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
Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    -
    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.
    Last updated
  • A
    license
    -
    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.
    Last updated
    MIT
  • F
    license
    -
    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.
    Last updated

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

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