MCP Host
A host for running multiple MCP servers, such as a calculator and an IP location query server, configured via a JSON file.
MCP Host [第三课]
架构图
配置 MCP Servers
config.json
{
"mcpServers": {
"calculator": {
"type": "stdio",
"command": "bin/calculator-server",
"args": []
},
"ip-location-query": {
"type": "http",
"command": "http://localhost:8080/mcp",
"args": []
}
}
}
运行 MCP Servers
calculator
go build -o bin/calculator-server tools/calculator/main.go
ip-location-query
go run tools/ip_location_query/main.go
运行 MCP Host
可见两个 MCP Servers 都被正常调用到了
go run main.go (in another terminal)
Initializing client...
[calculator] Connected to server: calculator-server 1.0.0
Initializing client...
[ip-location-query] Connected to server: ip-location-server 1.0.0
Type your queries or 'quit' to exit.
User: 查看183.193.158.228所在 地以及计算5+6等于几
Assistant: IP地址 **183.193.158.228** 位于中国上海市,具体信息如下:
- **国家/地区**:中国 (CN)
- **城市**:上海
- **经纬度**:北纬31.2222°,东经121.4581°
- **运营商**:中国移动通信集团上海有限公司 (AS24400)
计算结果:
**5 + 6 = 11**
User: 你调用了哪些工具
Assistant: 为了回答你的问题,我调用了以下两个工具:
1. **IP 地址查询工具**:用于查询 `183.193.158.228` 的地理位置信息。
2. **计算工具**:用于计算 `5 + 6` 的结果。
如果你有其他问题,随时告诉我!
User: 告诉我工具名
Assistant: 我调用了以下两个工具来完成你的请求:
1. **`ip_location_query`**(IP 地址查询工具):用于查询 `183.193.158.228` 的地理位置信息。
2. **`calculate`**(计算工具):用于执行加法运算 `5 + 6`。
如果你需要进一步了解这些工具的功能或使用方法,可以随时告诉我!
参考
Related Servers
Scout Monitoring MCP
sponsorPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
sponsorAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
MCP ZepAi Server
A server for Zep, a long-term memory store for AI applications, requiring a ZEP_API_KEY for access.
Xcode
Tools for Xcode project management, building, testing, archiving, code signing, and iOS development utilities.
FastMCP
A fast, Pythonic framework for building MCP servers and clients.
third-eye-mcp
Privacy-first screen capture MCP server for AI coding agents. Let Claude, Cursor, or any MCP-compatible AI see your screen with full control.
Shipyard
The Shipyard CLI provides an MCP server for agents to manage Shipyard environments directly: by pulling logs, comparing branches, running tests, and stopping/starting environments..
Image Generation MCP Server
An MCP server for generating images using the Replicate API and the Flux model.
Codelogic
Utilize Codelogic's rich software dependency data in your AI programming assistant.
stdout-mcp-server
Captures and manages stdout logs from multiple processes via a named pipe system for real-time debugging and analysis.
gurddy mcp
his repository contains a fully functional MCP (Model Context Protocol) server, providing solutions for Constraint Satisfaction Problems (CSP) and Linear Programming (LP). It is based on the gurddy package and supports solving a variety of classic problems.
MCP Neurolora
An intelligent server for code analysis, collection, and documentation generation using the OpenAI API.