Skip to main content
Glama
souravjai

Calculator MCP Server

by souravjai

Calculator MCP Server

stdio 経由で基本的な電卓操作を提供する、小さな Model Context Protocol (MCP) サーバーです。

Calculator MCP server tutorial

機能

このサーバーは以下のツールを提供します:

ツール

説明

引数

add

2つの数値を加算します

op1, op2

sub

最初の数値から2番目の数値を減算します

op1, op2

mul

2つの数値を乗算します

op1, op2

div

最初の数値を2番目の数値で除算します

op1, op2

すべての引数は数値でなければなりません。div は op2 が 0 のときエラーを返します。

Related MCP server: Simple Calculator MCP

要件

  • Node.js 18 以降

  • npm

セットアップ

このディレクトリで依存関係をインストールします:

npm install

サーバーを実行する

stdio 経由で MCP サーバーを起動します:

npm start

サーバーは MCP クライアントの接続を待機するため、通常のアプリケーション出力をターミナルに表示しません。

サンプルクライアントでテストする

サンプルクライアントはサーバーを起動してツールを一覧表示し、ゼロ除算エラーを示すために div を 10 と 0 で呼び出します:

npm run test-client

成功する操作をテストするには、mcp-client-test.ts の callTool 引数を更新します。例:

arguments: { op1: 10, op2: 2 },

MCP Inspector を使用する

次のコマンドでインタラクティブな MCP Inspector を実行します:

npm run mcp-inspect

コマンドが出力した URL を開き、電卓ツールを選択して op1 と op2 に値を入力してください。

プロジェクトファイル

  • mcp-server.ts - MCP サーバーと電卓ツールの定義

  • mcp-client-test.ts - サンプル MCP クライアント

  • mcp-calculator.gif - チュートリアルのウォークスルー

  • package.json - スクリプトと依存関係

Related MCP Connectors

Related MCP Servers

  • F
    license
    A
    quality
    D
    maintenance
    Provides basic mathematical operations including addition, subtraction, multiplication, division, and power calculations through a Model Context Protocol interface.
    5
    1
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides file reading and mathematical calculation tools through the Model Context Protocol. Enables reading file contents and evaluating mathematical expressions via stdio transport.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides basic arithmetic operations (add, multiply, divide) for AI assistants through the Model Context Protocol.
    -