M
metoro-io/mcp-golang
Write an MCP server in a few lines of Go
在 GitHub 查看 ↗链接已于 2026-11-12 核查 · HTTP 200 · 打开的是厂商自己的官网
我们没有从该仓库取到可核对的安装命令,也没有公开的远端端点。这两样都没有时,我们不出配置——编一条出来比不给更糟。 各客户端的接法 →
- 来源明细
- 收录自 abordage/awesome-mcp 榜单(我们从中收集的条目之一) · 条目类型:MCP 服务
- 收录与活跃
- 收录于 2026-11-05 · 最近见到 2026-11-14 · 共见到 10 次 · 被 10 个来源列出
- 评分构成
- 综合分 1,003 · 10 个来源 · mcp
常见问题(答案都来自我们的记录)
它适合谁 / 用来做什么?
我们把它归在这些标签下: MCP 服务。标签来自条目自身,不是我们强加的分类。
谁维护它、还在更新吗?
我们收录于 2026-11-05;最近见到 2026-11-14。这里没有"官方认证"或"质量评级"——我们只记录来源与时间。
# mcp-golang
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
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
go
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 := mcpgolang.NewServer(stdio.NewStdioServerTransport())
err := server.RegisterTool("hello", "Say hello to a person", func(arguments MyFunctionsArguments) (mcpgolang.ToolResponse, error) {
return mcpgolang.NewToolResponse(mcpgolang.NewTextContent(fmt.Sprintf("Hello, %server!", arguments.Submitter))), nil
})
if err != nil {
panic(err)
err = server.RegisterPrompt("promttest", "This is a test prompt", func(arguments Content) (mcpgolang.PromptResponse, error) {
return mcpgolang.NewPromptResponse("description", mcpgolang.NewPromptMessage(mcpgolang.NewTextContent(fmt.Sprintf("Hello, %server!", arguments.Title)), mcpgolang.RoleUser)), nil
})
if err != nil {
panic(err)
err = server.RegisterResource("test://resource", "resourcetest", "This is a test resource", "application/json", func() (mcpgolang.ResourceResponse, error) {
return mcpgolang.NewResourceResponse(mcpgolang.NewTextEmbeddedResource("test://resource", "This is a test resource", "application/json")), nil
})
err = server.Serve()
if err != nil {
panic(err)
0 {
log.Printf("Result: %s", response.Content[0].TextContent.Text)
### Using with Claude Desktop
Create a file in ~/Library/Application Support/Claude/claudedesktopconfig.json with the following contents:
json
"mcpServers": {
"golang-mcp-server": {
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
go
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 := mcpgolang.NewServer(stdio.NewStdioServerTransport())
err := server.RegisterTool("hello", "Say hello to a person", func(arguments MyFunctionsArguments) (mcpgolang.ToolResponse, error) {
return mcpgolang.NewToolResponse(mcpgolang.NewTextContent(fmt.Sprintf("Hello, %server!", arguments.Submitter))), nil
})
if err != nil {
panic(err)
err = server.RegisterPrompt("promttest", "This is a test prompt", func(arguments Content) (mcpgolang.PromptResponse, error) {
return mcpgolang.NewPromptResponse("description", mcpgolang.NewPromptMessage(mcpgolang.NewTextContent(fmt.Sprintf("Hello, %server!", arguments.Title)), mcpgolang.RoleUser)), nil
})
if err != nil {
panic(err)
err = server.RegisterResource("test://resource", "resourcetest", "This is a test resource", "application/json", func() (mcpgolang.ResourceResponse, error) {
return mcpgolang.NewResourceResponse(mcpgolang.NewTextEmbeddedResource("test://resource", "This is a test resource", "application/json")), nil
})
err = server.Serve()
if err != nil {
panic(err)
0 {
log.Printf("Result: %s", response.Content[0].TextContent.Text)
### Using with Claude Desktop
Create a file in ~/Library/Application Support/Claude/claudedesktopconfig.json with the following contents:
json
"mcpServers": {
"golang-mcp-server": {
收录徽章(可选)
想把收录标记放进 README 就复制这行,可选,不影响收录。
[](https://anclum.com/zh/s/metoro-io-mcp-golang/)
- 来源
- awesome · https://github.com/metoro-io/mcp-golang
- 按领域浏览
- MCP 服务
- 收录来源
- 10 个独立来源
- 收录于
- 今天
同类推荐
所属领域与标签
每个标签都能点进去看同类的全部条目。数字是当前库里的真实条数。