Skip to main content
Glama
amandhunna

MCP Calculator Service

by amandhunna

MCP 計算サービス

Claude AI を使用して自然言語リクエストを処理し、数学計算を実行する計算機サービスのモデル コンテキスト プロトコル (MCP) 実装。

建築

このサービスは、次の 3 つの主要コンポーネントで構成されています。

  1. Calculator API ( calculator-api.js ): 基本的な数学演算を処理します

  2. MCP サーバー( mcp-server.js ): LLM 統合とツール オーケストレーションを管理します。

  3. MCP クライアント( mcp-client.js ): サービスと対話するためのユーザー インターフェースを提供します。

Related MCP server: Calculator MCP

設定

  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

  • アクシオス: ^1.6.7

  • ボディパーサー: ^1.20.2

  • コア: ^2.8.5

  • ドテンヴ: ^16.4.5

  • エクスプレス: ^4.18.3

  • 同時実行: ^8.2.2 (開発依存)

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    A Model Context Protocol server that provides basic mathematical and statistical functions to LLMs, enabling them to perform accurate numerical calculations through a simple API.
    13
    34 npm
    190
    MIT
  • A
    license
    B
    quality
    C
    maintenance
    A Model Context Protocol server that provides basic calculator functionality for LLMs, enabling them to perform mathematical operations like addition, subtraction, multiplication, division, modulo, and square root.
    6
    235 npm
    15
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A 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.
    1
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    A simple Model Context Protocol (MCP) server that provides basic calculation functions to Claude. It enables users to perform mathematical operations like addition directly through natural language commands.
    1
    MIT