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-calc2. 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:
Add
cwdconfig (required by some editors like Trae):json{ "mcpServers": { "a-calc": { "command": "npx", "args": ["a-calc-mcp"], "cwd": "${workspaceFolder}" } } }Global install:
bashnpm install -g a-calcThen use:
json{ "mcpServers": { "a-calc": { "command": "a-calc-mcp" } } }Windows note: If you see
Windows requires 'cmd /c' wrapper, changenpxtocmd /c npx
3. Restart Your AI Tool
Restart after configuration and you're ready to go.
Available Tools
| Tool | Purpose | Example |
|---|---|---|
calc | Expression evaluation | calc("0.1 + 0.2") → "0.3" |
fmt | Number formatting | fmt(1234567, ",") → "1,234,567" |
calc_sum | Batch summation | calc_sum("price * qty", [...]) |
basic_calc | Basic arithmetic | basic_calc("add", [0.1, 0.2]) |
chain_calc | Chain calculation | cadd(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.50Troubleshooting
| Issue | Solution |
|---|---|
| Server won't start | 1. Add cwd: "${workspaceFolder}" config2. Try global install npm install -g a-calc3. Ensure Node.js ≥ 18 |
| Tool call fails | Check expression syntax and parameter format |
| Windows error | Change npx to cmd /c npx |