A type‑safe, intuitive Go SDK for MCP server development 🤔 What is go‑mcp? • ✨ Features • 🏁 Quick Start • 🔍 Examples • ✅ Supported Features • 🤝 Contributing 🤔 What is go‑mcp? go‑mcp is a Go SDK for building MCP (Model Context Protocol) servers with ease and confidence. It provides a type‑safe, intuitive interface that makes server development a breeze. ✨ Features 🔒 Type‑Safe – Code generation ensures your tools and prompt parameters are statically typed, so errors are caught at compile time instead of at runtime. – Code generation ensures your tools and prompt parameters are statically typed, so errors are caught at compile time instead of at runtime. 🧩 Simple & Intuitive API – A natural, idiomatic Go interface that lets you build servers quickly without a steep learning curve. – A natural, idiomatic Go interface that lets you build servers quickly without a steep learning curve. 🔌 Developer‑Friendly – Designed with API ergonomics in mind, making it approachable. 🏁 Quick Start Creating an MCP server with go‑mcp is straightforward! Directory structure Below is an example directory structure for a temperature‑conversion MCP server: . ├── cmd │ ├── mcpgen │ │ └── main.go │ └── temperature │ └── main.go ├── mcp.gen.go └── temperature.go 1. Define the MCP server First, create cmd/mcpgen/main.go for code generation. Running this file will automatically generate the necessary code. package main import ( "log" "os" "path/filepath" "github.com/ktr0731/go-mcp/codegen" ) func main () { // Create output directory outDir := "." if err := os . MkdirAll ( outDir , 0o755 ); err != nil { log . Fatalf ( "failed to create output directory: %v" , err ) } // Create output file f , err := os . Create ( filepath . Join ( outDir , "mcp.gen.go" )) if err != nil { log . Fatalf ( "failed to create file: %v" , err ) } defer f . Close () // Server definition def := & codegen. ServerDefinition { Capabilities : codegen. ServerCapabilities { Tools : & codegen. ToolCapability {}, Logging : & codege...
First seen: 2025-04-17 13:11
Last seen: 2025-04-17 18:12