Exposes six calculator operations as MCP tools: add, subtract, multiply, divide, power, and sqrt. Each operation takes numeric parameters and returns formatted results like "5 + 3 = 8" or "2^8 = 256". Includes basic error handling for division by zero and negative square roots. You'd reach for this as a simple reference implementation when learning to build MCP servers or testing client integrations. The TypeScript source is straightforward, making it easy to fork and extend with additional mathematical operations. Runs via stdio transport and integrates with Claude Desktop through a standard node command configuration.
Public tool metadata for what this MCP can expose to an agent.
calculateEvaluate math expressions, simplify algebraic expressions, or compute symbolic derivatives. Supports arithmetic, trigonometry, statistics, matrices, complex numbers, units, and combinatorics.5 paramsEvaluate math expressions, simplify algebraic expressions, or compute symbolic derivatives. Supports arithmetic, trigonometry, statistics, matrices, complex numbers, units, and combinatorics.
scopeobjectvariablevalueoperationstringevaluate · simplify · derivativedefault: evaluateprecisionvalueexpressionstringA simple Model Context Protocol (MCP) server that provides basic calculator functionality through MCP tools.
This MCP server provides the following calculator tools:
npm install
npm run build
Start the MCP server:
npm start
Or run in development mode:
npm run dev
To use this calculator MCP server with an MCP client (like Claude Desktop), add it to your MCP configuration:
{
"mcpServers": {
"calculator": {
"command": "node",
"args": ["/path/to/calculator-mcp/dist/index.js"],
"env": {}
}
}
}
Adds two numbers together.
a (number), b (number)add(5, 3) returns 5 + 3 = 8Subtracts the second number from the first.
a (number), b (number)subtract(10, 4) returns 10 - 4 = 6Multiplies two numbers together.
a (number), b (number)multiply(6, 7) returns 6 × 7 = 42Divides the first number by the second.
a (number), b (number)divide(15, 3) returns 15 ÷ 3 = 5Raises the base to the power of the exponent.
base (number), exponent (number)power(2, 8) returns 2^8 = 256Calculates the square root of a number.
number (number)sqrt(16) returns √16 = 4calculator-mcp/
├── src/
│ └── index.ts # Main MCP server implementation
├── dist/ # Compiled JavaScript output
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # This file
npm run build
npm run dev
The calculator includes proper error handling for:
All errors are returned with appropriate error messages and the isError flag set to true.
MIT