{"id":26492573,"url":"https://github.com/metoro-io/mcp-golang","last_synced_at":"2025-05-15T17:06:40.062Z","repository":{"id":267491430,"uuid":"900003919","full_name":"metoro-io/mcp-golang","owner":"metoro-io","description":"Write Model Context Protocol servers in few lines of go code. Docs at https://mcpgolang.com","archived":false,"fork":false,"pushed_at":"2025-05-07T12:45:49.000Z","size":1027,"stargazers_count":836,"open_issues_count":34,"forks_count":82,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-15T17:06:33.816Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://mcpgolang.com","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/metoro-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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-12-07T15:52:56.000Z","updated_at":"2025-05-15T08:57:31.000Z","dependencies_parsed_at":"2025-05-08T05:00:48.971Z","dependency_job_id":null,"html_url":"https://github.com/metoro-io/mcp-golang","commit_stats":null,"previous_names":["metoro-io/mcp-golang"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metoro-io%2Fmcp-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metoro-io%2Fmcp-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metoro-io%2Fmcp-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metoro-io%2Fmcp-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metoro-io","download_url":"https://codeload.github.com/metoro-io/mcp-golang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384988,"owners_count":22062422,"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":[],"created_at":"2025-03-20T09:01:13.396Z","updated_at":"2025-05-15T17:06:35.052Z","avatar_url":"https://github.com/metoro-io.png","language":"Go","funding_links":[],"categories":["Development Tools MCP Servers","Go","📚 Projects (1974 total)","[Model Context Protocol](https://modelcontextprotocol.io/introduction)","Frameworks","⚙️ DevOps","MCP SDK","SDKs","框架","Table of Contents","MCP Servers \u0026 Protocol"],"sub_categories":["MCP Servers","Multi-modal","🛠️ \u003ca name=\"other-tools-and-integrations\"\u003e\u003c/a\u003eOther Tools and Integrations","🛠️ Other Tools and Integrations","Go","Developer Tools"],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"./resources/mcp-golang-logo.webp\" height=\"300\" alt=\"Statusphere logo\"\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\u003cdiv align=\"center\"\u003e\n\n![GitHub stars](https://img.shields.io/github/stars/metoro-io/mcp-golang?style=social)\n![GitHub forks](https://img.shields.io/github/forks/metoro-io/mcp-golang?style=social)\n![GitHub issues](https://img.shields.io/github/issues/metoro-io/mcp-golang)\n![GitHub pull requests](https://img.shields.io/github/issues-pr/metoro-io/mcp-golang)\n![GitHub license](https://img.shields.io/github/license/metoro-io/mcp-golang)\n![GitHub contributors](https://img.shields.io/github/contributors/metoro-io/mcp-golang)\n![GitHub last commit](https://img.shields.io/github/last-commit/metoro-io/mcp-golang)\n[![GoDoc](https://pkg.go.dev/badge/github.com/metoro-io/mcp-golang.svg)](https://pkg.go.dev/github.com/metoro-io/mcp-golang)\n[![Go Report Card](https://goreportcard.com/badge/github.com/metoro-io/mcp-golang)](https://goreportcard.com/report/github.com/metoro-io/mcp-golang)\n![Tests](https://github.com/metoro-io/mcp-golang/actions/workflows/go-test.yml/badge.svg)\n\n\n\n\n\u003c/div\u003e\n\n# mcp-golang \n\nmcp-golang is an unofficial implementation of the [Model Context Protocol](https://modelcontextprotocol.io/) in Go.\n\nWrite MCP servers and clients in golang with a few lines of code.\n\nDocs at [https://mcpgolang.com](https://mcpgolang.com)\n\n## Highlights\n- 🛡️**Type safety** - Define your tool arguments as native go structs, have mcp-golang handle the rest. Automatic schema generation, deserialization, error handling etc.\n- 🚛 **Custom transports** - Use the built-in transports (stdio for full feature support, HTTP for stateless communication) or write your own.\n- ⚡ **Low boilerplate** - mcp-golang generates all the MCP endpoints for you apart from your tools, prompts and resources.\n- 🧩 **Modular** - The library is split into three components: transport, protocol and server/client. Use them all or take what you need.\n- 🔄 **Bi-directional** - Full support for both server and client implementations through stdio transport.\n\n## Example Usage\n\nInstall with `go get github.com/metoro-io/mcp-golang`\n\n### Server Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/metoro-io/mcp-golang\"\n\t\"github.com/metoro-io/mcp-golang/transport/stdio\"\n)\n\n// Tool arguments are just structs, annotated with jsonschema tags\n// More at https://mcpgolang.com/tools#schema-generation\ntype Content struct {\n\tTitle       string  `json:\"title\" jsonschema:\"required,description=The title to submit\"`\n\tDescription *string `json:\"description\" jsonschema:\"description=The description to submit\"`\n}\ntype MyFunctionsArguments struct {\n\tSubmitter string  `json:\"submitter\" jsonschema:\"required,description=The name of the thing calling this tool (openai, google, claude, etc)\"`\n\tContent   Content `json:\"content\" jsonschema:\"required,description=The content of the message\"`\n}\n\nfunc main() {\n\tdone := make(chan struct{})\n\n\tserver := mcp_golang.NewServer(stdio.NewStdioServerTransport())\n\terr := server.RegisterTool(\"hello\", \"Say hello to a person\", func(arguments MyFunctionsArguments) (*mcp_golang.ToolResponse, error) {\n\t\treturn mcp_golang.NewToolResponse(mcp_golang.NewTextContent(fmt.Sprintf(\"Hello, %server!\", arguments.Submitter))), nil\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = server.RegisterPrompt(\"promt_test\", \"This is a test prompt\", func(arguments Content) (*mcp_golang.PromptResponse, error) {\n\t\treturn mcp_golang.NewPromptResponse(\"description\", mcp_golang.NewPromptMessage(mcp_golang.NewTextContent(fmt.Sprintf(\"Hello, %server!\", arguments.Title)), mcp_golang.RoleUser)), nil\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = server.RegisterResource(\"test://resource\", \"resource_test\", \"This is a test resource\", \"application/json\", func() (*mcp_golang.ResourceResponse, error) {\n\t\treturn mcp_golang.NewResourceResponse(mcp_golang.NewTextEmbeddedResource(\"test://resource\", \"This is a test resource\", \"application/json\")), nil\n\t})\n\n\terr = server.Serve()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t\u003c-done\n}\n```\n\n### HTTP Server Example\n\nYou can also create an HTTP-based server using either the standard HTTP transport or Gin framework:\n\n```go\n// Standard HTTP\ntransport := http.NewHTTPTransport(\"/mcp\")\ntransport.WithAddr(\":8080\")\nserver := mcp_golang.NewServer(transport)\n\n// Or with Gin framework\ntransport := http.NewGinTransport()\nrouter := gin.Default()\nrouter.POST(\"/mcp\", transport.Handler())\nserver := mcp_golang.NewServer(transport)\n```\n\nNote: HTTP transports are stateless and don't support bidirectional features like notifications. Use stdio transport if you need those features.\n\n### Client Example\n\nCheckout the [examples/client](./examples/client) directory for a more complete example.\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"log\"\n    mcp \"github.com/metoro-io/mcp-golang\"\n    \"github.com/metoro-io/mcp-golang/transport/stdio\"\n)\n\n// Define type-safe arguments\ntype CalculateArgs struct {\n    Operation string `json:\"operation\"`\n    A         int    `json:\"a\"`\n    B         int    `json:\"b\"`\n}\n\nfunc main() {\n   cmd := exec.Command(\"go\", \"run\", \"./server/main.go\")\n   stdin, err := cmd.StdinPipe()\n   if err != nil {\n    log.Fatalf(\"Failed to get stdin pipe: %v\", err)\n   }\n   stdout, err := cmd.StdoutPipe()\n   if err != nil {\n    log.Fatalf(\"Failed to get stdout pipe: %v\", err)\n   }\n\n   if err := cmd.Start(); err != nil {\n    log.Fatalf(\"Failed to start server: %v\", err)\n   }\n   defer cmd.Process.Kill()\n    // Create and initialize client\n    transport := stdio.NewStdioServerTransportWithIO(stdout, stdin)\n    client := mcp.NewClient(transport)\n    \n    if _, err := client.Initialize(context.Background()); err != nil {\n        log.Fatalf(\"Failed to initialize: %v\", err)\n    }\n\n    // Call a tool with typed arguments\n    args := CalculateArgs{\n        Operation: \"add\",\n        A:         10,\n        B:         5,\n    }\n    \n    response, err := client.CallTool(context.Background(), \"calculate\", args)\n    if err != nil {\n        log.Fatalf(\"Failed to call tool: %v\", err)\n    }\n    \n    if response != nil \u0026\u0026 len(response.Content) \u003e 0 {\n        log.Printf(\"Result: %s\", response.Content[0].TextContent.Text)\n    }\n}\n```\n\n### Using with Claude Desktop\n\nCreate a file in ~/Library/Application Support/Claude/claude_desktop_config.json with the following contents:\n\n```json\n{\n\"mcpServers\": {\n  \"golang-mcp-server\": {\n      \"command\": \"\u003cyour path to golang MCP server go executable\u003e\",\n      \"args\": [],\n      \"env\": {}\n    }\n  }\n}\n``` \n\n## Contributions\n\nContributions are more than welcome! Please check out [our contribution guidelines](./CONTRIBUTING.md).\n\n## Discord\n\nGot any suggestions, have a question on the api or usage? Ask on the [discord server](https://discord.gg/33saRwE3pT). \nA maintainer will be happy to help you out.\n\n## Examples\n\nSome more extensive examples using the library found here:\n\n- \u003cimg height=\"12\" width=\"12\" src=\"https://metoro.io/static/images/logos/Metoro.svg\" /\u003e **[Metoro](https://github.com/metoro-io/metoro-mcp-server)** - Query and interact with kubernetes environments monitored by Metoro\n\nOpen a PR to add your own projects!\n\n## Server Feature Implementation\n\n### Tools\n- [x] Tool Calls\n- [x] Native go structs as arguments\n- [x] Programatically generated tool list endpoint\n- [x] Change notifications\n- [x] Pagination\n\n### Prompts\n- [x] Prompt Calls\n- [x] Programatically generated prompt list endpoint\n- [x] Change notifications\n- [x] Pagination\n\n### Resources\n- [x] Resource Calls\n- [x] Programatically generated resource list endpoint\n- [x] Change notifications\n- [x] Pagination\n\n### Transports\n- [x] Stdio - Full support for all features including bidirectional communication\n- [x] HTTP - Stateless transport for simple request-response scenarios (no notifications support)\n- [x] Gin - HTTP transport with Gin framework integration (stateless, no notifications support)\n- [x] SSE\n- [x] Custom transport support\n- [ ] HTTPS with custom auth support - in progress. Not currently part of the spec but we'll be adding experimental support for it.\n\n### Client\n- [x] Call tools\n- [x] Call prompts\n- [x] Call resources\n- [x] List tools\n- [x] List prompts\n- [x] List resources\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetoro-io%2Fmcp-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetoro-io%2Fmcp-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetoro-io%2Fmcp-golang/lists"}