Calculator MCP Server
# Calculator MCP Server
A very basic MCP (Model Context Protocol) server built for training purposes. It exposes five simple tools over stdio so you can see the core MCP mechanics — tool listing, input schemas, and structured responses — without any extra complexity like auth, persistence, or external APIs.
## Tools
| Tool | Input | Description |
|---|---|---|
| `add` | `{a: number, b: number}` | Returns `a + b` |
| `subtract` | `{a: number, b: number}` | Returns `a - b` |
| `multiply` | `{a: number, b: number}` | Returns `a * b` |
| `divide` | `{a: number, b: number}` | Returns `a / b` (errors on `b = 0`) |
| `reverse_string` | `{text: string}` | Returns the reversed string |
## Setup
```bash
npm install
npm run build
```
## Testing locally
Use the [MCP Inspector](https://github.com/modelcontextprotocol/inspector) to interactively call each tool from a browser UI:
```bash
npm run inspect
```
This opens a local web page where you can select a tool, fill in arguments, and see the raw JSON-RPC request/response.
## Using it in Claude Desktop / Claude Code
Add this to your MCP client's config (e.g. `claude_desktop_config.json`):
```json
{
"mcpServers": {
"calculator": {
"command": "node",
"args": ["/Users/douglasbailey/my-dev/claude-mcp/dist/index.js"]
}
}
}
```
Restart the client, and the five calculator tools will be available for Claude to call.
## How it works
- `src/index.ts` creates an MCP `Server`, declares the `tools` capability, and connects over `StdioServerTransport` (the standard transport for local MCP servers).
- `ListToolsRequestSchema` handler returns the tool definitions (name, description, JSON-schema input).
- `CallToolRequestSchema` handler dispatches on `request.params.name` and returns `{content: [{type: "text", text: ...}]}`.
- Throwing an `Error` inside a handler (e.g. divide-by-zero) is automatically surfaced to the client as a tool error — no special handling needed.
TDQS
Scored across 5 tools
The four arithmetic tools (add, subtract, multiply, divide) have clearly distinct, unambiguous purposes. The only oddity is reverse_string, which is unrelated to arithmetic and slightly muddies the server's scope, though it does not overlap with any other tool.
All tools use lowercase snake_case with a consistent verb-based pattern (add, subtract, multiply, divide, reverse_string). No mixing of conventions or casing styles.
Five tools is well-scoped for a simple calculator. Each operation earns its place and there is no redundancy or bloat.
Core arithmetic is fully covered (add, subtract, multiply, divide), but common calculator operations like modulo, exponent, or square root are missing. reverse_string also feels out of place and suggests an incomplete or inconsistent domain focus.