MCP Arithmetic Server
README.md
# MCP Arithmetic Server
A Model Context Protocol (MCP) server built with Node.js that exposes four arithmetic tools: `add`, `subtract`, `multiply`, and `divide`.
## Prerequisites
- Node.js 18+ (for top-level `await` and ES modules)
## Installation
```bash
npm install
```
## Running the server
```bash
npm start
```
The server communicates over **stdio**, so it can be connected to any MCP-compatible client.
## MCP Inspector
The [MCP Inspector](https://github.com/modelcontextprotocol/inspector) is a tool for inspecting and testing MCP servers. It provides a web UI where you can list tools and call them interactively.
```bash
npm run inspector
```
This launches the inspector in your browser. In the inspector UI:
- Set the **transport** to `Stdio`
- Set the **command** to `node` and the **args** to `server.js`
- Click **Connect**
You can then call any of the tools directly from the browser.
## Available tools
All four tools share the same input schema — two numbers:
| Property | Type | Required | Description |
| -------- | ------ | -------- | ----------------- |
| `a` | number | yes | The first number |
| `b` | number | yes | The second number |
### `add`
Adds two numbers together.
```json
{ "a": 5, "b": 7 }
```
**Result:** `5 + 7 = 12`
### `subtract`
Subtracts the second number from the first (`a - b`).
```json
{ "a": 10, "b": 4 }
```
**Result:** `10 - 4 = 6`
### `multiply`
Multiplies two numbers together.
```json
{ "a": 5, "b": 7 }
```
**Result:** `5 * 7 = 35`
### `divide`
Divides the first number by the second (`a / b`). Returns an error if `b` is zero.
```json
{ "a": 15, "b": 3 }
```
**Result:** `15 / 3 = 5`
```json
{ "a": 15, "b": 0 }
```
**Result (error):** `Cannot divide by zero.`
## Testing locally
You can test the server with the MCP Inspector:
```bash
npm run server:inspect
```
## Connecting to a client
Configure your MCP client (e.g., Claude Desktop, VS Code Copilot) to use this command:
```
node D:\Learning_Projects\MCP\server.js
```
TDQS
A4.2/5.0
Scored across 4 tools
Disambiguation5/5
Each tool performs a unique arithmetic operation with no overlap. Clear parameter conventions (a, b) further eliminate ambiguity.
Naming Consistency5/5
All tool names are single verbs matching their operations exactly: add, subtract, multiply, divide. Perfectly consistent pattern.
Tool Count5/5
Four tools cover the four basic arithmetic operations without redundancy. The scope is narrow and well-suited to the server's purpose.
Completeness4/5
The core arithmetic operations are fully covered. Minor additions like modulo or exponentiation could be useful, but the current set is coherent and complete for basic arithmetic.
Maintenance
ActivityMaintained
ResponsivenessNo issues