Skip to main content
Glama

MCP Server Basic Example

by ugundhar

MCP サーバーの基本例

これは、ツールやリソースなどのコア機能を示すモデル コンテキスト プロトコル (MCP) サーバー実装の基本的な例です。

セットアップ手順

  1. プロジェクトを初期化します (任意のローカル フォルダーに移動して、PowerShell または cmd を起動します)。
uv init mcp-server-basic cd mcp-server-basic
  1. 仮想環境を作成してアクティブ化する

uv venv .venv\Scripts\activate
  1. 依存関係をインストールします:
uv add "mcp[cli]"

または

uv add -r requirements.txt

特徴

サーバーは次の機能を実装します。

ツール

  • add(a: int, b: int) : 2つの数値を加算する
  • subtract(a: int, b: int) : 最初の数値から2番目の数値を引く

リソース

  • greeting://{name} : パーソナライズされた挨拶を返します

サーバーの実行

開発用に MCP Inspector を使用してサーバーを実行するには:

uv run mcp dev main.py

サーバーを通常どおり実行するには:

uv run mcp run

Claude デスクトップ アプリにサーバーをインストールするには:

uv run mcp install main.py

VSコードでのMCP接続

  • vscodeでフォルダ/mcp-server-basicを開く
  • ターミナルを開き、以下のコマンドを実行します。
uv run main.py
  • Cntrl+Shift+I をクリックして、VS Code でチャットを起動します。
  • Githubでログインしてセットアップする
  • 以下の手順に従ってください (VS Code ユーザー設定に MCP 構成を追加する 2 つの方法)。

#MCPからこんにちは

-
security - not tested
F
license - not found
-
quality - not tested

シンプルな算術ツールとグリーティング リソースを使用してコア機能をデモンストレーションするモデル コンテキスト プロトコル サーバーのサンプル実装。

  1. セットアップ手順
    1. 特徴
      1. ツール
      2. リソース
    2. サーバーの実行
      1. VSコードでのMCP接続

        Related MCP Servers

        • A
          security
          F
          license
          A
          quality
          A server that provides tools for performing basic arithmetic operations (addition, subtraction, multiplication, division) via the Model Context Protocol.
          Last updated -
          4
          JavaScript
          • Apple
        • A
          security
          A
          license
          A
          quality
          A Model Context Protocol server providing utility tools for development and testing, offering functionalities like personalized greetings, random card drawing, and datetime formatting with an extensible architecture.
          Last updated -
          19
          215
          2
          TypeScript
          MIT License
          • Apple
          • Linux
        • A
          security
          F
          license
          A
          quality
          A simple Model Context Protocol server that provides basic arithmetic operations (addition, subtraction, multiplication, division) as tools that can be called by Large Language Models.
          Last updated -
          4
          JavaScript
        • -
          security
          -
          license
          -
          quality
          A simple implementation of a Model Context Protocol server that demonstrates core functionality including mathematical tools (add, subtract) and personalized greeting resources.
          Last updated -
          3
          Python
          GPL 3.0

        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/ugundhar/mcp-server'

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