科学计算器服务

一个提供无状态科学计算操作的模型上下文协议(MCP)服务器,支持健康检查、表达式评估和列出支持的操作。

  • by AStheTECH
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Curious-Layer/cl-mcp-scientific-calculator

使用说明

科学计算器MCP服务器

提供无状态科学计算器操作的模型上下文协议(MCP)服务器。

认证

这是一个实用的MCP服务器。不需要身份验证输入,因为工具不访问外部租户数据。

特性

  • health_check:验证服务器准备就绪。
  • evaluate_expression:通过可选的角度模式和精度控制,安全地评估科学表达式。
  • list_supported_operations:返回可用的运算符、函数、常量和角度模式。

可用工具

health_check

检查服务器准备状态和基本连接。

论据:

  • 没有。

示例调用:

{
  "tool": "health_check",
  "arguments": {}
}

evaluate_expression

使用同种异体AST计算器安全地评估科学表达式。

论据:

  • expression (必填,字符串):要计算的科学表达式。
    • 支持操作员: +, -, *, /, //, %, **,一元 +x,一元 -x.
    • 支持常量: pi, e, tau.
    • 支持功能: abs, acos, asin, atan, ceil, cos, degrees, exp, factorial, floor, log, log10, radians, sin, sqrt, tan.
    • 最大长度:512个字符。
  • angle_mode (可选,字符串):三角角模式。
    • 允许值: radians, degrees.
    • 违约: radians.
  • precision (可选,整数):有限浮点数结果的小数精度。
    • 允许的范围:0到15。
    • 默认值:10。

示例调用:

{
  "tool": "evaluate_expression",
  "arguments": {
    "expression": "sin(pi / 2) + sqrt(16)",
    "angle_mode": "radians",
    "precision": 6
  }
}

list_supported_operations

返回服务器当前支持的运算符、函数、常量和角度模式。

论据:

  • 没有。

示例调用:

{
  "tool": "list_supported_operations",
  "arguments": {}
}

设置

pip install -r requirements.txt

运行服务器

# stdio
python server.py

# sse
python server.py --transport sse --host 127.0.0.1 --port 8001

# streamable-http
python server.py --transport streamable-http --host 127.0.0.1 --port 8001

工具调用示例

{
  "tool": "evaluate_expression",
  "arguments": {
    "expression": "sin(pi / 2) + sqrt(16)",
    "angle_mode": "radians",
    "precision": 6
  }
}
{
  "tool": "evaluate_expression",
  "arguments": {
    "expression": "sin(30)",
    "angle_mode": "degrees"
  }
}

项目结构

cl-mcp-scientific-calculator/
|-- server.py
|-- requirements.txt
|-- README.md
`-- scientific_calculator_mcp/
    |-- __init__.py
    |-- cli.py
    |-- config.py
    `-- tools.py