Calculator MCP Server
This server provides five basic arithmetic calculation tools that accept numeric inputs and return both human-readable text and structured JSON results.
Add — add two numbers (
a,b) and return their sum.Subtract — subtract the second number from the first (
a,b) and return the difference.Multiply — multiply two numbers (
a,b) and return the product.Divide — divide the dividend by the divisor (
a,b) and return the quotient (errors on division by zero).Percentage — calculate a specified percent of a value (
value,percent).Input validation via Zod schemas, plus structured outputs containing operation, inputs, and result.
Connects the calculator MCP server to GitHub Copilot Chat in VS Code via stdio, allowing Copilot Agent mode to invoke calculator tools such as addition, subtraction, multiplication, division, and percentage calculation.
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 20% of 500?"
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.

Overview
A simple Model Context Protocol (MCP) server built in Node.js that provides some basic arithmetic calculation tools.The srver uses official MCP JavaScript SDK, Zod for input validation and Standard Input/Output (stdio to communicate with MCP clients.
Features:
Addition of two numbers
Subtraction of one number from another
Multiplication of two numbers
Division with division-by-zero error handling
Percentage calculation
Input validation using Zod
Structured output schemas using Zod
Human-readable and machine-readable tool responses
Integration with GitHub Copilot Chat in Visual Studio Code
Automatic tool selection and sequential tool execution
Related MCP server: Calculator MCP Server
Tech Stack
JavaScript (ES Modules)
Node.js
Model Context Protocol (MCP)
Official MCP JavaScript SDK
Zod
MCP Inspector
Visual Studio Code
GitHub Copilot Chat
Git and GitHub
Available Tools
Tool | Description | Example |
Add | Adds two numbers and returns their sum | 2 + 3 = 5 |
Subtract | Subtracts the second number from the first | 10 − 5 = 5 |
Multiply | Multiplies two numbers | 4 × 3 = 12 |
Divide | Divides the first number by the second | 5 ÷ 2 = 2.5 |
Percentage | Calculates a specified percentage of a number | 20% of 500 = 100 |
Input parameters:
Add, Subtract, Multiply, Divide:
aandbPercentage:
valueandpercent
All input parameters are numbers.
Division by zero returns an error response instead of a successful calculation.
Structured Outputs
All five calculator tools support structured outputs through the MCP protocol.
Each tool defines an outputSchema using Zod and returns a structuredContent object containing the calculation details.
Successful tool responses contain two forms of output:
content— Human-readable text describing the calculation.structuredContent— Machine-readable JSON containing the operation, inputs, and result.
Example: Addition
Input:
{
"a": 125,
"b": 375
}Human-readable response:
The sum of 125 and 375 is 500Structured response:
{
"operation": "addition",
"a": 125,
"b": 375,
"result": 500
}Example: Percentage
Input:
{
"value": 840,
"percent": 25
}Structured response:
{
"operation": "percentage",
"value": 840,
"percent": 25,
"result": 210
}Output Schema Validation
The tools declare output schemas to describe the expected structure and data types of successful results.
For example, the Division tool uses:
outputSchema: {
operation: z.literal("division"),
a: z.number(),
b: z.number(),
result: z.number()
}The operation field identifies the calculation, while the remaining fields represent the inputs and numeric result.
Error responses, such as division by zero, use isError: true and return an explanatory message.
Project Folder Structure
calculator-mcp-server
├── 📁 .vscode
│ └── ⚙️ mcp.json
├── 📁 assets
│ └── 🖼️ banner.png
├── 📁 screenshots
│ ├── 📁 github-copilot
│ │ ├── 🖼️ add-tool-call.png
│ │ ├── 🖼️ all-tool-call-series-prompt.png
│ │ ├── 🖼️ all-tool-call-series-result.png
│ │ ├── 🖼️ automatic-tool-call.png
│ │ ├── 🖼️ copilot-chat.png
│ │ └── 🖼️ serial-tool-call.png
│ └── 📁 mcp-inspector
│ ├── 📁 addition-tool
│ │ ├── 🖼️ input.png
│ │ └── 🖼️ output.png
│ ├── 📁 division-tool
│ │ ├── 🖼️ input.png
│ │ └── 🖼️ output.png
│ ├── 📁 multiplication-tool
│ │ ├── 🖼️ input.png
│ │ └── 🖼️ output.png
│ ├── 📁 percentage-tool
│ │ ├── 🖼️ input.png
│ │ └── 🖼️ output.png
│ ├── 📁 subtraction-tool
│ │ ├── 🖼️ input.png
│ │ └── 🖼️ output.png
│ └── 🖼️ calculator-mcp-server.png
├── 📁 src
│ ├── 📁 server
│ │ └── 📄 calculatorServer.js
│ ├── 📁 tools
│ │ ├── 📄 addition.js
│ │ ├── 📄 division.js
│ │ ├── 📄 multiplication.js
│ │ ├── 📄 percentage.js
│ │ └── 📄 subtraction.js
│ └── 📄 index.js
├── ⚙️ .gitignore
├── 📄 LICENSE
├── 📝 README.md
├── ⚙️ package-lock.json
└── ⚙️ package.jsonPrerequisites
Node.js (developed and tested with v24.11.1)
npm (developed and tested with v11.6.2)
For GitHub Copilot integration:
Visual Studio Code with MCP support
GitHub Copilot Chat access
Installation
1. Clone the repository
git clone https://github.com/sdewanshu-lab/calculator-mcp-server.git2. Navigate to the project directory
cd calculator-mcp-server3. Install dependencies
npm installRunning the MCP Server
Start the server using:
npm run startThe server communicates through stdio, so it does not provide a conventional HTTP endpoint or web interface.
When launched through an MCP client, the client manages the server process and communication.
Testing with MCP Inspector
MCP Inspector is used to test and inspect the server's tools, schemas, and responses.
Launch Inspector from the project directory:
npx @modelcontextprotocol/inspector node src/index.jsOpen the URL provided in the terminal.
MCP Inspector Configuration
Setting | Value |
Transport | stdio |
Command | node |
Arguments | src/index.js |
Working directory | Project root |
Testing Procedure
Connect to the MCP server.
Open the Tools section.
Select List Tools.
Choose a calculator tool.
Enter the required input values.
Execute the tool.
Inspect the text response and structured output.
Test Coverage
The tools were manually tested with cases including:
Positive numbers
Negative numbers
Decimal numbers
Zero values
Division by zero
Invalid input types
Missing required parameters
Successful responses were checked for both content and structuredContent.
Division by zero was tested to verify appropriate error handling.
GitHub Copilot Integration (VS Code)
The Calculator MCP Server can be integrated with GitHub Copilot Chat in Visual Studio Code using stdio transport.
This allows Copilot to discover and invoke the custom calculator tools through MCP.
Configuration
Create the following file in the project root:
.vscode/mcp.json
Add:
{
"servers":{
"calculator-mcp":{
"type":"stdio",
"command":"node",
"args":[
"src/index.js"
]
}
}
}Starting the Server
Open the project folder in Visual Studio Code.
Open
.vscode/mcp.json.Start
calculator-mcpusing the MCP configuration controls or the MCP: List Servers command.Confirm that the server is running.
Open GitHub Copilot Chat in Agent mode.
Ensure the calculator MCP tools are enabled.
Testing with GitHub Copilot
Test 1 — Direct tool invocation
Prompt:
Use the Add tool from my calculator MCP server to calculate 125 + 375.
Expected result: 500
Test 2 — Automatic tool selection
Prompt:
Calculate 35% of 1,200 using my calculator MCP server. Choose the appropriate tool yourself.
Expected result: 420
Test 3 — Sequential tool invocation
Prompt:
Using my calculator MCP server, calculate 25% of 840 and then add 150 to that result.
Expected result: 360
Tools used: Percentage → Add
Five-Tool Sequential Execution
A more advanced test was performed using all five tools in a single natural-language request.
Prompt:
Find my MCP server and calculate 20% of 100, add 10 to the result, then subtract 2, multiply the result by 5, and divide the result by 2. Give all steps and which tool you used.
Execution results:
Step | Tool | Calculation | Result |
1 | Percentage | 20% of 100 | 20 |
2 | Add | 20 + 10 | 30 |
3 | Subtract | 30 − 2 | 28 |
4 | Multiply | 28 × 5 | 140 |
5 | Divide | 140 ÷ 2 | 70 |
Final result: 70
This test demonstrated successful MCP tool discovery, automatic tool selection, and sequential tool execution through GitHub Copilot Chat.
Validation Summary
The following functionality has been manually verified:
All five arithmetic tools operate correctly for the tested cases.
Zod input schemas are registered.
Zod output schemas are registered.
Successful responses include both text and structured content.
Division-by-zero handling returns an error.
MCP Inspector displays the structured responses.
GitHub Copilot discovers and invokes the calculator tools.
Multi-step calculations using sequential MCP tool calls work successfully.
Note: Automated test suites have not yet been implemented.
Screenshots
The following screenshots demonstrate the testing procedure and results of all the five calculator tools using MCP Inspector and Github Copilot Chat in VS Code.
MCP Inspector
MCP server available to test all tools in MCP Inspector

The Addition Tool
Inputs given to Add Tool

Add tool gave text and structured outputs

Subtraction Tool
Inputs given to Subtract Tool

Subtract Tool gave text and structured outputs

Multiplication Tool
Inputs given to Multiply Tool

Multiply Tool gave text and structured outputs

Division Tool
Inputs given to Divide Tool

Divide Tool gave text and structured outputs

Percentage Tool
Inputs given to Percentage Tool

Percentage Tool gave text and structured outputs

GitHub Copilot Chat (VS Code)
Copilot was asked to find the MCP server

Copilot to explicitly call the addition tool to perform addition and it gave correct result

Copilot was asked to perform a calculation by using appropriate tool and it gave correct result by calling the required tool automatically

Copilot was asked to call two tools, one after the other to perform a calulation and it called the first tool, and used that result in the second calculation to giive finalresult

A prompt was ggiven to Copilot to perform a certain calculation that was a combinition of small calculations that were based on all five tools

Copilot intelligently used all five tools in the same sequence of it was asked to do, it performed all and generated final result by using intermediate results of one operation as an input to subsequent operation

Version
Current published release: v1.0.0
Structured tool outputs have been implemented and tested locally and are planned for the next release.
Future improvements may include additional calculator tools, MCP Resources, MCP Prompts, automated testing, and further error handling.
License
This project is licensed under the ISC License. See the LICENSE file for details.
Author
Dewanshu Sharma
GitHub: https://github.com/sdewanshu-lab
Project Repository: https://github.com/sdewanshu-lab/calculator-mcp-server
Available Tools
5 toolsAddA
Adds two numbers and returns their sum
Inputs: a (required), b (required). Returns: a, b, result, operation
DivideB
Divides the dividend by divisor and returns the quotient
Inputs: a (required), b (required). Returns: a, b, result, operation
MultiplyA
Multiplies two numbers and returns their product
Inputs: a (required), b (required). Returns: a, b, result, operation
PercentageB
Calculates a specified percentage of a given number
Inputs: value (required), percent (required). Returns: value, result, percent, operation
SubtractA
Subtracts the second number from the first number and returns the difference
Inputs: a (required), b (required). Returns: a, b, result, operation
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool maps to a single unambiguous arithmetic operation (addition, subtraction, multiplication, division, percentage) with no overlap. An agent can select the correct tool from the operation name alone, and the descriptions reinforce the boundaries.
All five tools use a uniform PascalCase verb style (Add, Subtract, Multiply, Divide, Percentage). The convention is predictable and applied consistently across the set, making names easy to infer.
Five tools is tightly scoped to the calculator domain, with each operation earning its place. There is no redundancy or filler in the surface.
The four core arithmetic operations plus percentage cover the stated purpose well. Minor gaps exist for common calculator operations like exponentiation, square root, or modulo, but agents can work around them via multiplication or division.
Maintenance
Related MCP Connectors
Developer utilities over MCP: Base64 encode and decode, decode JWTs, format JSON, do percentages.
Free calculators as MCP tools: finance, taxes, health, units, dates. Search, fetch & compute.
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
Unofficial Math.js MCP — wraps the mathjs.org API (free, no auth)
Related MCP Servers
- FlicenseBqualityDmaintenanceEnables basic calculator operations such as add, subtract, multiply, and divide through an MCP interface.2-
- FlicenseNot gradedqualityDmaintenanceExposes add, subtract, multiply, and divide as MCP tools, implemented with the FastMCP SDK and a raw stdio version.-
- FlicenseAqualityDmaintenanceEnables 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-
- AlicenseAqualityCmaintenanceEnables basic arithmetic operations such as addition, subtraction, multiplication, and division on two numbers through MCP tools.4MIT