Track MCP LogoTrack MCP
Track MCP LogoTrack MCP

The world's largest repository of Model Context Protocol servers. Discover, explore, and submit MCP tools.

Product

  • Categories
  • Top MCP
  • New & Updated
  • Submit MCP

Company

  • About

Legal

  • Privacy Policy
  • Terms of Service
  • Cookie Policy

© 2026 TrackMCP. All rights reserved.

Built with ❤️ by Krishna Goyal

    Mcp Go Sdk

    This SDK provides a Go implementation of the Machine Control Protocol (MCP), enabling bidirectional communication between clients and servers for tool execution, resource access, and prompt handling. Based on https://github.com/modelcontextprotocol SDK

    5 stars
    Go
    Updated Sep 17, 2025

    Table of Contents

    • Features
    • Installation
    • Quick Start
    • Usage Guide
    • Creating a Server
    • Adding Tools
    • Adding Resources
    • Adding Prompts
    • Transport Configuration
    • Example Applications
    • Contributing
    • License

    Table of Contents

    • Features
    • Installation
    • Quick Start
    • Usage Guide
    • Creating a Server
    • Adding Tools
    • Adding Resources
    • Adding Prompts
    • Transport Configuration
    • Example Applications
    • Contributing
    • License

    Documentation

    MCP Go SDK

    This SDK provides a Go implementation of the Model Context Protocol (MCP), enabling bidirectional communication between clients and servers for tool execution, resource access, and prompt handling.

    Features

    • Transport Layer
    • Multiple transport options (stdio, SSE, WebSocket)
    • Bidirectional communication
    • Configurable endpoints and settings
    • Server Implementation
    • Tool registration and execution
    • Resource pattern matching and access
    • Prompt template rendering
    • Session management
    • Reflection-based handler invocation
    • Core Protocol Types
    • JSON-RPC message handling
    • MCP-specific types (tools, resources, prompts)
    • Capabilities and initialization

    Installation

    bash
    go get github.com/SetiabudiResearch/mcp-go-sdk

    Quick Start

    Here's a simple example of creating an MCP server:

    go
    package main
    
    import (
        "context"
        "log"
        "github.com/SetiabudiResearch/mcp-go-sdk/pkg/mcp/server"
        "github.com/SetiabudiResearch/mcp-go-sdk/pkg/mcp/transport"
    )
    
    func main() {
        // Create a new server
        srv := server.NewServer("Example Server")
    
        // Add a tool
        srv.AddTool("greet", func(name string) string {
            return "Hello, " + name + "!"
        }, "Greet a person")
    
        // Create a session
        session := server.NewSession(context.Background(), srv)
    
        // Create and start a transport
        t := transport.NewStdioTransport(session)
        if err := t.Start(); err != nil {
            log.Fatal(err)
        }
    }

    Usage Guide

    Creating a Server

    go
    // Create a new server with a name
    srv := server.NewServer("My Server")
    
    // Optionally configure server capabilities
    srv.WithCapabilities(protocol.ServerCapabilities{
        SupportsAsync: true,
    })

    Adding Tools

    go
    // Add a synchronous tool
    srv.AddTool("myTool", func(arg1 string, arg2 int) (string, error) {
        return fmt.Sprintf("Processed %s with %d", arg1, arg2), nil
    }, "Tool description")
    
    // Add an asynchronous tool
    srv.AddAsyncTool("longRunningTool", func(params string) error {
        // Long-running operation
        return nil
    }, "Async tool description")

    Adding Resources

    go
    // Add a resource with pattern matching
    srv.AddResource("files/{path}", func(path string) ([]byte, error) {
        return ioutil.ReadFile(path)
    }, "Access files")
    
    // Resource patterns support multiple parameters
    srv.AddResource("api/{version}/{endpoint}", func(version, endpoint string) (interface{}, error) {
        return callAPI(version, endpoint)
    }, "API access")

    Adding Prompts

    go
    // Add a simple text prompt
    srv.AddPrompt("confirm", func(action string) string {
        return fmt.Sprintf("Are you sure you want to %s?", action)
    }, "Confirmation prompt")
    
    // Add a multi-message prompt
    srv.AddPrompt("chat", func(context string) []protocol.PromptMessage {
        return []protocol.PromptMessage{
            {
                Role: protocol.RoleAssistant,
                Content: protocol.TextContent{
                    Type: "text",
                    Text: "How can I help you with " + context + "?",
                },
            },
        }
    }, "Chat prompt")

    Transport Configuration

    go
    // Create a session
    session := server.NewSession(context.Background(), srv)
    
    // Stdio transport (for CLI applications)
    t := transport.NewStdioTransport(session)
    
    // WebSocket transport (for web applications)
    t := transport.NewWebSocketTransport(session, transport.WithAddress(":8080"))
    
    // Server-Sent Events transport (for web browsers)
    t := transport.NewSSETransport(session, transport.WithAddress(":8080"))
    
    // Start the transport
    if err := t.Start(); err != nil {
        log.Fatal(err)
    }

    Example Applications

    See the examples directory for complete example applications:

    • File Server: A complete file server implementation using MCP
    • Calculator: A simple calculator service
    • Chat Bot: An example chat bot using prompts

    Contributing

    Contributions are welcome! Please feel free to submit a Pull Request.

    License

    This project is licensed under the MIT License - see the LICENSE file for details.

    Similar MCP

    Based on tags & features

    • MC

      Mcpjungle

      Go·
      617
    • AN

      Anyquery

      Go·
      1.4k
    • YU

      Yutu

      Go·
      317
    • MC

      Mcp Cyclops

      Go·
      29

    Trending MCP

    Most active this week

    • PL

      Playwright Mcp

      TypeScript·
      22.1k
    • SE

      Serena

      Python·
      14.5k
    • MC

      Mcp Playwright

      TypeScript·
      4.9k
    • MC

      Mcp Server Cloudflare

      TypeScript·
      3.0k
    View All MCP Servers

    Similar MCP

    Based on tags & features

    • MC

      Mcpjungle

      Go·
      617
    • AN

      Anyquery

      Go·
      1.4k
    • YU

      Yutu

      Go·
      317
    • MC

      Mcp Cyclops

      Go·
      29

    Trending MCP

    Most active this week

    • PL

      Playwright Mcp

      TypeScript·
      22.1k
    • SE

      Serena

      Python·
      14.5k
    • MC

      Mcp Playwright

      TypeScript·
      4.9k
    • MC

      Mcp Server Cloudflare

      TypeScript·
      3.0k