模型上下文协议测试服务器

用于测试与robotmcp_server子模块集成的轻量级MCP服务器。

  • by stex2005
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 stex2005/test-mcp-server

使用说明

测试MCP服务器

用于测试子模块与robotmcp_server集成的最小模型上下文协议(MCP)服务器。

特性

  • 简单工具: ping 和 greet 用于测试MCP连接
  • 集成就绪:与robotmcp_server的子模块自动发现兼容
  • 最小依赖性:只需要 fastmcp>=2.11.3

项目结构

test-mcp-server/
├── pyproject.toml              # Package metadata
├── README.md                   # This file
├── .gitignore                  # Git ignore patterns
└── test_mcp/
    ├── __init__.py             # Package init
    ├── integration.py          # Entry point for robotmcp_server
    ├── tools/
    │   ├── __init__.py         # Tool registration hub
    │   └── tools.py            # Tool implementations
    ├── resources/
    │   └── __init__.py         # Resource registration
    └── prompts/
        └── __init__.py         # Prompt registration

工具

工具 参数 说明
ping 无 返回 {"message": "pong"} -测试连接性
greet name: str 退货 {"message": "Hello, {name}!"}

安装

通过robotmcp服务器CLI(推荐)

robotmcp-server add https://github.com/robotmcp/test-mcp-server.git

这会自动:

  • 将存储库克隆为git子模块
  • 从安装依赖项 pyproject.toml
  • 通过以下方式注册工具 test_mcp/integration.py

要验证安装:

robotmcp-server list        # Show installed modules
robotmcp-server list-tools  # Show available tools

要删除:

robotmcp-server remove test-mcp-server

独立安装

git clone https://github.com/robotmcp/test-mcp-server.git
cd test-mcp-server
pip install -e .

用法

使用robotmcp服务器

安装后,工具会自动注册。通过以下方式进行验证:

robotmcp-server list-tools

预期产量:

test_mcp:
  - ping: Simple ping tool to test connectivity.
  - greet: Greet a person by name.

独立

from fastmcp import FastMCP
from test_mcp.integration import register

mcp = FastMCP("test-server")
register(mcp)

集成模式

这 integration.py 模块提供 register(mcp, **kwargs) robotmcpserver子模块自动发现调用的函数:

# test_mcp/integration.py
def register(mcp: FastMCP, **kwargs) -> None:
    """Register all test MCP tools, resources, and prompts."""
    register_all_tools(mcp)
    register_all_resources(mcp)
    register_all_prompts(mcp)

此模式允许robotmcp_server动态加载和注册子模块中的组件。

发展

需求

  • Python>=3.10
  • fastmcp>=2.11.3

设置

# Clone the repository
git clone https://github.com/robotmcp/test-mcp-server.git
cd test-mcp-server

# Install in development mode
pip install -e .

添加新工具

  1. 添加工具功能 test_mcp/tools/tools.py
  2. 使用 @mcp.tool() 装饰师进行注册
  3. 测试用 robotmcp-server list-tools

使用robotmcp服务器进行测试

对于本地开发,您可以直接从本地路径添加:

# From the robotmcp_server directory
git submodule add ../path/to/test-mcp-server
robotmcp-server list-tools

许可证

版权所有(c)2025 Contoro。保留所有权利。