Skip to main content
Glama
souravjai

Calculator MCP Server

by souravjai

Calculator MCP Server

A small Model Context Protocol (MCP) server that exposes basic calculator operations over stdio.

Calculator MCP server tutorial

Features

The server provides these tools:

Tool

Description

Arguments

add

Adds two numbers

op1, op2

sub

Subtracts the second number from the first

op1, op2

mul

Multiplies two numbers

op1, op2

div

Divides the first number by the second

op1, op2

All arguments must be numbers. div returns an error when op2 is 0.

Related MCP server: Math MCP Server

Requirements

  • Node.js 18 or later

  • npm

Setup

Install the dependencies from this directory:

npm install

Run the server

Start the MCP server over stdio:

npm start

The server waits for an MCP client to connect, so it does not print normal application output to the terminal.

Test with the example client

The example client starts the server, lists its tools, and calls div with 10 and 0 to demonstrate the division-by-zero error:

npm run test-client

To test a successful operation, update the callTool arguments in mcp-client-test.ts, for example:

arguments: { op1: 10, op2: 2 },

Use MCP Inspector

Run the interactive MCP Inspector with:

npm run mcp-inspect

Open the URL printed by the command, then select a calculator tool and provide values for op1 and op2.

Project files

  • mcp-server.ts - MCP server and calculator tool definitions

  • mcp-client-test.ts - example MCP client

  • mcp-calculator.gif - tutorial walkthrough

  • package.json - scripts and dependencies

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables basic arithmetic operations (addition, subtraction, multiplication, division) with 64-bit precision and matrix multiplication capabilities. Provides mathematical computation tools for AI assistants through the Model Context Protocol.
    5
    1
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Provides basic mathematical operations including addition, subtraction, multiplication, division, and power calculations through a Model Context Protocol interface.
    5
    1
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides file reading and mathematical calculation tools through the Model Context Protocol. Enables reading file contents and evaluating mathematical expressions via stdio transport.
    -