Back to MCP directory
publicPublicdnsLocal runtime

mcp-client-go

mcp-client-go是一个Golang客户端库,用于与模型上下文协议(MCP)服务交互,支持多种服务如Amap、Github等,提供统一的API接口。

article

README

🚀 MCP Client Go项目

本项目 MCP Client Go 提供了便捷的客户端工具,可用于相关应用的开发,支持多种初始化和调用方式,同时提供了丰富的示例供开发者参考。

🚀 快速开始

在使用 MCP Client Go 前,需完成必要工具的安装和环境配置。

📦 安装指南

安装 npx, uvx, docker 并将它们添加到环境变量中!

go get github.com/yincongcyincong/mcp-client-go

💻 使用示例

以下是一些使用示例的链接,你可以点击查看详细代码:

📚 详细文档

API概述

基础用法

初始化客户端

conf := clients.InitStdioMCPClient("npx-amap-maps-mcp-server", "npx", []string{
"AMAP_MAPS_API_KEY=" + AmapApiKey,
}, []string{
"-y",
"@amap/amap-maps-mcp-server",
}, mcp.InitializeRequest{}, nil, nil)
//
conf := clients.InitSSEMCPClient("npx-amap-maps-mcp-server", "http://127.0.0.1", nil, nil, nil)

注册MCP客户端

clients.RegisterMCPClient(context.Background(), []*param.MCPClientConf{conf})

获取MCP客户端

client, err := clients.GetMCPClient("npx-amap-maps-mcp-server")
//
client, err := clients.GetMCPClientByToolName("geo_location")

执行工具

client.ExecTools(ctx, "tool_name", map[string]interface{}{...})

📄 许可证

本项目采用 MIT License 开源协议。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client