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 计算器服务

计算器服务的模型上下文协议 (MCP) 实现,使用 Claude AI 处理自然语言请求并执行数学计算。

建筑学

该服务由三个主要部分组成:

  1. 计算器 APIcalculator-api.js ):处理基本的数学运算
  2. MCP 服务器mcp-server.js ):管理 LLM 集成和工具编排
  3. MCP 客户端mcp-client.js ):提供与服务交互的用户界面

设置

  1. 安装依赖项:
npm install
  1. 在根目录中创建一个.env文件,其中包含以下变量:
ANTHROPIC_API_KEY=your_api_key_here PORT=3000 MCP_PORT=3001

运行服务

您可以同时运行所有组件:

npm start

或者单独运行它们:

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

用法

服务运行后,您可以通过客户端界面与其交互。以下是一些示例命令:

  • “将 5 加 3”
  • “10 加 20 等于多少?”
  • “计算 7.5 + 2.25”
  • “4 乘以 6”
  • “8 乘以 3 等于多少?”

输入“help”获取更多示例或输入“exit”退出。

API 端点

计算器 API(端口 3000)

  • POST /:operation - 执行数学运算(加、减、乘、除、幂)
  • GET /health - 健康检查端点

MCP 服务器(端口 3001)

  • GET /tools - 列出可用工具
  • POST /execute/:toolId - 执行特定工具
  • POST /agent - 处理自然语言请求
  • GET /health - 健康检查端点

错误处理

该服务包括针对以下方面的全面错误处理:

  • 无效的数学运算
  • 除以零
  • 无效的参数类型
  • LLM 响应解析错误
  • 网络错误

依赖项

  • @anthropic-ai/sdk: ^0.51.0
  • axios:^1.6.7
  • 正文解析器:^1.20.2
  • COR:^2.8.5
  • dotenv:^16.4.5
  • 快递:^4.18.3
  • 同时:^8.2.2(开发依赖)
-
security - not tested
F
license - not found
-
quality - not tested

通过模型-上下文-协议架构将 Claude AI 与计算器 API 集成,处理自然语言请求以执行数学计算的服务。

  1. 建筑学
    1. 设置
      1. 运行服务
        1. 用法
          1. API 端点
            1. 计算器 API(端口 3000)
            2. MCP 服务器(端口 3001)
          2. 错误处理
            1. 依赖项

              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