MCPcopy
hub / github.com/micro/go-micro

github.com/micro/go-micro @v6.3.13 sqlite

repository ↗ · DeepWiki ↗ · release v6.3.13 ↗
6,347 symbols 23,956 edges 627 files 2,360 documented · 37%
README

Go Micro Go.Dev reference Go Report Card Discord

Go Micro is an agent harness and service framework for Go.

Community: questions, ideas, or just want to build alongside us? Join the Discord.

A harness is the runtime around an agent: the tools it can call, the memory it keeps, the guardrails that bound it, the workflows that trigger it, the services it depends on, and the protocols other agents use to reach it.

Go Micro gives you the harness as Go code. Build an agent and it gets a model, memory, tools, planning, delegation, guardrails, and service discovery; it is reachable over MCP and A2A. Write services and every endpoint becomes an AI-callable tool. Orchestrate the deterministic parts with durable flows. Agents, services, and flows share one runtime because an agent is a distributed system, and building one is building a service.

Sponsors

     

Want to support Go Micro and see your logo here? Become a sponsor — reach out on Discord.

Commercial Support

Running Go Micro in production, or building on it and want help? Paid support, consulting, training, and retainers are available directly from the maintainer — and they're what keep the project maintained. See Support for the tiers, or open a request.

Contents

Quick Start

Install the CLI:

# Binary (no Go required)
curl -fsSL https://go-micro.dev/install.sh | sh

# Or with Go
go install go-micro.dev/v6/cmd/micro@latest

Fastest start — no API key

Scaffold a service, run it, call it:

micro new helloworld
cd helloworld
micro run

Then in another terminal:

curl -X POST http://localhost:8080/api/helloworld/Helloworld.Call \
  -H 'Content-Type: application/json' -d '{"name":"World"}'

This install → scaffold → run → call path is covered by no-secret CI harnesses. To verify just the local installer and first-run CLI boundaries without network access or provider keys, use:

make install-smoke

To run the broader local contract (including the 0→hero services → agents → workflows path, chat/inspect CLI boundaries, and deploy dry-run), use:

make harness

First agent on-ramp

After install and the first micro new/micro run smoke check, take the walkable agent path in this order:

  1. No-secret first-agent transcript — run the maintained support agent with a mock model and see services → agents → workflows succeed without a key.
  2. Your First Agent — build a service-backed agent and talk to it with micro chat.
  3. Debugging your agent — use micro agent inspect, run history, memory, and provider checks when the first conversation does something unexpected.
  4. 0→hero Reference — complete the services → agents → workflows loop with scaffold, run, chat, inspect, flow history, and deploy dry-run commands that match the maintained harness.

Generate from a prompt — with an LLM key

Set a provider key, describe what you want, and the AI designs services, writes handlers, compiles, and starts them:

export ANTHROPIC_API_KEY=sk-ant-...   # or OPENAI_API_KEY, GEMINI_API_KEY, ...
micro run --prompt "a task management system with categories" --provider anthropic

The AI designs the architecture, you review it, then it generates handlers with real business logic, compiles them, and starts them:

Services:
  ● task — Task management with status tracking
  ● project — Project organization

Generate? [Y/n]

Micro
  Services:
    ● task
    ● project
  Agents:
    ◆ agent

Then talk to your services from the console:

> Create a project called Launch, then add three tasks to it

→ project_Project_Create({"name":"Launch"})
← {"record":{"id":"p1..."},"success":true}
→ task_Task_Create({"title":"Design specs","project_id":"p1..."})
→ task_Task_Create({"title":"Write code","project_id":"p1..."})
→ task_Task_Create({"title":"Ship it","project_id":"p1..."})

Created project Launch and added three tasks to it.

When you need a capability that doesn't exist, the agent generates a new service mid-conversation:

> I need to track shipping. Create a shipment for order 123 to London.

  ⚡ generating shipping service...
  ✓ shipping
  → shipping_Shipping_Create({"order_id":"123","destination":"London"})
  ← {"record":{"id":"xyz...","status":"pending"}}

  Created shipment for order 123 going to London.

Edit the generated code by hand at any time — re-running preserves your changes. Read more.

Why an Agent Harness

The first wave of agent frameworks helped developers put a model in a loop. The next problem is operating that loop: connecting it to real tools, scoping what it can touch, preserving state, routing work to specialists, recovering from failures, observing what happened, and letting other agents call it. That is harness work.

