fastmcp for Go
github.com/malcolmston/fastmcp
Build Model Context Protocol servers, fast.
GitHubports jlowin/fastmcp
A from-scratch, standard-library-only framework for building MCP (Model Context Protocol) servers in Go — an idiomatic port of Python's FastMCP. Register tools, resources and prompts as ordinary Go functions; the JSON-RPC 2.0 plumbing, reflected JSON schemas and transports (stdio + HTTP) are handled for you.
Install
shell
$ go get github.com/malcolmston/fastmcpQuick start
main.go
type AddArgs struct {
A int `json:"a"`
B int `json:"b"`
}
s := fastmcp.New("demo", fastmcp.WithVersion("1.0.0"))
s.Tool("add", "Add two integers together",
func(ctx context.Context, args AddArgs) (any, error) {
return args.A + args.B, nil
})
s.Run(context.Background())Features
- Register tools from plain Go funcs — args & JSON schema reflected from struct tags
- Resources and prompts with the same ergonomic registration
- Newline-delimited JSON-RPC 2.0 over stdio (the default transport)
- Streamable HTTP transport via
ServeHTTP/HTTPHandler - Server options:
WithVersion,WithInstructions - Zero third-party dependencies — Go standard library only