MCP Calculator Service

by amandhunna
Integrations
  • Manages environment variables for the MCP server, including Anthropic API keys and port configurations.

  • Used for making HTTP requests to the calculator API endpoints, enabling the MCP server to perform mathematical operations like addition, subtraction, multiplication, division, and power calculations.

  • Powers the API endpoints for both the calculator service and MCP server, handling requests for mathematical operations and tool execution.

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:

  1. Calculator API (calculator-api.js): Handles basic mathematical operations
  2. MCP Server (mcp-server.js): Manages LLM integration and tool orchestration
  3. MCP Client (mcp-client.js): Provides a user interface for interacting with the service

Setup

  1. Install dependencies:
npm install
  1. Create a .env file in the root directory with the following variables:
ANTHROPIC_API_KEY=your_api_key_here PORT=3000 MCP_PORT=3001

Running the Service

You can run all components concurrently:

npm start

Or run them individually:

# Calculator API npm run start:calculator # MCP Server npm run start:mcp # MCP Client npm run start:client

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 tools
  • POST /execute/:toolId - Execute a specific tool
  • POST /agent - Process natural language requests
  • GET /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)
-
security - not tested
F
license - not found
-
quality - not tested

A service that processes natural language requests to perform mathematical calculations by integrating Claude AI with a calculator API through the Model-Context-Protocol architecture.

  1. Architecture
    1. Setup
      1. Running the Service
        1. Usage
          1. API Endpoints
            1. Calculator API (Port 3000)
            2. MCP Server (Port 3001)
          2. Error Handling
            1. Dependencies

              Related MCP Servers

              • -
                security
                F
                license
                -
                quality
                A Node.js server that processes mathematical calculations and natural language math queries through RESTful API endpoints.
                Last updated -
                JavaScript
              • A
                security
                F
                license
                A
                quality
                A simple server that provides basic arithmetic operations (addition, subtraction, multiplication, division) as tools that can be called by Large Language Models through the Model Context Protocol.
                Last updated -
                4
                JavaScript
              • -
                security
                A
                license
                -
                quality
                A mathematical expression calculator that processes user-input expressions and returns computed results, supporting basic operations and built-in constants like PI and E.
                Last updated -
                408
                2
                TypeScript
                MIT License
              • A
                security
                A
                license
                A
                quality
                A Model Context Protocol server implementation that enables AI assistants like Claude to perform Google searches and retrieve web data directly through natural language requests.
                Last updated -
                1
                75
                3
                TypeScript
                MIT License

              View all related MCP servers

              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/amandhunna/mcpserver'

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