mcp-calculator
Provides tools for arithmetic operations (add, subtract, multiply, divide, power, sqrt) powered by an Ollama AI model that understands natural language math queries.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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:4bSetup
# Install dependencies
npm installRun
# Interactive chat
npm run devThen 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 two numbers | 3 + 5 |
| Subtract second from first | 10 - 4 |
| Multiply two numbers | 6 * 7 |
| Divide first by second | 20 / 4 |
| Raise number to a power | 2^8 |
| 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 devIntegrate 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.jsonLicense
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
AI-callable calculators and engineering models with real formulas. No hallucinated math.
Tested financial & practical calculators as free, no-auth MCP tools for AI agents.
Loan & mortgage calculator, compound interest, ROI, crypto prices, FX conversion for AI agents.
Deterministic liquidity and leverage ratio tools for AI agents — current, quick and cash ratios, defensive interval, debt-to-equity, debt-to-assets, equity multiplier and interest coverage via Model Context Protocol. Useful for corporate finance, credit analysis, financial analysis, financial formulas and financial modeling.
Related MCP Servers
- AlicenseCqualityDmaintenanceA Model Context Protocol server that enables LLMs to perform precise numerical calculations by evaluating mathematical expressions.16,157 PyPI160MIT
- AlicenseBqualityCmaintenanceA 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.6235 npm15MIT
- AlicenseNot gradedqualityDmaintenanceA 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.1MIT
- AlicenseAqualityDmaintenanceEnables 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.51MIT