Skip to main content
Glama
Calculator MCP Server

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

Related MCP server: MPC-PoC-1-EchoServerToolsbasicas

Setup

npm install
npm run build

Testing locally

Use the MCP Inspector to interactively call each tool from a browser UI:

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):

{
  "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.

Available Tools

5 tools
addA

Add two numbers together

Inputs: a (required), b (required).

divideB

Divide a by b

Inputs: a (required), b (required).

multiplyB

Multiply two numbers together

Inputs: a (required), b (required).

reverse_stringB

Reverse a string of text

Inputs: text (required).

subtractB

Subtract b from a

Inputs: a (required), b (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 5 tools

    Disambiguation4/5

    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.

    Naming Consistency5/5

    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.

    Tool Count5/5

    Five tools is well-scoped for a simple calculator. Each operation earns its place and there is no redundancy or bloat.

    Completeness4/5

    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.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      D
      quality
      D
      maintenance
      Provides basic mathematical operations (addition, subtraction, multiplication, division) through a calculate tool. Supports both stdio and HTTP/SSE transport modes.
      1
      13 npm
      ISC
    • F
      license
      A
      quality
      D
      maintenance
      A learning-oriented MCP server that exposes basic tools (echo, add, reverse) over stdio transport to validate MCP handshake and tool calls.
      3
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Exposes add, subtract, multiply, and divide tools for performing arithmetic operations over stdio via the Model Context Protocol.
      24 npm
      MIT
    • F
      license
      A
      quality
      C
      maintenance
      Enables 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
      -