calc_mcp
Click on "Deploy 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., "@calc_mcp Calculate 12.5 times 4 and then add 3.2"
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.
calc_mcp
A calculator MCP service that provides addition, subtraction, multiplication, and division over stdio.
It uses the FastMCP API from the official MCP Python SDK, with dependencies pinned to 1.x to avoid interface changes from major version upgrades.
Available tools
All tools take two required numeric arguments, a and b, and support integers, decimals, and negative numbers.
Tool | Operation | Example arguments | Result |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A successful call returns {"result": 数值} as structuredContent, along with compatible text content. The tools do not read or write files and do not access the network.
Errors are returned with isError: true in the MCP tool result and do not interrupt the service:
Divisor is
0or-0.0:Cannot divide by zero.Operand is NaN or infinity:
Operands must be finite numbers.Result overflows to infinity:
Result exceeds the supported finite number range.Missing arguments or values that cannot be parsed as numbers: the SDK returns an argument validation error.
Arithmetic uses Python double-precision floating-point numbers, so the usual floating-point rounding errors apply; for example, 0.1 + 0.2 may return 0.30000000000000004. It is not meant for scenarios that require exact decimal arithmetic; this version does not support expression evaluation.
Related MCP server: My Calculator MCP Server
Directory structure
calc_mcp/
├── pyproject.toml # 项目、依赖和命令行入口
├── uv.lock # 依赖版本锁定
├── README.md
├── .gitignore
├── src/calc_mcp/
│ ├── __init__.py
│ ├── __main__.py # python -m calc_mcp 入口
│ ├── server.py # MCP 实例和 stdio 启动
│ └── tools.py # 四则运算、边界检查和工具注册
└── tests/
└── test_server.py # 算术单元测试和 stdio 集成测试Installation and startup
Requires Python 3.10+ and uv. Run the following in the project directory:
uv sync
uv run calc-mcpYou can also start it via the module entry point:
uv run python -m calc_mcpThe service communicates with MCP clients over standard input/output and does not provide a web page. It is normal for it to wait for client messages right after startup. Do not print debug information to stdout; logs should be written to stderr.
MCP client configuration example
The following applies to clients that use the mcpServers JSON configuration format; adjust it to match your client:
{
"mcpServers": {
"calc-mcp": {
"command": "uv",
"args": [
"--directory",
"/Users/lifang/product/0826/calc_mcp",
"run",
"calc-mcp"
]
}
}
}If the client cannot find uv, change command to the absolute path of the uv executable. After moving the project, update the directory path accordingly.
Verification
uv run python -m unittest discover -s tests -vThe tests cover the four arithmetic operations, negative numbers, decimals, zero, invalid arguments, non-finite numbers, and overflow. They also launch a real stdio subprocess to check MCP initialization, tool discovery, tool invocation, and normal calls after errors.
Future extension points
Add tool definitions in src/calc_mcp/tools.py and include the functions in the registration list of register_tools(). create_server() in server.py registers all tools centrally.
Available Tools
4 toolsaddARead-onlyIdempotent
Add two finite numbers: a + b.
Inputs: a (required), b (required). Returns: result
divideARead-onlyIdempotent
Divide a by b: a / b. Operands must be finite and b must not be zero.
Inputs: a (required), b (required). Returns: result
multiplyARead-onlyIdempotent
Multiply two finite numbers: a * b.
Inputs: a (required), b (required). Returns: result
subtractARead-onlyIdempotent
Subtract b from a: a - b. Both operands must be finite numbers.
Inputs: a (required), b (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool maps to a single, distinct arithmetic operation: addition, subtraction, multiplication, or division. There is no overlap or ambiguity between tool purposes.
All tool names follow the same simple verb-only pattern: add, subtract, multiply, divide. The naming is perfectly consistent and instantly predictable.
Four tools is the ideal size for a basic arithmetic calculator server. Each tool covers a fundamental operation without unnecessary bloat.
The tool set fully covers the core arithmetic operations needed for a calculator: addition, subtraction, multiplication, and division, with appropriate edge-case handling for division by zero. It is a complete minimal surface for its stated purpose.
Maintenance
Related MCP Connectors
Evaluates Reverse Polish Notation (postfix) expressions: arithmetic, trig, logs, bitwise ops.
High-precision finance & business calculations for AI agents — exact decimals, never floats.
Exact arithmetic, algebra, calculus, physics, chemistry and finance with a checkable formula.
Create friendly greetings and add two numbers instantly. Speed up simple tasks and streamline ligh…
Related MCP Servers
- AlicenseDqualityDmaintenanceProvides basic mathematical operations (addition, subtraction, multiplication, division) through a calculate tool. Supports both stdio and HTTP/SSE transport modes.1ISC
- FlicenseNot gradedqualityDmaintenanceEnables basic calculator operations such as add, subtract, multiply, and divide through an MCP interface.-
- AlicenseNot gradedqualityDmaintenanceExposes add, subtract, multiply, and divide tools for performing arithmetic operations over stdio via the Model Context Protocol.ISC
- FlicenseAqualityCmaintenanceEnables an LLM client to perform basic arithmetic on two numbers — addition, subtraction, multiplication, and division — plus reverse a supplied text string, through five simple tools exposed over stdio. Inputs and structured text results follow JSON schemas, with invalid operations such as division by zero surfaced as tool errors.5-