Price Per TokenPrice Per Token

MCP Golang Server

by metoro-io

0

About

mcp-golang is an unofficial implementation of the Model Context Protocol (MCP) in Go that enables developers to build MCP servers and clients with minimal boilerplate code. Key capabilities include: - Type-safe tool arguments defined as native Go structs with automatic JSON schema generation, deserialization, and error handling - Multiple built-in transports including stdio for full feature support and HTTP for stateless communication, with the ability to implement custom transports - Modular architecture split into transport, protocol, and server/client components that can be used independently or together - Bi-directional support for both server and client implementations through stdio transport - Automatic generation of MCP endpoints leaving developers to focus only on implementing tools, prompts, and resources

README

[](https://pkg.go.dev/github.com/metoro-io/mcp-golang) [](https://goreportcard.com/report/github.com/metoro-io/mcp-golang)

mcp-golang

mcp-golang is an unofficial implementation of the Model Context Protocol in Go.

Write MCP servers and clients in golang with a few lines of code.

Docs at https://mcpgolang.com

Highlights

  • 🛡️Type safety - Define your tool arguments as native go structs, have mcp-golang handle the rest. Automatic schema generation, deserialization, error handling etc.
  • 🚛 Custom transports - Use the built-in transports (stdio for full feature support, HTTP for stateless communication) or write your own.
  • Low boilerplate - mcp-golang generates all the MCP endpoints for you apart from your tools, prompts and resources.
  • 🧩 Modular - The library is split into three components: transport, protocol and server/client. Use them all or take what you need.
  • 🔄 Bi-directional - Full support for both server and client implementations through stdio transport.
  • Example Usage

    Install with go get github.com/metoro-io/mcp-golang

    Server Example

    package main

    import ( "fmt" "github.com/metoro-io/mcp-golang" "github.com/metoro-io/mcp-golang/transport/stdio" )

    // Tool arguments are just structs, annotated with jsonschema tags // More at https://mcpgolang.com/tools#schema-generation type Content struct { Title string json:"title" jsonschema:"required,description=The title to submit" Description *string json:"description" jsonschema:"description=The description to submit" } type MyFunctionsArguments struct { Submitter string json:"submitter" jsonschema:"required,description=The name of the thing calling this tool (openai, google, claude, etc)" Content Content json:"content" jsonschema:"required,description=The content of the message" }

    func main() { done := make(chan struct{})

    server := mcp_golang.NewServer(stdio.NewStdioServerTransport()) err := server.RegisterTool("hello", "Say hello to a person", func(arguments MyFunctionsArguments) (*mcp_golang.ToolResponse, error) { return mcp_golang.NewToolResponse(mcp_golang.NewTextContent(fmt.Sprintf("Hello, %server!", arguments.Submitter))), nil }) if err != nil { panic(err) }

    err = server.RegisterPrompt("promt_test", "This is a test prompt", func(arguments Content) (*mcp_golang.PromptResponse, error) { return mcp_golang.NewPromptResponse("description", mcp_golang.NewPromptMessage(mcp_golang.NewTextContent(fmt.Sprintf("Hello, %server!", arguments.Title)), mcp_golang.RoleUser)), nil }) if err != nil { panic(err) }

    err = server.RegisterResource("test://resource", "resource_test", "This is a test resource", "application/json", func() (*mcp_golang.ResourceResponse, error) { return mcp_golang.NewResourceResponse(mcp_golang.NewTextEmbeddedResource("test://resource", "This is a test resource", "application/json")), nil })

    err = server.Serve() if err != nil { panic(err) }

    <-done }

    HTTP Server Example

    You can also create an HTTP-based server using either the standard HTTP transport or Gin framework:

    // Standard HTTP
    transport := http.NewHTTPTransport("/mcp")
    transport.WithAddr(":8080")
    server := mcp_golang.NewServer(transport)

    // Or with Gin framework transport := http.NewGinTransport() router := gin.Default() router.POST("/mcp", transport.Handler()) server := mcp_golang.NewServer(transport)

    Note: HTTP transports are stateless and don't support bidirectional features like notifications. Use stdio transport if you need those features.

    Client Example

    Checkout the examples/client directory for a more complete example.

    ``go package main

    import ( "context" "log" mcp "github.com/metoro-io/mcp-golang" "github.com/metoro-io/mcp-golang/transport/stdio" )

    // Define type-safe arguments type CalculateArgs struct { Operation string json:"operation" A int json:"a"` B

    Related MCP Servers

    AI Research Assistant

    AI Research Assistant

    hamid-vakilzadeh

    AI Research Assistant provides comprehensive access to millions of academic papers through the Semantic Scholar and arXiv databases. This MCP server enables AI coding assistants to perform intelligent literature searches, citation network analysis, and paper content extraction without requiring an API key. Key features include: - Advanced paper search with multi-filter support by year ranges, citation thresholds, field of study, and publication type - Title matching with confidence scoring for finding specific papers - Batch operations supporting up to 500 papers per request - Citation analysis and network exploration for understanding research relationships - Full-text PDF extraction from arXiv and Wiley open-access content (Wiley TDM token required for institutional access) - Rate limits of 100 requests per 5 minutes with options to request higher limits through Semantic Scholar

    Web & Search
    12 8
    Linkup

    Linkup

    LinkupPlatform

    Linkup is a real-time web search and content extraction service that enables AI assistants to search the web and retrieve information from trusted sources. It provides source-backed answers with citations, making it ideal for fact-checking, news gathering, and research tasks. Key features of Linkup: - Real-time web search using natural language queries to find current information, news, and data - Page fetching to extract and read content from any webpage URL - Search depth modes: Standard for direct-answer queries and Deep for complex research across multiple sources - Source-backed results with citations and context from relevant, trustworthy websites - JavaScript rendering support for accessing dynamic content on JavaScript-heavy pages

    Web & Search
    2 24

    context7

    huynguyen03dev

    5