Skip to main content
Glama
Arunyaiitm

mcp-calculator

by Arunyaiitm

MCP Calculator Agent

A simple calculator powered by the Model Context Protocol (MCP) and Ollama. Ask math questions in plain English and get answers.

What is this?

This project connects an AI model (Ollama) to a set of calculator tools via MCP. The AI understands your question, picks the right tool, and returns the result — all through a simple chat interface.

Related MCP server: Calculator MCP

How it works

You  ──>  Agent  ──>  Ollama (AI)  ──>  MCP Server (tools)
              │             │                    │
              │  send msg   │  pick tool call    │  execute math
              │<────────────│<───────────────────│
              │  get answer │  return result     │
              │<────────────│<───────────────────│
  • MCP Server — exposes 6 calculator tools (add, subtract, multiply, divide, power, sqrt)

  • Agent — middleman that connects Ollama to the MCP server and runs the chat loop

  • Ollama — the AI brain that reads your question and decides which tool to use

Prerequisites

# Pull a model
ollama pull qwen3:4b

Setup

# Install dependencies
npm install

Run

# Interactive chat
npm run dev

Then ask things like:

What is 12 * 15?
What's the square root of 144?
Calculate (3 + 7) * 2
What is 2 to the power of 10?

Type quit or exit to stop.

Available Tools

Tool

Description

Example

add

Add two numbers

3 + 5

subtract

Subtract second from first

10 - 4

multiply

Multiply two numbers

6 * 7

divide

Divide first by second

20 / 4

power

Raise number to a power

2^8

sqrt

Square root of a number

sqrt(144)

Use a different model

Set the OLLAMA_MODEL environment variable:

OLLAMA_MODEL=qwen2.5-coder:3b npm run dev

Integrate with OpenCode

Add this to opencode.jsonc in your project root:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "calculator": {
      "type": "local",
      "command": ["npx", "tsx", "src/server-runner.ts"],
      "cwd": "."
    }
  }
}

Project structure

mcp-calculator/
├── src/
│   ├── server.ts         # MCP server with calculator tools
│   ├── server-runner.ts  # Entry point for the MCP server
│   ├── agent.ts          # Agent connecting Ollama to MCP
│   ├── index.ts          # Interactive REPL
│   └── test.ts           # Quick end-to-end test
├── package.json
└── tsconfig.json

License

MIT

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    B
    quality
    C
    maintenance
    A Model Context Protocol server that provides basic calculator functionality for LLMs, enabling them to perform mathematical operations like addition, subtraction, multiplication, division, modulo, and square root.
    6
    444
    16
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A backend service that provides accurate arithmetic calculation capabilities to AI models via the Model Context Protocol, allowing LLMs to offload mathematical computations for numerical queries.
    1
    MIT
  • A
    license
    A
    quality
    C
    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

View all related MCP servers

Related MCP Connectors

  • AI-callable calculators and engineering models with real formulas. No hallucinated math.

  • Precision math engine for AI agents. 203 exact methods. Zero hallucination.

  • High-precision finance & business calculations for AI agents — exact decimals, never floats.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Arunyaiitm/mcp-calculator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server