loading…
Search for a command to run...
loading…
A basic MCP server built with the FastMCP framework that provides fundamental mathematical operations like addition, subtraction, multiplication, and division.
A basic MCP server built with the FastMCP framework that provides fundamental mathematical operations like addition, subtraction, multiplication, and division. It serves as a demonstration for integrating math-based tools into MCP-compatible environments like Cursor IDE.
一个使用 FastMCP 框架构建的 MCP 服务器,提供基本的数学运算功能。
add) - 计算两个整数的和subtract) - 计算两个整数的差multiply) - 计算两个整数的积divide) - 计算两个整数的商如果你还没有安装 uv,请先安装:
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# 或者使用 pip
pip install uv
克隆项目:
git clone <repository-url>
cd test_fast_mcp
安装依赖:
uv sync
激活虚拟环境:
uv shell
运行服务器:
uv run python main.py
启动开发服务器:
uv run dev
运行测试:
uv run test
代码格式化:
uv run format
代码检查:
uv run lint
导入排序:
uv run sort
# 添加生产依赖
uv add package-name
# 添加开发依赖
uv add --dev package-name
uv lock --upgrade

将以下配置添加到你的 Cursor MCP 配置文件 (~/.cursor/mcp.json) 中:
{
"mcpServers": {
"test-fast-mcp": {
"command": "uv",
"args": ["run", "python", "/Users/guosong/Desktop/Sina/Code/test_fast_mcp/main.py"],
"env": {
"PYTHONPATH": ".",
"TRANSPORT": "stdio"
}
}
}
}
重要配置说明:
main.py 文件"TRANSPORT": "stdio" 环境变量PYTHONPATH 设置正确test_fast_mcp/
├── main.py # 主服务器文件,包含所有工具定义
├── pyproject.toml # 项目配置和依赖管理
├── uv.lock # 依赖锁定文件
├── mcp.json # Cursor MCP 配置示例
├── test_tools.py # 工具测试文件
└── README.md # 项目说明文档
运行测试脚本来验证数学函数:
python test_tools.py
预期输出:
Testing math functions:
add(5, 4) = 9
subtract(10, 3) = 7
multiply(6, 7) = 42
divide(15, 3) = 5.0
"No tools or prompts" 错误
TRANSPORT: "stdio" 环境变量构建错误
uv sync 重新安装依赖pyproject.toml 配置工具无法调用
mcp_test-fast-mcp_<tool_name>检查服务器状态:
ps aux | grep "python main.py"
查看服务器日志:
uv run python main.py
测试工具功能:
python -c "from main import add; print(add(5, 4))"
这个项目使用 FastMCP 框架,它简化了 MCP 服务器的创建过程。
main.py 中定义新函数@mcp.tool 装饰器示例:
@mcp.tool
def new_tool(param: str) -> str:
"""Tool description.
Args:
param: Parameter description
Returns:
Return value description
"""
return f"Processed: {param}"
MIT License
欢迎提交 Issue 和 Pull Request!
如果遇到问题,请:
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"test-fastmcp": {
"command": "npx",
"args": []
}
}
}PRs, issues, code search, CI status
Database, auth and storage
Reference / test server with prompts, resources, and tools.
Secure file operations with configurable access controls.