Calculator MCP Server
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., "@Calculator MCP Server what is 10 plus 20?"
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 Server
A small, working Model Context Protocol (MCP) server written in TypeScript.
It exposes five MCP tools:
add(a, b)subtract(a, b)multiply(a, b)divide(a, b)square(a)
Prerequisites
Node.js 20+
npm
Related MCP server: Calculator MCP Server
Install
npm installBuild
npm run buildRun
npm startThe server uses stdio, so it waits for an MCP client. Seeing no normal output is expected.
Server diagnostics are written to stderr because stdout is reserved for MCP protocol traffic.
Development mode
npm run devTest with MCP Inspector
Run:
npm run inspectThis starts the MCP Inspector and launches this server through stdio.
In the Inspector:
Connect to the server.
Open the Tools section.
You should see:
addsubtractmultiplydividesquare
Try
addwitha=10,b=20.Expected result:
10 + 20 = 30.Try
squarewitha=5.Expected result:
5² = 25.Try
dividewitha=10,b=0.Expected result: an MCP tool error saying division by zero is not allowed.
MCP client configuration
After publishing this package to npm, another user can configure a compatible MCP client using:
{
"mcpServers": {
"calculator": {
"command": "npx",
"args": ["-y", "sample-calculator-mcp"]
}
}
}For local development, point the client to the local project instead:
{
"mcpServers": {
"calculator": {
"command": "npx",
"args": ["tsx", "C:\\path\\to\\calculator-mcp\\src\\index.ts"]
}
}
}Use the correct path for your machine.
Publishing to npm
First create an npm account and log in:
npm loginBuild:
npm run buildCheck what will be published:
npm pack --dry-runPublish:
npm publishAfter publishing, users can run:
npx -y sample-calculator-mcpProject structure
calculator-mcp/
├── src/
│ └── index.ts
├── package.json
├── tsconfig.json
├── .gitignore
├── README.md
└── LICENSEHow MCP works here
LLM / MCP Host
|
v
MCP Client
|
stdio
|
v
Calculator MCP Server
|
+---+---+---+---+
| | | | |
add sub mul div squareThe MCP server exposes tools. The MCP client discovers those tools and sends tool calls. The server executes the calculation and returns the result.
Important
Do not use console.log() for application/debug output in a stdio MCP server. stdout is used by the MCP protocol. Use console.error() for diagnostics.
Available Tools
4 toolsTool 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 performs a single, clearly distinct arithmetic operation with no overlap. An agent can easily tell multiply, divide, add, and subtract apart based on the operation name and description.
All tool names are simple, lowercase verbs that directly describe the operation. The naming follows a consistent verb pattern without any deviations.
Four tools is a well-scoped set for a basic calculator server, covering the fundamental arithmetic operations without extraneous tools. Each tool earns its place.
The four basic operations cover core arithmetic needs, but a calculator domain typically includes additional operations like exponentiation, square root, or modulo. These are minor gaps that limit some use cases.
Maintenance
Related MCP Connectors
Unofficial Math.js MCP — wraps the mathjs.org API (free, no auth)
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
500+ deterministic tools for AI agents: math, conversion, validation, hashing, encoding, date/time.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides basic calculator operations (add, subtract, multiply, divide) as MCP tools for use with Claude Desktop and other MCP clients.-
- FlicenseAqualityDmaintenanceProvides basic arithmetic operations (add, subtract, multiply, divide) through MCP, enabling AI clients to perform calculations via natural language.4-
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to perform arithmetic operations such as addition, subtraction, multiplication, and division through standardized MCP tools.1-
- FlicenseAqualityCmaintenanceEnables AI agents to perform arithmetic operations — addition, subtraction, multiplication, and division with divide-by-zero validation — through MCP tool calls. It can be run locally over stdio or as an HTTP microservice via streamable-http transport.4-