-
Notifications
You must be signed in to change notification settings - Fork 0
MCP Hub Guide
GIS Data Agent v14.5 — 基于 Google ADK 的 AI 地理空间平台 仓库:https://github.com/zhouning/gisdataagent
Model Context Protocol (MCP) 是一套标准化协议,用于将 AI 代理与外部工具和服务连接。通过 MCP,GIS Data Agent 可以动态接入第三方工具服务器,扩展代理可用的工具集,而无需修改代码或重启应用。
MCP 的核心价值:
- 标准化接口:统一的工具发现和调用协议
- 动态扩展:运行时添加/移除工具服务器
- 生态互通:接入任何符合 MCP 标准的工具提供者
- 打开数据面板 → MCP Hub(MCP 中心) 标签页
- 点击 "Add Server"(添加服务器)
- 配置服务器信息:
| 字段 | 说明 | 示例 |
|---|---|---|
| 名称 | 服务器显示名称 | weather-tools |
| 传输协议 | 通信方式(三选一) |
stdio / sse / streamable-http
|
| 命令/URL | 启动命令或服务地址 | 见下方说明 |
通过子进程启动 MCP 服务器,使用 stdin/stdout 通信。适合本地工具。
命令: python weather_server.py
参数: --port 8080
通过 HTTP SSE 连接远程 MCP 服务器。适合长连接场景。
URL: https://mcp.example.com/sse
通过可流式传输的 HTTP 连接。适合现代 HTTP/2 环境。
URL: https://mcp.example.com/stream
除了通过 UI 添加,还可以在 mcp_servers.yaml 中声明持久化的服务器配置:
servers:
- name: weather-tools
transport: stdio
command: python
args:
- /path/to/weather_server.py
env:
API_KEY: your-api-key
- name: geocoding-service
transport: sse
url: https://geocoding-mcp.example.com/sse
- name: data-converter
transport: streamable-http
url: https://converter-mcp.example.com/streamYAML 中定义的服务器在应用启动时自动加载。
MCP Hub 连接到服务器后,自动执行 工具发现:
- 向 MCP 服务器发送
tools/list请求 - 服务器返回可用工具列表(名称、描述、参数定义)
- 工具自动注册到代理的可用工具集中
发现的工具会显示在 MCP Hub 标签页中,包括:
- 工具名称和描述
- 输入参数定义
- 所属服务器信息
- 连接状态
MCP 工具一旦被发现,即与内置工具并列,代理可以无缝调用:
使用天气工具查询北京今天的天气
Use the weather tool to check Beijing's weather today
将这个文件转换为GeoJSON格式
Convert this file to GeoJSON format
代理会根据用户请求自动选择最合适的工具——无需指定工具来源是内置还是 MCP。
MCP Hub 支持 热重载——在不重启应用的情况下动态管理服务器:
- 通过 UI 添加 → 即时生效
- 修改
mcp_servers.yaml→ 触发重载
- 通过 UI 删除 → 断开连接,移除工具
- 不影响其他已连接的服务器
- 服务器断线后可一键重连
- 重连后自动重新发现工具
MCP Hub 提供 10 个 REST API 端点用于程序化管理:
| 端点 | 方法 | 功能 |
|---|---|---|
/api/mcp/servers |
GET | 列出所有 MCP 服务器 |
/api/mcp/servers |
POST | 添加新服务器 |
/api/mcp/servers/{id} |
PUT | 更新服务器配置 |
/api/mcp/servers/{id} |
DELETE | 删除服务器 |
/api/mcp/servers/{id}/tools |
GET | 列出服务器的工具 |
/api/mcp/servers/{id}/connect |
POST | 连接服务器 |
/api/mcp/servers/{id}/disconnect |
POST | 断开服务器 |
/api/mcp/servers/{id}/status |
GET | 获取连接状态 |
/api/mcp/tools |
GET | 列出所有已发现的工具 |
/api/mcp/reload |
POST | 重载 YAML 配置 |
GIS Data Agent v14.5 — AI geospatial platform on Google ADK Repository: https://github.com/zhouning/gisdataagent
Model Context Protocol (MCP) is a standardized protocol for connecting AI agents to external tools and services. Through MCP, GIS Data Agent can dynamically connect to third-party tool servers, extending the agent's available toolset without modifying code or restarting the application.
Core values of MCP:
- Standardized interface: Unified tool discovery and invocation protocol
- Dynamic extension: Add/remove tool servers at runtime
- Ecosystem interoperability: Connect to any MCP-compliant tool provider
- Open the Data Panel → MCP Hub tab
- Click "Add Server"
- Configure server information:
| Field | Description | Example |
|---|---|---|
| Name | Server display name | weather-tools |
| Transport | Communication method (choose one) |
stdio / sse / streamable-http
|
| Command/URL | Launch command or service address | See details below |
Launch an MCP server as a subprocess, communicating via stdin/stdout. Best for local tools.
Command: python weather_server.py
Args: --port 8080
Connect to a remote MCP server via HTTP SSE. Best for long-lived connections.
URL: https://mcp.example.com/sse
Connect via streamable HTTP transport. Best for modern HTTP/2 environments.
URL: https://mcp.example.com/stream
In addition to adding servers via UI, you can declare persistent server configurations in mcp_servers.yaml:
servers:
- name: weather-tools
transport: stdio
command: python
args:
- /path/to/weather_server.py
env:
API_KEY: your-api-key
- name: geocoding-service
transport: sse
url: https://geocoding-mcp.example.com/sse
- name: data-converter
transport: streamable-http
url: https://converter-mcp.example.com/streamServers defined in YAML are automatically loaded at application startup.
After connecting to a server, MCP Hub automatically performs tool discovery:
- Sends a
tools/listrequest to the MCP server - Server returns available tools (names, descriptions, parameter definitions)
- Tools are automatically registered into the agent's available toolset
Discovered tools are displayed in the MCP Hub tab, including:
- Tool name and description
- Input parameter definitions
- Parent server information
- Connection status
Once discovered, MCP tools appear alongside built-in tools, and agents can call them seamlessly:
使用天气工具查询北京今天的天气
Use the weather tool to check Beijing's weather today
将这个文件转换为GeoJSON格式
Convert this file to GeoJSON format
The agent automatically selects the most appropriate tool based on the user's request — no need to specify whether the tool is built-in or from MCP.
MCP Hub supports hot reload — dynamically managing servers without restarting the application:
- Add via UI → takes effect immediately
- Modify
mcp_servers.yaml→ triggers reload
- Delete via UI → disconnects and removes tools
- Does not affect other connected servers
- One-click reconnect after server disconnection
- Tools are automatically re-discovered after reconnection
MCP Hub provides 10 REST API endpoints for programmatic management:
| Endpoint | Method | Function |
|---|---|---|
/api/mcp/servers |
GET | List all MCP servers |
/api/mcp/servers |
POST | Add a new server |
/api/mcp/servers/{id} |
PUT | Update server configuration |
/api/mcp/servers/{id} |
DELETE | Delete a server |
/api/mcp/servers/{id}/tools |
GET | List a server's tools |
/api/mcp/servers/{id}/connect |
POST | Connect to a server |
/api/mcp/servers/{id}/disconnect |
POST | Disconnect from a server |
/api/mcp/servers/{id}/status |
GET | Get connection status |
/api/mcp/tools |
GET | List all discovered tools |
/api/mcp/reload |
POST | Reload YAML configuration |
GIS Data Agent v14.5 · Built on Google ADK · GitHub · Report Issue
快速开始 Getting Started
核心概念 Core Concepts
使用指南 User Guide
架构与运维 Architecture & Ops
参考 Reference