A zero-dependency MCP server framework that turns any Go program into an AI-accessible service. Tools, resources, and prompts over stdio. Compile, ship, connect.
package main import ( "context" "fmt" "github.com/BackendStack21/go-mcp/gomcp" ) func main() { srv := gomcp.NewServer("greeter", "1.0.0") srv.AddTool(gomcp.Tool{ Name: "greet", Description: "Greet a person by name", InputSchema: gomcp.InputSchema{ Type: "object", Properties: map[string]gomcp.Property{ "name": {Type: "string"}, }, }, Handler: func(ctx context.Context, args map[string]any) (string, error) { return fmt.Sprintf("Hello, %s!", args["name"]), nil }, }) srv.Run() // blocks, reading JSON-RPC from stdin }
Register tools, resources, and prompts. The AI client discovers them automatically. All over stdin/stdout.
Wrap PostgreSQL or MySQL as read-only MCP tools. The AI explores schemas, runs queries, and analyzes data — safely.
Expose CPU, memory, and disk as resources. The AI checks system health, diagnoses issues, and monitors trends.
Wrap kubectl as MCP tools. The AI describes deployments, fetches logs, and diagnoses cluster issues — without cluster admin.
Bridge any REST API to AI. Give agents access to GitHub, Stripe, Slack — any HTTP endpoint becomes a callable tool.
Give AI scoped file access. Read, list, and search files — with path traversal protection built in.
Go's ecosystem is the limit. gRPC services, crypto operations, image processing — if you can write it in Go, the AI can call it.
Give AI agents safe, read-only SQL access. Query the schema, list tables, run SELECT statements — all scoped and auditable. The AI sees your database without touching your credentials.
srv.AddTool(gomcp.Tool{ Name: "db_query", Description: "Run a read-only SQL query", InputSchema: gomcp.InputSchema{ Type: "object", Properties: map[string]gomcp.Property{ "query": {Type: "string"}, }, }, Handler: func(ctx context.Context, args map[string]any) (string, error) { // Validate, execute, return formatted results return runQuery(ctx, args["query"].(string)) }, })
Expose any server data as MCP resources. CPU, memory, process info, disk usage — read on demand via resources/read. The AI monitors your infrastructure without SSH access.
srv.AddResource(gomcp.Resource{ URI: "system://cpu", Name: "CPU Usage", MimeType: "application/json", Handler: func(ctx context.Context) (string, error) { info := map[string]any{ "cores": runtime.NumCPU(), "percent": getCPUPercent(), } data, _ := json.Marshal(info) return string(data), nil }, })
Tools for actions. Resources for data. Prompts for templates. Register them, the framework handles the rest.
Callable functions with typed input schemas. The AI discovers them via tools/list and invokes them via tools/call. Return text results the AI can reason about.
Readable data sources identified by URI. The AI lists them via resources/list and reads them via resources/read. MIME types included.
Pre-defined conversation templates. The AI requests them by name with arguments via prompts/get. Returns formatted messages ready for the chat.
All eight MCP methods implemented. Not a subset. Not a work-in-progress. Complete.
Compiles to a single static binary. Ships in any container. Connects to any MCP client.
go get github.com/BackendStack21/go-mcp
15 tests. 4 example servers. View on GitHub →