Zero dependencies. Single binary. Go-native.

Build AI tools
in Go

A zero-dependency MCP framework that turns any Go program into an AI-accessible service. Tools, resources, and prompts over stdio or Streamable HTTP — with clients for both. Compile, ship, connect.

greeter/main.go
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()  // stdio — or srv.ListenAndServe(":8080") for HTTP
}
0
dependencies
11
MCP methods
2
transports — stdio & HTTP
<1ms
cold start
~5MB
memory

Turn any Go program into an
AI-accessible service

Register tools, resources, and prompts. The AI client discovers them automatically over stdio or HTTP. Or connect to other MCP servers yourself with the built-in clients.

Database Explorer

Wrap PostgreSQL or MySQL as read-only MCP tools. The AI explores schemas, runs queries, and analyzes data — safely.

System Monitor

Expose CPU, memory, and disk as resources. The AI checks system health, diagnoses issues, and monitors trends.

Kubernetes Operator

Wrap kubectl as MCP tools. The AI describes deployments, fetches logs, and diagnoses cluster issues — without cluster admin.

API Integration

Bridge any REST API to AI. Give agents access to GitHub, Stripe, Slack — any HTTP endpoint becomes a callable tool.

HTTP-Native Server

Serve MCP over Streamable HTTP — one handler, any port. Optional Bearer auth and Origin allowlist built in.

MCP Client Too

Connect to any MCP server over HTTP or spawn one over stdio — the same typed Client interface for both.

Filesystem Navigator

Give AI scoped file access. Read, list, and search files — with path traversal protection built in.

Anything with Go

Go's ecosystem is the limit. gRPC services, crypto operations, image processing — if you can write it in Go, the AI can call it.

Database Explorer

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))
    },
})

System Resources

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
    },
})

Three primitives. Infinite possibilities.

Tools for actions. Resources for data. Prompts for templates. Register them, the framework handles the rest.

Tools

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.

Resources

Readable data sources identified by URI. The AI lists them via resources/list and reads them via resources/read. MIME types included.

Prompts

Pre-defined conversation templates. The AI requests them by name with arguments via prompts/get. Returns formatted messages ready for the chat.

Two transports. One framework.

The same server runs over stdio or Streamable HTTP — and the built-in clients talk to either.

server — stdio or HTTP
// stdio — the default, for local AI clients
srv.Run()

// Streamable HTTP — for remote access
srv.SetAuthToken(token)            // optional
srv.SetAllowedOrigins(origins)     // optional
srv.ListenAndServe(":8080")

// or mount on your own mux:
mux.Handle("/mcp", srv.Handler())
client — HTTP or subprocess
// connect to a remote server
c := gomcp.NewHTTPClientWithToken(url, token)

// or spawn a local one
c, _ := gomcp.NewStdioClient("./my-server")

c.Initialize(ctx, "client", "1.0")
tools, _ := c.ListTools(ctx)
out, _  := c.CallTool(ctx, "greet", args)

Full MCP coverage

2026-07-28 plus the legacy initialize handshake. Not a subset. Not a work-in-progress. Backward compatible.

MethodDescriptionStatus
server/discover2026-07-28 capability probe — versions, identity, cache hints✓
initializeLegacy handshake — reports server name, version, capabilities✓
notifications/initializedClient ready notification — consumed silently✓
pingLiveness check kept for older clients✓
tools/listReturns metadata for all registered tools✓
tools/callDispatches a call to the matching tool handler✓
resources/listReturns metadata for all registered resources✓
resources/readReads a resource by URI✓
resources/templates/listEmpty catalog — spec-compliant probe response✓
prompts/listReturns metadata for all registered prompts✓
prompts/getBuilds a prompt from arguments✓

One command. Zero dependencies.

Compiles to a single static binary. Ships in any container. Connects to any MCP client.

$ go get github.com/BackendStack21/go-mcp

102 tests. 91.9% coverage. View on GitHub →