使用说明
FastMCP计算器服务器
一种模型上下文协议(MCP)服务器,提供具有身份验证选项的计算器功能。
快速开始
1.安装依赖项
pip install -r requirements.txt
2.选择身份验证模式
无身份验证(端口8000)
python calculator_server.py
JWT身份验证(端口8001)
python calculator_server_auth.py
# Copy the bearer token from output
谷歌OAuth(端口8002)
# Setup: Get credentials from https://console.cloud.google.com/
# Create .env file with GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET
python calculator_server_google_oauth.py
计算器工具
add(a, b)-加两个数字subtract(a, b)-减去数字multiply(a, b)-将数字相乘divide(a, b)-分割数字power(base, exponent)-提升到权力modulo(a, b)-获取剩余部分square_root(n)-计算平方根evaluate_expression(expr)-评估数学表达式calculate_percentage(value, pct)-计算百分比average(numbers)-计算平均值
Google OAuth设置
- 首选https://console.cloud.google.com/
- 创建OAuth 2.0客户端ID
- 添加重定向URI:
http://localhost:8000/auth/callback - 将凭据复制到
.env:
GOOGLE_CLIENT_ID=your-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-secret
SERVER_BASE_URL=http://localhost:8000
Claude桌面设置
编辑您的Claude配置文件:
视窗: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"calculator": {
"command": "python",
"args": ["path/to/calculator_server.py"]
}
}
}
生产
- 使用HTTPS(Google OAuth需要)
- 安全地存储凭据
- 启用速率限制
- 设置监控
