计算器服务器

FastMCP Calculator Server 是一个提供计算器功能的模型上下文协议(MCP)服务器,支持多种认证方式,适用于需要远程计算服务的开发场景。

  • by Muhammad-Moin
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Muhammad-Moin/MCP_SERVER

使用说明

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设置

  1. 首选https://console.cloud.google.com/
  2. 创建OAuth 2.0客户端ID
  3. 添加重定向URI: http://localhost:8000/auth/callback
  4. 将凭据复制到 .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需要)
  • 安全地存储凭据
  • 启用速率限制
  • 设置监控

资源