internal/website/docs/guides/micro-run.md
micro run provides a complete development environment for Go microservices.
Note: This guide focuses on
micro runfeatures. For a comparison withmicro serverand gateway architecture details, see the CLI & Gateway Guide.
micro new helloworld
cd helloworld
micro run
Open http://localhost:8080 to see your service.
When you run micro run, you get:
| URL | Description |
|---|---|
| http://localhost:8080 | Web dashboard - browse and call services |
| http://localhost:8080/agent | Agent playground - AI chat with MCP tools |
| http://localhost:8080/api | API explorer - browse endpoints and schemas |
| http://localhost:8080/api/{service}/{method} | API gateway - HTTP to RPC proxy |
| http://localhost:8080/api/mcp/tools | MCP tools - list all services as AI tools |
| http://localhost:8080/auth/tokens | Token management - create and manage API tokens |
| http://localhost:8080/auth/scopes | Scope management - restrict endpoint access |
| http://localhost:8080/auth/users | User management - create and manage users |
| http://localhost:8080/health | Health checks - aggregated service health |
| http://localhost:8080/services | Service list - JSON |
Plus:
admin/micro)--mcp-addressThe gateway converts HTTP requests to RPC calls. All API calls require authentication:
# Log in at http://localhost:8080 with admin/micro to get a session
# Or use a token for programmatic access:
curl -X POST http://localhost:8080/api/helloworld/Say.Hello \
-H "Authorization: Bearer <token>" \
-d '{"name": "World"}'
# Response
{"message": "Hello World"}
Create tokens at /auth/tokens. The default admin token has * scope (full access).
The agent playground at /agent lets you interact with your services using AI. Your services are automatically exposed as MCP (Model Context Protocol) tools — no configuration needed.
The MCP tools API is available at:
/api/mcp/tools — list all services as AI-callable tools/api/mcp/call — invoke a tool (service endpoint) by nameFor a dedicated MCP protocol listener (for external AI clients), use:
micro run --mcp-address :3000
By default, micro run watches for .go file changes and automatically rebuilds and restarts affected services.
micro run # Hot reload enabled (default)
micro run --no-watch # Disable hot reload
Changes are debounced (300ms) to handle rapid saves from editors.
For multi-service projects, create a micro.mu file to define services, dependencies, and environments.
# Service definitions
service users
path ./users
port 8081
service posts
path ./posts
port 8082
depends users
service web
path ./web
port 8089
depends users posts
# Environment configurations
env development
STORE_ADDRESS file://./data
DEBUG true
env production
STORE_ADDRESS postgres://localhost/db
DEBUG false
{
"services": {
"users": {
"path": "./users",
"port": 8081
},
"posts": {
"path": "./posts",
"port": 8082,
"depends": ["users"]
}
},
"env": {
"development": {
"STORE_ADDRESS": "file://./data"
}
}
}
| Property | Required | Description |
|---|---|---|
path | Yes | Directory containing the service (with main.go) |
port | No | Port the service listens on (enables health check waiting) |
depends | No | Services that must start first (space-separated in .mu, array in .json) |
When depends is specified, services start in topological order:
port, we wait for /health to return 200micro run # Uses 'development' (default)
micro run --env production # Uses 'production'
micro run --env staging # Uses 'staging'
MICRO_ENV=test micro run # Environment variable override
Environment variables from the config are injected into each service's environment.
On SIGINT (Ctrl+C) or SIGTERM:
If no micro.mu or micro.json exists:
main.go files are discovered recursivelyService logs are written to:
~/micro/logs/{service}-{hash}.logView logs:
micro logs # List available logs
micro logs users # Show logs for 'users' service
micro status # Show running services
micro stop users # Stop a specific service
The micro/blog project demonstrates a multi-service setup:
# micro.mu
service users
path ./users
port 8081
service posts
path ./posts
port 8082
depends users
service comments
path ./comments
port 8083
depends users posts
service web
path ./web
port 8089
depends users posts comments
Run it:
micro run github.com/micro/blog
micro run # Gateway on :8080, hot reload
micro run --address :3000 # Custom gateway port
micro run --no-gateway # Services only, no HTTP gateway
micro run --no-watch # Disable hot reload
micro run --env production # Use production environment
micro run --mcp-address :3000 # Enable MCP protocol gateway for AI clients
port for services to enable health check waiting/health returning 200 for reliable startup sequencing.go files trigger rebuilds; static assets don't