Skip to content

MCP Integration

a-calc ships a built-in MCP server so AI assistants can use a-calc for precise calculations and formatting.

Quick Start

1. Install

bash
npm install a-calc

2. Configure Your AI Tool

Add to your config file:

Claude Desktop

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Cline / Trae / other MCP clients — add in the corresponding settings

Config:

json
{
  "mcpServers": {
    "a-calc": {
      "command": "npx",
      "args": ["a-calc-mcp"]
    }
  }
}

💡 Note: Claude Desktop defaults to the project root directory and will automatically use the locally installed a-calc if present. Otherwise npx downloads the latest version.

Troubleshooting:

If the MCP server fails to start, try in order:

  1. Add cwd config (required by some editors like Trae):

    json
    {
      "mcpServers": {
        "a-calc": {
          "command": "npx",
          "args": ["a-calc-mcp"],
          "cwd": "${workspaceFolder}"
        }
      }
    }
  2. Global install:

    bash
    npm install -g a-calc

    Then use:

    json
    {
      "mcpServers": {
        "a-calc": {
          "command": "a-calc-mcp"
        }
      }
    }
  3. Windows note: If you see Windows requires 'cmd /c' wrapper, change npx to cmd /c npx

3. Restart Your AI Tool

Restart after configuration and you're ready to go.

Available Tools

ToolPurposeExample
calcExpression evaluationcalc("0.1 + 0.2")"0.3"
fmtNumber formattingfmt(1234567, ",")"1,234,567"
calc_sumBatch summationcalc_sum("price * qty", [...])
basic_calcBasic arithmeticbasic_calc("add", [0.1, 0.2])
chain_calcChain calculationcadd(100).mul(0.8)()

Usage Examples

User: Calculate 0.1 + 0.2
AI: [calls calc] → 0.3

User: Format 1234567.89 with thousands separator and 2 decimal places
AI: [calls fmt] → 1,234,567.89

User: Calculate order total (Item A: 99.9×2, Item B: 49.9×3)
AI: [calls calc_sum] → 349.50

Troubleshooting

IssueSolution
Server won't start1. Add cwd: "${workspaceFolder}" config
2. Try global install npm install -g a-calc
3. Ensure Node.js ≥ 18
Tool call failsCheck expression syntax and parameter format
Windows errorChange npx to cmd /c npx

Released under the MIT License