Skip to main content
Glama
doudou-fly

Calculator MCP Server

by doudou-fly

Calculator MCP Server

一个简单的计算器 MCP 服务器,基于 Model Context Protocol 协议,提供加减乘除四则运算功能。

项目简介

Calculator MCP Server 是一个基于 TypeScript 开发的 Model Context Protocol 服务器,为 AI 客户端提供标准化的计算工具能力。通过 MCP 协议,AI 助手可以自动调用加、减、乘、除四则运算工具,无需用户手动计算。

功能特性

  • 加法运算: 计算两个数的和

  • 减法运算: 计算两个数的差

  • ✖️ 乘法运算: 计算两个数的积

  • 除法运算: 计算两个数的商(自动校验除数不为零)

  • 🔒 参数校验: 基于 zod 的自动参数类型校验

  • 📝 调用日志: 服务器端输出每次工具调用的详细日志

工具列表

工具名

功能

参数

add

加法

a: number, b: number

subtract

减法 (a - b)

a: number, b: number

multiply

乘法

a: number, b: number

divide

除法 (a ÷ b)

a: number, b: number

技术栈

  • TypeScript + Node.js

  • @modelcontextprotocol/sdk(McpServer 高层 API)

  • zod(参数校验)

Related MCP server: Math Operations MCP Server

部署指南

环境依赖

  • Node.js >= 18

本地构建

# 安装依赖
npm install

# 构建
npm run build

构建完成后生成 dist/index.js,MCP 客户端会通过 stdio 方式调用它,无需手动启动。

服务配置

在 MCP 客户端中添加以下 STDIO 类型服务配置:

{
  "mcpServers": {
    "calculator": {
      "command": "npx",
      "args": [
        "-y",
        "calculator-mcp-server"
      ]
    }
  }
}

Windows 系统下,建议使用以下配置:

{
  "mcpServers": {
    "calculator": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "calculator-mcp-server"
      ]
    }
  }
}

如果使用本地源码运行,请将 args 替换为实际路径:

{
  "mcpServers": {
    "calculator": {
      "command": "node",
      "args": ["D:\\project\\open-mcp\\dist\\index.js"]
    }
  }
}

各客户端配置示例

Trae

打开 Trae 设置 → MCP 服务器,添加以下配置:

{
  "mcpServers": {
    "calculator": {
      "command": "node",
      "args": ["D:\\project\\open-mcp\\dist\\index.js"]
    }
  }
}

MCP Inspector 调试

npx @modelcontextprotocol/inspector node dist/index.js

浏览器打开后,可以在可视化界面中直接测试所有工具。

命令行测试

项目提供了测试脚本 test.cjs

# 查看所有工具
node test.cjs list

# 调用具体工具(参数:工具名 a b)
node test.cjs call add 3 5
node test.cjs call multiply 123 456
node test.cjs call divide 100 3

使用示例

示例 1:加法运算

在 AI 客户端中输入:

帮我算一下 3 + 5 等于多少?

AI 自动调用 add 工具,返回结果:

3 + 5 = 8

示例 2:乘法运算

帮我算一下 123 × 456 等于多少?

AI 自动调用 multiply 工具,返回结果:

123 × 456 = 56088

示例 3:除法运算

帮我算一下 100 ÷ 3 等于多少?

AI 自动调用 divide 工具,返回结果:

100 ÷ 3 = 33.333333333333336

服务器运行日志

工具调用时,服务器终端会输出调用日志:

计算器 MCP 服务器已启动
[2026-08-04T05:46:55.953Z] 收到调用: multiply {"a":123,"b":456}
[2026-08-04T05:46:55.954Z] 结果(multiply): 123 × 456 = 56088

Available Tools

4 tools
addA

计算两个数的和

ParametersJSON Schema
NameRequiredDescriptionDefault
aYes第一个加数
bYes第二个加数

TDQS

A4/5.0
Behavior4/5

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. The description clearly states the pure computation of a sum, which is the primary behavior. It does not mention edge cases or return type, but for such a trivial operation, the disclosed behavior is adequate and not misleading.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that is front-loaded and directly states the operation. Every word earns its place, and there is zero waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-number addition tool with complete parameter schema, the description sufficiently covers the tool's purpose. It doesn't explicitly state the return value, but that is self-evident from the operation. The low complexity and high schema coverage make the description complete enough.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both parameters 'a' and 'b' described as addends. The description does not add any extra meaning beyond the schema, so the baseline score of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '计算两个数的和' clearly states the tool computes the sum of two numbers. It uses a specific verb and resource, and naturally distinguishes itself from siblings subtract, multiply, and divide by describing the addition operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use when addition is needed, but it does not explicitly state when to use or not use this tool versus the sibling operations. The context is clear from the name and sibling names, but explicit guidance is absent, so it falls to the 'implied usage' level.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

divideA

计算两个数的商 (a ÷ b)

