{"id":28426022,"url":"https://github.com/xiaoconstantine/mcp-go","last_synced_at":"2025-07-06T18:04:12.258Z","repository":{"id":264897887,"uuid":"894593049","full_name":"XiaoConstantine/mcp-go","owner":"XiaoConstantine","description":"Golang impl of mcp protocol","archived":false,"fork":false,"pushed_at":"2025-05-19T23:13:04.000Z","size":188,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-05T11:08:20.581Z","etag":null,"topics":["golang","modelcontextprotocol"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XiaoConstantine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-26T16:19:51.000Z","updated_at":"2025-04-23T02:46:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"bb5f9b4d-51f3-45fc-a27f-eccf285d6d18","html_url":"https://github.com/XiaoConstantine/mcp-go","commit_stats":null,"previous_names":["xiaoconstantine/mcp-go"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/XiaoConstantine/mcp-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiaoConstantine%2Fmcp-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiaoConstantine%2Fmcp-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiaoConstantine%2Fmcp-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiaoConstantine%2Fmcp-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XiaoConstantine","download_url":"https://codeload.github.com/XiaoConstantine/mcp-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiaoConstantine%2Fmcp-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262406202,"owners_count":23306101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","modelcontextprotocol"],"created_at":"2025-06-05T11:08:20.563Z","updated_at":"2025-06-28T09:32:06.621Z","avatar_url":"https://github.com/XiaoConstantine.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MCP-Go\n\n[![Unit and Integration Tests](https://github.com/XiaoConstantine/mcp-go/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/XiaoConstantine/mcp-go/actions/workflows/go.yml)\n[![codecov](https://codecov.io/gh/XiaoConstantine/mcp-go/graph/badge.svg?token=RFXBU53AH9)](https://codecov.io/gh/XiaoConstantine/mcp-go)\n\nA Go implementation of the Model Context Protocol (MCP), a standardized protocol for communication between LLM clients and context providers.\n\n## What is MCP?\n\nThe Model Context Protocol (MCP) is a standardized communication protocol that enables large language models (LLMs) to access contextual information and tools from external providers. It creates a clear interface between:\n\n- **LLM clients** (applications that interact with language models)\n- **Context providers** (services that provide data, functionality, or tools)\n\nKey features of MCP:\n\n- Bi-directional communication through a JSON-RPC based protocol\n- Support for resource discovery and reading\n- Tool invocation capabilities\n- Prompt templates\n- Notification system for resource updates\n- Structured logging\n\n## Overview\n\nThis library provides a complete implementation of the MCP specification in Go, including:\n\n- Client implementation for connecting to MCP servers\n- Server framework for building context providers\n- Transport layer with support for standard I/O communication\n- Complete type definitions for the MCP protocol\n- Utilities for logging and error handling\n\n## Installation\n\n```bash\ngo get github.com/XiaoConstantine/mcp-go\n```\n\n## Getting Started\n\n### Creating an MCP Client\n\n```go\nimport (\n    \"context\"\n    \"fmt\"\n    \"time\"\n    \n    \"github.com/XiaoConstantine/mcp-go/pkg/client\"\n    \"github.com/XiaoConstantine/mcp-go/pkg/logging\"\n    \"github.com/XiaoConstantine/mcp-go/pkg/transport\"\n)\n\nfunc main() {\n    // Create a logger\n    logger := logging.NewStdLogger(logging.InfoLevel)\n    \n    // Create a transport (using standard I/O in this example)\n    t := transport.NewStdioTransport(serverOut, serverIn, logger)\n    \n    // Create the client\n    mcpClient := client.NewClient(\n        t,\n        client.WithLogger(logger),\n        client.WithClientInfo(\"my-mcp-client\", \"1.0.0\"),\n    )\n    \n    // Set a timeout for initialization\n    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n    defer cancel()\n    \n    // Initialize the client\n    initResult, err := mcpClient.Initialize(ctx)\n    if err != nil {\n        fmt.Printf(\"Failed to initialize client: %v\\n\", err)\n        return\n    }\n    \n    fmt.Printf(\"Connected to MCP server: %s %s\\n\", \n        initResult.ServerInfo.Name, \n        initResult.ServerInfo.Version)\n    \n    // Use the client to access tools, resources, etc.\n    // ...\n    \n    // Shutdown when done\n    mcpClient.Shutdown()\n}\n```\n\n### Building an MCP Server\n\n```go\nimport (\n    \"fmt\"\n    \"time\"\n    \n    \"github.com/XiaoConstantine/mcp-go/pkg/model\"\n    \"github.com/XiaoConstantine/mcp-go/pkg/server\"\n    \"github.com/XiaoConstantine/mcp-go/pkg/server/core\"\n)\n\nfunc main() {\n    // Create server info\n    serverInfo := models.Implementation{\n        Name:    \"my-mcp-server\",\n        Version: \"1.0.0\",\n    }\n    \n    // Create the core MCP server\n    mcpServer := core.NewServer(serverInfo, \"2024-11-05\")\n    \n    // Register tools, resources, etc.\n    // ...\n    \n    // Configure the server\n    config := \u0026server.ServerConfig{\n        DefaultTimeout: 60 * time.Second,\n    }\n    \n    // Create a stdio server\n    stdioServer := server.NewServer(mcpServer, config)\n    \n    // Start the server\n    fmt.Println(\"Starting MCP server...\")\n    if err := stdioServer.Start(); err != nil {\n        fmt.Printf(\"Server error: %v\\n\", err)\n    }\n}\n```\n\n## Examples\n\nThe repository includes several example implementations:\n\n- **Git MCP Server**: Provides Git repository information as MCP resources and Git commands as tools\n- **Shell MCP Server**: Exposes shell commands as MCP tools\n- **Client Example**: Demonstrates how to connect to and interact with MCP servers\n\nSee the `example/` directory for complete examples.\n\n## API Documentation\n\nThe library is organized into several key packages:\n\n- `pkg/client`: Client implementation for connecting to MCP servers\n- `pkg/server`: Server implementation for creating MCP context providers\n- `pkg/transport`: Transport layer implementations (currently supporting stdio)\n- `pkg/model`: Type definitions for MCP protocol objects\n- `pkg/protocol`: Core protocol implementation (JSON-RPC, capabilities)\n- `pkg/errors`: Error definitions and handling\n- `pkg/logging`: Logging utilities\n- `pkg/handler`: Handler interfaces for server-side functionality\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoconstantine%2Fmcp-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiaoconstantine%2Fmcp-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoconstantine%2Fmcp-go/lists"}