MCP サーバーの基本例
これは、ツールやリソースなどのコア機能を示すモデル コンテキスト プロトコル (MCP) サーバー実装の基本的な例です。
セットアップ手順
プロジェクトを初期化します (任意のローカル フォルダーに移動して、PowerShell または cmd を起動します)。
仮想環境を作成してアクティブ化する
依存関係をインストールします:
または
特徴
サーバーは次の機能を実装します。
ツール
add(a: int, b: int)
: 2つの数値を加算するsubtract(a: int, b: int)
: 最初の数値から2番目の数値を引く
リソース
greeting://{name}
: パーソナライズされた挨拶を返します
サーバーの実行
開発用に MCP Inspector を使用してサーバーを実行するには:
サーバーを通常どおり実行するには:
Claude デスクトップ アプリにサーバーをインストールするには:
VSコードでのMCP接続
vscodeでフォルダ/mcp-server-basicを開く
ターミナルを開き、以下のコマンドを実行します。
Cntrl+Shift+I をクリックして、VS Code でチャットを起動します。
Githubでログインしてセットアップする
以下の手順に従ってください (VS Code ユーザー設定に MCP 構成を追加する 2 つの方法)。
#MCPからこんにちは
This server cannot be installed
シンプルな算術ツールとグリーティング リソースを使用してコア機能をデモンストレーションするモデル コンテキスト プロトコル サーバーのサンプル実装。
Related MCP Servers
- -securityAlicense-qualityA simple implementation of a Model Context Protocol server that demonstrates core functionality including mathematical tools (add, subtract) and personalized greeting resources.Last updated -75GPL 3.0
- -securityFlicense-qualityA minimal example server implementing the Model Context Protocol, providing addition and multiplication tools for learning and experimentation with MCP clients.Last updated -
- AsecurityFlicenseAqualityA Model Context Protocol server implementation that provides basic utility tools including echo, uppercase text conversion, and mathematical calculations.Last updated -3504
- -securityFlicense-qualityA simple demonstration server for the Model Context Protocol that provides tools for creating and managing greetings with support for multiple transport methods (stdio, HTTP, SSE).Last updated -