ParametersJSON Schema
NameRequiredDescriptionDefault
aYes被除数
bYes除数(不能为 0)

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description should disclose behavioral traits. It states the operation but does not mention error handling for division by zero, potential precision issues, or return value expectations. The schema does note that b cannot be zero, but the description itself adds no behavioral context beyond the operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single short sentence, directly stating the operation with no superfluous words. It is well-structured and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple arithmetic tool with two parameters, the description and schema together are largely sufficient. It could optionally mention error behavior for b=0, but the schema already indicates the constraint, so the description is reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already provides full descriptions for both parameters (a as dividend, b as divisor, with constraint b cannot be zero). The description only restates the operation and does not add additional parameter meaning beyond what the schema already covers.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool computes the quotient of two numbers (a ÷ b), using a specific verb ('calculate') and resource ('quotient'). This unambiguously distinguishes it from sibling tools like add, subtract, and multiply.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is used when division is needed, but it does not explicitly state when to use it over alternatives or mention any exclusions. No contextual guidance is provided beyond the operation itself.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

multiplyA

计算两个数的积

ParametersJSON Schema
NameRequiredDescriptionDefault
aYes第一个乘数
bYes第二个乘数

TDQS

A3.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description must carry full behavioral disclosure. It only restates the operation ('calculate product') without detailing return type, side effects, or error handling, leaving the agent to infer these from the name and schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence in Chinese with no redundant words. It is perfectly front-loaded and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a trivial arithmetic tool with fully documented parameters, the description is adequate. No output schema exists, but the return value (product) is strongly implied by the operation, so no significant gap is present.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema covers 100% of parameters with clear descriptions (第一个乘数, 第二个乘数). The tool description adds no additional semantic value beyond what the schema already provides, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb (计算) and resource (两个数的积), clearly distinguishing it from sister operations like add, subtract, and divide. It directly states what the tool does without ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit usage guidance or alternative comparisons are provided. However, the name and description make the use case obvious for a basic arithmetic operation, so usage is reasonably implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

subtractA

计算两个数的差 (a - b)

ParametersJSON Schema
NameRequiredDescriptionDefault
aYes被减数
bYes减数

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the behavioral burden. It defines the order-sensitive subtraction behavior (a - b), which is useful. However, it does not disclose error handling, return type, or behavior for edge cases, though the schema covers input types.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, front-loaded sentence conveys the core operation and formula without redundancy. Every word contributes to understanding the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-number arithmetic tool, the description plus schema sufficiently covers the operation and parameters. It lacks explicit return-type or error information, but the low complexity and full parameter coverage make the tool adequately specified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already provides descriptions for both parameters ('被减数' minuend and '减数' subtrahend) with 100% coverage. The description adds the explicit formula a - b, which reinforces the relational meaning of the parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the operation: '计算两个数的差 (a - b)', clearly indicating subtraction of b from a. This distinguishes it from sibling tools add, multiply, and divide.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

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 only states the mathematical operation and does not mention exclusions, prerequisites, or when a different arithmetic tool would be appropriate.

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. Dates show when Glama detected each change.

  1. 4 tool updatesv1.0.0
    • First observedadd
    • First observeddivide
    • First observedmultiply
    • First observedsubtract

TDQS

A4/5.0
Disambiguation5/5

Each tool performs a unique arithmetic operation (addition, subtraction, multiplication, division) with no overlap. The distinct mathematical symbols in descriptions remove any ambiguity.

Naming Consistency5/5

All tool names follow the same verb pattern using the operation name (add, subtract, multiply, divide). This is perfectly consistent and predictable.

Tool Count5/5

Four tools is an ideal scope for a basic calculator server, covering the core arithmetic operations without unnecessary bloat.

Completeness4/5

The four basic operations cover the primary use case for a calculator. A modulo or power operation could be added, but the surface is not severely incomplete.

Maintenance

ActivityMaintained
ResponsivenessSyncing

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

  • Math.js MCP — wraps the mathjs.org API (free, no auth)

  • This MCP server enables users to perform scientific computations regarding linear algebra and vect…

  • Tested financial & practical calculators as free, no-auth MCP tools for AI agents.

  • SmartMoney77 MCP v0.6.0 — 14 public tools that turn financial questions into exact numbers and citable links. New: historical_investment_return and compare_investments, which compute "what if I had invested" results from real yearly price data. Also compound interest, FIRE number, credit-card payoff, emergency fund, inflation, latte factor, investment fees, cost of waiting, plus discovery/deep-link/share-pack tools for a catalog of calculators in 6 languages (he/en/ar/es/pt/in). Public, no login. Endpoint: https://smartmoney77.com/mcp

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides basic mathematical operations (addition, subtraction, multiplication, division) through a Model Context Protocol server. Enables MCP-compatible clients like chatbots to perform calculations by sending structured math requests.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI applications to perform basic mathematical operations like addition and subtraction through MCP tools. Also provides REST API endpoints for the same operations.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables basic arithmetic operations (add, subtract, multiply, divide, modulo) via natural language, with a FastMCP-based server and client for exploring MCP tool calling.
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables performing arithmetic operations (add, subtract, multiply, divide, power, modulo) via natural language through HTTP SSE transport, allowing integration with Claude or other MCP clients for AI-powered calculations.
    -

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/doudou-fly/open-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server