Go Micro's answer is to make the harness the same thing you already deploy:

  • Tools are services — endpoint metadata becomes tool schema; RPC executes the call.
  • Agents are services — they register, discover, load-balance, and expose Agent.Chat.
  • Workflows are durable code paths — use flows when the path is known; dispatch to agents when it is not.
  • Safety lives at executionMaxSteps, LoopLimit, ApproveTool, and tool wrappers run where actions happen.
  • Interop is built in — MCP for tools, A2A for agents, x402 for paid tools.

Use Go Micro when the agent has to operate a system, not just answer a prompt.

Writing Services

Under the hood, a service is a struct with methods. Doc comments and @example tags become tool descriptions for AI agents automatically.

package main

import (
    "context"

    "go-micro.dev/v6"
)

type Request struct {
    Name string `json:"name"`
}

type Response struct {
    Message string `json:"message"`
}

type Say struct{}

// Hello greets a person by name.
// @example {"name": "Alice"}
func (h *Say) Hello(ctx context.Context, req *Request, rsp *Response) error {
    rsp.Message = "Hello " + req.Name
    return nil
}

func main() {
    service := micro.NewService("greeter")
    service.Handle(new(Say))
    service.Run()
}

Run it and everything is accessible — REST, gRPC, MCP, agent playground:

micro run
# Dashboard:   http://localhost:8080
# API:         http://localhost:8080/api/{service}/{method}
# Agent:       http://localhost:8080/agent
# MCP Tools:   http://localhost:8080/mcp/tools

You can also scaffold a service from a template:

micro new helloworld
micro new contacts --template crud

Building Agents

An Agent is a service with an LLM inside it. It has a proto-defined Agent.Chat RPC endpoint, registers in the registry, and is callable like any service:

agent := micro.NewAgent("task-mgr",
    micro.AgentServices("task", "project"),
    micro.AgentPrompt("You manage tasks and projects. You understand deadlines and priorities."),
    micro.AgentProvider("anthropic"),
)
agent.Run()

The agent discovers its services from the registry, scopes its tools to their endpoints, and maintains conversation memory in the store. It registers itself so micro chat and other agents can find it.

// Programmatic interaction
resp, _ := agent.Ask(ctx, "What tasks are overdue?")
fmt.Println(resp.Reply)

Multiple agents coordinate via RPC — each is a service with an Agent.Chat endpoint. micro chat routes to the right one.

micro agent list                    # list registered agents
micro call task-mgr Agent.Chat '{"message": "What tasks are overdue?"}'

Plan & Delegate

Every agent gets two built-in harness capabilities, exposed as tools — no extra setup or separate graph runtime:

  • plan — for multi-step work, the agent records an ordered plan in its store-backed memory and stays oriented across turns.
  • delegate — the agent hands a self-contained subtask to another agent. If a registered agent already owns the relevant services, the hand-off goes over RPC to that agent; otherwise a focused, short-lived sub-agent is created for the subtask with its own isolated context.

This keeps intelligence distributed: an agent doesn't need to know how to do everything, only who does. See examples/agent-plan-delegate.

// A sub-agent is just an agent — created with New, talked to with Ask.
// delegate-first: reuse a registered agent, or spin up a focused one.
resp, _ := agent.Ask(ctx, "Plan the launch, create the tasks, and have comms notify the owner.")

Batteries included, pluggable

Just as a service composes pluggable abstractions (registry, broker, store), an agent composes a model, memory, and tools — sane defaults out of the box, each swappable.

agent := micro.NewAgent("assistant",
    micro.AgentProvider("anthropic"),                 // model — swap the provider
    micro.AgentCompactMemory(40, 12),                 // memory — durable, summarized, recallable
    micro.AgentTool("weather", "Get the weather for a city",
        map[string]any{"city": map[string]any{"type": "string"}},
        func(ctx context.Context, in map[string]any) (string, error) {
            return getWeather(in["city"].(string))    // tools beyond your services — any function
        }),
    micro.AgentMaxSteps(8),                            // guardrails
)

Memory is durable and store-backed by default (Postgres, NATS KV, or file), so an agent picks up where it left off after a restart — or supply your own with AgentMemory. Long-running agents can opt into AgentCompactMemory(maxMessages, keepRecent): older turns are collapsed into a deterministic summary, recent turns stay verbatim, and relevant archived turns are recalled on future asks without replaying the whole conversation. Tools are your services automatically, plus any function you register with AgentTool.

Paid tools (x402)

Every endpoint is an AI-callable tool — and it can be a paid tool. Go Micro supports x402, the HTTP 402 payment standard for agents, so a tool can require a stablecoin payment and an agent can settle it autonomously. It's opt-in and carries no crypto in the framework: verification is delegated to a pluggable facilitator (Coinbase, Alchemy, self-hosted), so Base and Solana are just different facilitators.

