Calculator MCP
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Calculator MCPcalculate the square root of 144"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Calculator MCP
一个简单而强大的计算器 MCP 服务器,通过 Model Context Protocol 提供数学运算功能。
功能特性
➕ 基本运算: 加、减、乘、除、幂、取模
🔢 高级数学: 平方根、阶乘、对数
📐 三角函数: sin、cos、tan
🚀 零依赖: 仅使用 Python 标准库
📡 stdio 模式: 兼容 supergateway 和 Claude Desktop
Related MCP server: Math MCP Server
快速开始
使用 uvx (推荐)
uvx bachai-calculator-mcp使用 pip 安装
pip install bachai-calculator-mcp
bachai-calculator-mcp直接运行
python main.pyMCP 工具列表
1. calculate
基本数学运算
参数:
operation: 运算类型(add, subtract, multiply, divide, power, modulo)a: 第一个数字b: 第二个数字
示例:
{
"name": "calculate",
"arguments": {
"operation": "add",
"a": 10,
"b": 5
}
}返回: 10 + 5 = 15
2. sqrt
计算平方根
参数:
number: 要计算平方根的数字
示例:
{
"name": "sqrt",
"arguments": {
"number": 16
}
}返回: √16 = 4.0
3. factorial
计算阶乘
参数:
number: 要计算阶乘的整数
示例:
{
"name": "factorial",
"arguments": {
"number": 5
}
}返回: 5! = 120
4. trigonometry
三角函数计算
参数:
function: 三角函数类型(sin, cos, tan)angle: 角度(度数)
示例:
{
"name": "trigonometry",
"arguments": {
"function": "sin",
"angle": 30
}
}返回: sin(30°) = 0.5
5. logarithm
对数计算
参数:
number: 真数base: 底数(可选,默认为 e)
示例:
{
"name": "logarithm",
"arguments": {
"number": 100,
"base": 10
}
}返回: log_10(100) = 2.0
配置
Supergateway 配置
{
"mcpServers": {
"calculator": {
"outputTransport": "sse",
"port": 8000,
"stdio": "uvx bachai-calculator-mcp",
"ssePath": "/sse",
"messagePath": "/message"
}
}
}Claude Desktop 配置
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"calculator": {
"command": "uvx",
"args": ["bachai-calculator-mcp"]
}
}
}macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"calculator": {
"command": "uvx",
"args": ["bachai-calculator-mcp"]
}
}
}使用示例
在 Claude Desktop 中使用
安装并配置后,您可以向 Claude 发送类似的请求:
"请帮我计算 123 + 456"
"计算 25 的平方根"
"5 的阶乘是多少?"
"计算 sin(45度)"
"计算以 2 为底 8 的对数"
手动测试
# 测试初始化
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | uvx bachai-calculator-mcp
# 测试加法
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"calculate","arguments":{"operation":"add","a":10,"b":5}}}' | uvx bachai-calculator-mcp技术特点
零依赖: 仅使用 Python 标准库(math, operator, json)
轻量级: 代码简洁,启动快速
可靠: 完整的错误处理和边界检查
兼容性: 支持 Python 3.7+
标准化: 完全遵循 MCP 协议规范
错误处理
服务器包含完善的错误处理:
✅ 除零检查
✅ 负数平方根检查
✅ 阶乘范围验证
✅ 对数参数验证
✅ JSON 解析错误处理
开发
# 克隆仓库
git clone https://github.com/BACH-AI-Tools/calculator-mcp.git
cd calculator-mcp
# 本地测试
python main.py
# 构建包
python -m build
# 发布到 PyPI
python -m twine upload dist/*许可证
MIT License - 详见 LICENSE 文件
贡献
欢迎提交 Issue 和 Pull Request!
更新日志
v1.0.0 (2024-11-07)
🎉 初始发布
✨ 支持基本数学运算
✨ 支持高级数学函数
✨ 支持三角函数
✨ 零依赖实现
Available Tools
5 toolscalculateC
执行基本数学运算(加、减、乘、除、幂、取模)
| Name | Required | Description | Default |
|---|---|---|---|
| operation | Yes | 运算类型 | |
| a | Yes | 第一个数字 | |
| b | Yes | 第二个数字 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states what operations are performed without mentioning error handling (e.g., division by zero), input constraints (e.g., numeric types), output format, or performance characteristics. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise and front-loaded: a single sentence in Chinese that directly states the tool's function. There's no wasted verbiage or unnecessary elaboration, making it efficient for quick understanding.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (basic math operations with 3 parameters) and lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects like error handling, input validation, or result formatting. While the schema covers parameters well, the overall context for safe and effective use is insufficient.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, with clear descriptions for all parameters: 'operation' (运算类型), 'a' (第一个数字), and 'b' (第二个数字). The description adds minimal value beyond the schema by listing the operation types, but it doesn't explain parameter interactions or provide examples. With high schema coverage, the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: '执行基本数学运算(加、减、乘、除、幂、取模)' which translates to 'Perform basic mathematical operations (addition, subtraction, multiplication, division, power, modulo).' This specifies the verb ('perform') and resource ('basic mathematical operations') with a list of specific operations. However, it doesn't explicitly differentiate from sibling tools like factorial or logarithm, which handle more specialized mathematical functions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like factorial, logarithm, sqrt, or trigonometry, nor does it specify contexts where basic operations are preferred over more specialized ones. There's no information about prerequisites, limitations, or common use cases.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
factorialC
计算阶乘
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | 要计算阶乘的整数 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the operation without mentioning potential issues like handling negative numbers, large inputs causing overflow, or performance characteristics. For a mathematical tool with zero annotation coverage, this is a significant gap in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise with a single phrase '计算阶乘', which is front-loaded and wastes no words. It directly states the tool's function without unnecessary elaboration, making it efficient for quick understanding.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the lack of annotations and output schema, the description is incomplete. It doesn't explain return values, error handling, or behavioral traits, which are crucial for a mathematical function. The description alone is inadequate for an agent to use the tool effectively without additional context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with the parameter 'number' documented as '要计算阶乘的整数' (integer to calculate factorial). The description doesn't add any meaning beyond what the schema provides, such as valid ranges or edge cases. Baseline 3 is appropriate since the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description '计算阶乘' (calculates factorial) states the mathematical operation but is vague about scope and context. It doesn't specify what type of factorial (e.g., integer, for non-negative numbers) or distinguish it from sibling tools like 'calculate' which might perform similar operations. The purpose is clear at a basic level but lacks specificity.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives like 'calculate' or other mathematical functions. The description doesn't mention prerequisites, constraints (e.g., input range), or typical use cases, leaving the agent to infer usage from the tool name alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
logarithmC
对数计算
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | 真数 | |
| base | No | 底数(可选,默认为 e) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. '对数计算' only states the operation without explaining behavioral traits such as error handling (e.g., for negative numbers or base=1), computational limits, or output format. This is inadequate for a tool with no annotation coverage.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single phrase '对数计算', which is extremely concise and front-loaded. However, it's under-specified rather than efficiently informative, as it lacks necessary details. It earns a 4 for brevity but loses points for not using its minimal space effectively.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no annotations, no output schema, and a simple mathematical tool with 2 parameters, the description is incomplete. It doesn't explain the return value (e.g., a numeric result), error conditions, or how it differs from sibling tools. This leaves significant gaps for an agent to use it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with clear parameter descriptions in Chinese ('真数' for number, '底数(可选,默认为 e)' for base with default e). The description adds no meaning beyond the schema, but the schema does the heavy lifting, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description '对数计算' (logarithm calculation) restates the tool name 'logarithm' in Chinese, making it a tautology. It doesn't specify what kind of logarithm calculation (e.g., natural log, base-10, custom base) or distinguish it from sibling tools like 'calculate' or 'factorial'. The purpose is vague beyond the obvious mathematical operation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives like 'calculate' (which might handle general math) or other mathematical siblings. The description offers no context, exclusions, or prerequisites, leaving the agent with no usage instructions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
sqrtC
计算平方根
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | 要计算平方根的数字 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full burden. It only states the basic operation without disclosing behavioral traits such as error handling (e.g., for negative inputs), performance characteristics, or output format. For a mathematical tool with no annotation coverage, this is a significant gap in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single phrase '计算平方根', which is appropriately sized and front-loaded. It wastes no words, but could be slightly more informative. It earns its place by stating the core function efficiently, though it lacks additional context that might be useful.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (one parameter, no output schema, no annotations), the description is incomplete. It doesn't explain the return value (e.g., numeric result or error), handle edge cases, or provide context for use among siblings. For a basic mathematical function, more detail on behavior and output would improve completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, with the parameter 'number' documented as '要计算平方根的数字' (the number to calculate the square root of). The description doesn't add meaning beyond what the schema provides, such as constraints or examples. With high schema coverage, the baseline score of 3 is appropriate as the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description '计算平方根' (calculates square root) states the basic function but is vague about scope and differentiation. It doesn't specify what type of numbers it handles (e.g., only non-negative) or how it distinguishes from sibling tools like 'calculate' or 'logarithm'. The purpose is clear but lacks specificity and sibling differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., input must be non-negative), exclusions, or comparisons to sibling tools like 'calculate' (which might handle general operations) or 'factorial'. Usage is implied from the name but not explicitly stated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
trigonometryC
三角函数计算(sin、cos、tan)
| Name | Required | Description | Default |
|---|---|---|---|
| function | Yes | 三角函数类型 | |
| angle | Yes | 角度(度数) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states what the tool does (trigonometric calculations) without any information about output format, error handling, precision, domain restrictions (e.g., tan at 90 degrees), or performance characteristics. This leaves significant gaps in understanding how the tool behaves beyond its basic function.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise—a single phrase in Chinese that directly states the tool's function. It is front-loaded with no unnecessary words, making it efficient and easy to parse. Every part of the description earns its place by specifying the mathematical operations.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (mathematical computation with potential edge cases) and the lack of annotations and output schema, the description is incomplete. It doesn't cover return values, error conditions, or behavioral nuances, which are critical for an AI agent to use the tool correctly. The description alone is insufficient for safe and effective invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with clear descriptions for both parameters ('function' as trigonometric type and 'angle' as degrees). The description adds no additional parameter semantics beyond what the schema provides, such as unit conventions or valid angle ranges. However, since the schema fully documents the parameters, the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description '三角函数计算(sin、cos、tan)' clearly states the tool's purpose: it performs trigonometric calculations (sin, cos, tan). It specifies the exact mathematical functions supported, which distinguishes it from sibling tools like 'calculate' (generic), 'factorial', 'logarithm', and 'sqrt'. However, it doesn't explicitly mention the verb 'calculate' or specify the resource (angles), keeping it from a perfect score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools or contexts where trigonometric functions are preferred over other mathematical operations. The agent must infer usage based on the function names alone, which is insufficient for clear decision-making.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v1.0.0- First observed
calculate - First observed
factorial - First observed
logarithm - First observed
sqrt - First observed
trigonometry
TDQS
Scored across 5 tools
Each tool has a clearly distinct mathematical purpose: basic arithmetic, factorial, logarithms, square roots, and trigonometry. There is no overlap in functionality, making it easy for an agent to select the correct tool based on the operation needed.
Most tools follow a consistent naming pattern with descriptive, single-word names (calculate, factorial, logarithm, sqrt, trigonometry). However, 'sqrt' is an abbreviation while others are full words, causing a minor deviation from perfect consistency.
With 5 tools, this server is well-scoped for a calculator domain. Each tool serves a distinct mathematical function, and the count is neither too sparse nor overwhelming, fitting typical calculator operations efficiently.
The toolset covers core mathematical operations (arithmetic, factorial, logarithms, square roots, trigonometry), but there are minor gaps such as missing advanced functions like hyperbolic trigonometry or statistical calculations. However, agents can handle most common calculator tasks without significant issues.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Precision math engine for AI agents. 203 exact methods. Zero hallucination.
AI-callable calculators and engineering models with real formulas. No hallucinated math.
Math.js MCP — wraps the mathjs.org API (free, no auth)
Deterministic time-value-of-money and fund-performance tools for AI agents — future value, present value, CAGR, annuities, perpetuities, loan payments, payback, discounted payback, DPI, RVPI and TVPI via Model Context Protocol. Useful for corporate finance, financial projections, financial analysis, quantitative analysis, financial formulas and financial modeling.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides basic arithmetic operations and advanced mathematical functions through the Model Context Protocol (MCP), with features like calculation history tracking and expression evaluation.1-
- AlicenseAqualityDmaintenanceEnables basic arithmetic operations (addition, subtraction, multiplication, division) with 64-bit precision and matrix multiplication capabilities. Provides mathematical computation tools for AI assistants through the Model Context Protocol.51MIT
- FlicenseAqualityDmaintenanceProvides basic mathematical operations including addition, subtraction, multiplication, division, and power calculations through a Model Context Protocol interface.51-
- FlicenseNot gradedqualityDmaintenanceA mathematical utility server implementing the Model Context Protocol to provide tools for basic and advanced calculations. It enables users to perform operations such as addition, subtraction, powers, square roots, and percentages through natural language.-