opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

A Go implementation of MCP for connecting LLM apps to tools and data
GitHub RepoViews0

Project Description

View on GitHub

Wiring Your LLM Apps to Tools and Data with Go

You've got an LLM application, and now you want it to actually do things—call a calculator, look up data, run a tool. The Model Context Protocol (MCP) is the standard that makes that connection possible, but implementing the protocol from scratch is a lot of plumbing you probably don't want to write. That's where mcp-go comes in: a Go implementation of MCP that handles the protocol details so you can focus on building the tools themselves.

What It Does

mcp-go is a Go library for building MCP servers—the piece that exposes tools, resources, and prompts to LLM applications. It gives you a high-level interface for defining what your server offers, and then takes care of the server management and protocol mechanics underneath.

The core objects are a server (created with server.NewMCPServer), tools (defined with mcp.NewTool and attached via s.AddTool), plus resources and prompts. You write a handler function for each tool, and the library routes incoming calls to it. Servers can run over stdio (server.ServeStdio) or other transports, and there's support for session management, request hooks, and tool handler middleware if you need more control.

Why It's Cool

  • The boilerplate is genuinely minimal. The README's whole first example—a working "hello world" tool server—fits in about thirty lines. You define a tool, give it a description and a typed parameter, register a handler, and serve. That's the entire surface area for the common case.

  • Typed parameter helpers cut down on ceremony. Instead of hand-parsing arguments, you declare mcp.WithString("name", mcp.Required(), mcp.Description(...)) and then call request.RequireString("name") in your handler. It's a small thing, but it's the kind of ergonomics that make a library pleasant to use day to day.

  • It takes sessions seriously. The extras section covers basic session handling, per-session tools, tool filtering, and working with context. If you're building something where different users or connections need different capabilities, the library gives you hooks for that rather than forcing you to bolt it on.

  • The honesty is refreshing. The README says it "aims" to provide a full implementation of the core MCP specification—with explicit emphasis on aims—and flags that it's under active development alongside a spec that's itself still moving. You know exactly what you're getting into.

  • It's built for Go developers specifically. If your stack is Go, you're not adapting a Python or TypeScript SDK. The API reads like idiomatic Go, and the examples are ready to paste into a main.go.

How to Try It

  1. Install the library:
go get github.com/mark3labs/mcp-go
  1. Create a server and define a tool. Here's the minimal version from the README:
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/mark3labs/mcp-go/mcp"
    "github.com/mark3labs/mcp-go/server"
)

func main() {
    s := server.NewMCPServer(
        "Demo",
        "1.0.0",
        server.WithToolCapabilities(false),
    )

    tool := mcp.NewTool("hello_world",
        mcp.WithDescription("Say hello to someone"),
        mcp.WithString("name",
            mcp.Required(),
            mcp.Description("Name of the person to greet"),
        ),
    )

    s.AddTool(tool, helloHandler)

    if err := server.ServeStdio(s); err != nil {
        fmt.Fprintf(os.Stderr, "Server error: %v
", err)
    }
}

func helloHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
    name, err := request.RequireString("name")
    if err != nil {
        return mcp.NewToolResultError(err.Error()), nil
    }

    return mcp.NewToolResultText(fmt.Sprintf("Hello, %s!", name)), nil
}
  1. Once that runs, the README's quickstart walks through a calculator example with server.WithRecovery() added, and the extras section covers transports, OAuth protected resource metadata, session management, request hooks, and middleware.

You can find the full docs, examples, and a tutorial video over at github.com/mark3labs/mcp-go. There's also a Discord if you want to ask questions directly.

Final Thoughts

mcp-go is a good fit if you're a Go developer who wants to expose tools to LLM apps without reimplementing MCP yourself. The API is small, the examples are copy-paste ready, and the extras are there when you need them. Just go in with realistic expectations: this is an actively developed library tracking a spec that's still evolving, so some advanced capabilities are in progress. For core tool-serving work, though, it does the job and stays out of your way.

Back to Projects
Project ID: mcp-goLast updated: November 30, 2026 at 02:48 AM