# Charge for tool calls at the MCP gateway (off unless you set a pay-to address)
micro mcp serve --x402_pay_to 0xYourAddress --x402_network solana --x402_amount 10000
# Per-tool amounts via a config file
micro mcp serve --x402_config x402.json

See the Payments (x402) guide.

Reachable by other agents (A2A)

Within a Go Micro system, agents reach each other over RPC. To make them reachable by agents on other frameworks, Go Micro speaks the Agent2Agent (A2A) protocol. The A2A gateway discovers your agents from the registry, generates an Agent Card for each from its metadata — the same way the MCP gateway derives tools from service endpoints — and translates incoming A2A tasks to the agent's Agent.Chat RPC. No per-agent code: register an agent and it's reachable over A2A.

micro a2a serve --address :4000    # gateway: expose every registered agent over A2A
micro a2a list                     # agents and their Agent Card URLs

Or skip the gateway entirely — an agent can serve its own A2A endpoint directly, handling tasks in-process:

micro.NewAgent("task-mgr", micro.AgentServices("task"), micro.AgentA2A(":4000"))

It works both ways. To call an agent on another framework, an a2a.Client is wired into the two places that hand off work: flow.A2A(url) as a workflow step (the cross-framework Dispatch), and delegate to an http(s) URL from inside an agent.

MCP exposes your services as tools; A2A exposes your agents as agents. See the A2A guide.

Features

AI

Feature Details
Agents micro.NewAgent() — intelligent

Extension points exported contracts — how you extend this code

Closer (Interface)
Closer handle client close. [6 implementers]
client/client.go
Watcher (Interface)
Watcher is an interface that returns updates about services within the registry. [12 implementers]
registry/watcher.go
Registry (Interface)
The registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, [7 …
registry/registry.go
TransportService (Interface)
Client API for Transport service [45 implementers]
transport/grpc/proto/transport.pb.micro.go
Store (Interface)
Store is a data storage interface. [7 implementers]
store/store.go
Codec (Interface)
Codec encodes/decodes various types of messages used within go-micro. ReadHeader and ReadBody are called in pairs to rea [26 …
codec/codec.go
Store (Interface)
Store is an event store interface [7 implementers]
events/events.go
ServerService (Interface)
Client API for Server service [6 implementers]
server/proto/server.pb.micro.go

Core symbols most depended-on inside this repo

Errorf
called by 1083
logger/helper.go
Fatalf
called by 1016
logger/helper.go
Fatal
called by 447
logger/helper.go
Error
called by 405
broker/broker.go
P
called by 193
cmd/protoc-gen-micro/plugin/micro/micro.go
P
called by 183
cmd/protoc-gen-micro/generator/generator.go
Unmarshal
called by 181
codec/codec.go
String
called by 179
cache/cache.go

Shape

Method 2,609
Function 2,498
Struct 933
FuncType 124
Interface 122
TypeAlias 23
Route 20
Class 18

Languages

Go99%
Python1%

Modules by API surface

cmd/protoc-gen-micro/generator/generator.go155 symbols
debug/proto/debug.pb.go100 symbols
debug/proto/debug.pb.micro.go89 symbols
gateway/a2a/a2a.go69 symbols
examples/mcp/platform/main.go68 symbols
server/server.go63 symbols
micro.go63 symbols
broker/rabbitmq/options.go55 symbols
cmd/protoc-gen-micro/examples/greeter/greeter.pb.micro.go48 symbols
client/client.go48 symbols
server/proto/server.pb.go45 symbols
flow/steps.go44 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

dario.cat/mergov1.0.2 · 1×
filippo.io/edwards25519v1.1.0 · 1×
github.com/armon/go-metricsv0.4.1 · 1×
github.com/beorn7/perksv1.0.1 · 1×
github.com/bitly/go-simplejsonv0.5.0 · 1×
github.com/bmizerany/assertv0.0.0-2016061122193 · 1×
github.com/cespare/xxhash/v2v2.3.0 · 1×
github.com/coreos/go-semverv0.3.0 · 1×
github.com/coreos/go-systemd/v22v22.3.2 · 1×
github.com/cpuguy83/go-md2man/v2v2.0.5 · 1×
github.com/davecgh/go-spewv1.1.2-0.20180830191 · 1×

Datastores touched

dbDatabase · 1 repos
d1Database · 1 repos
d2Database · 1 repos
myappDatabase · 1 repos
usersDatabase · 1 repos
testMicroDatabase · 1 repos
appDatabase · 1 repos
dbnameDatabase · 1 repos

For agents

$ claude mcp add go-micro \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact