MCP Calculator Service
A Model-Context-Protocol (MCP) implementation for a calculator service that uses Claude AI to process natural language requests and perform mathematical calculations.
Architecture
The service consists of three main components:
- Calculator API (
calculator-api.js
): Handles basic mathematical operations - MCP Server (
mcp-server.js
): Manages LLM integration and tool orchestration - MCP Client (
mcp-client.js
): Provides a user interface for interacting with the service
Setup
- Install dependencies:
- Create a
.env
file in the root directory with the following variables:
Running the Service
You can run all components concurrently:
Or run them individually:
Usage
Once the service is running, you can interact with it through the client interface. Here are some example commands:
- "Add 5 and 3"
- "What is 10 plus 20?"
- "Calculate 7.5 + 2.25"
- "Multiply 4 by 6"
- "What is 8 times 3?"
Type "help" for more examples or "exit" to quit.
API Endpoints
Calculator API (Port 3000)
POST /:operation
- Perform mathematical operations (add, subtract, multiply, divide, power)GET /health
- Health check endpoint
MCP Server (Port 3001)
GET /tools
- List available toolsPOST /execute/:toolId
- Execute a specific toolPOST /agent
- Process natural language requestsGET /health
- Health check endpoint
Error Handling
The service includes comprehensive error handling for:
- Invalid mathematical operations
- Division by zero
- Invalid parameter types
- LLM response parsing errors
- Network errors
Dependencies
- @anthropic-ai/sdk: ^0.51.0
- axios: ^1.6.7
- body-parser: ^1.20.2
- cors: ^2.8.5
- dotenv: ^16.4.5
- express: ^4.18.3
- concurrently: ^8.2.2 (dev dependency)
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
모델-컨텍스트-프로토콜 아키텍처를 통해 Claude AI와 계산기 API를 통합하여 수학적 계산을 수행하기 위한 자연어 요청을 처리하는 서비스입니다.
Related MCP Servers
- AsecurityFlicenseAqualityA server that provides advanced mathematical and financial calculation capabilities for AI code assistants, enabling them to perform complex calculations like symbolic calculus, numerical methods, and financial analysis without implementing algorithms directly.Last updated -183
- -securityFlicense-qualityA Node.js server that processes mathematical calculations and natural language math queries through RESTful API endpoints.Last updated -
- -securityAlicense-qualityA 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.Last updated -1MIT License
- -securityFlicense-qualityA calculator server that exposes mathematical functions as tools (add, subtract, multiply, divide, square, power, square root), enabling language models to perform calculations through Model Context Protocol (MCP).Last updated -