Skip to main content
Glama

MCP サーバーの例

このリポジトリには、教育目的のモデルコンテキストプロトコル(MCP)サーバーの実装が含まれています。このコードは、様々なLLMクライアントと統合できる機能的なMCPサーバーの構築方法を示しています。

完全なチュートリアルを実行するには、 YouTube ビデオ チュートリアルを参照してください。

MCPとは何ですか?

MCP(モデル・コンテキスト・プロトコル)は、アプリケーションがLLMにコンテキストを提供する方法を標準化するオープンプロトコルです。MCPはAIアプリケーション用のUSB-Cポートのようなもので、AIモデルをさまざまなデータソースやツールに接続するための標準化された方法を提供します。

MCP図

主なメリット

  • LLMに直接接続できる、構築済みの統合のリストが増えています

  • LLMプロバイダーとベンダーを切り替える柔軟性

  • インフラストラクチャ内でデータを保護するためのベストプラクティス

Related MCP server: Optimized Memory MCP Server V2

アーキテクチャの概要

MCP は、ホスト アプリケーションが複数のサーバーに接続できるクライアント サーバー アーキテクチャに従います。

  • MCPホスト: Claude Desktop、IDE、またはMCPを介してデータにアクセスするAIツールなどのプログラム

  • MCPクライアント: サーバーとの1:1接続を維持するプロトコルクライアント

  • MCP サーバー: 標準化されたモデル コンテキスト プロトコルを通じて特定の機能を公開する軽量プログラム

  • データ ソース: MCP サーバーがアクセスできるローカル (ファイル、データベース) とリモート サービス (API) の両方

MCPコアコンセプト

MCP サーバーは、主に次の 3 種類の機能を提供できます。

  • リソース: クライアントが読み取ることができるファイルのようなデータ (API レスポンスやファイルの内容など)

  • ツール: LLM から呼び出せる関数 (ユーザーの承認が必要)

  • プロンプト: ユーザーが特定のタスクを達成するのに役立つ、事前に作成されたテンプレート

システム要件

  • Python 3.10以上

  • MCP SDK 1.2.0以上

  • uvパッケージマネージャー

はじめる

uv パッケージマネージャーのインストール

MacOS/Linuxの場合:

curl -LsSf https://astral.sh/uv/install.sh | sh

uvコマンドが確実に実行されるように、後でターミナルを再起動してください。

プロジェクトのセットアップ

  1. プロジェクトを作成して初期化します。

# Create a new directory for our project
uv init mcp-server
cd mcp-server

# Create virtual environment and activate it
uv venv
source .venv/bin/activate  # On Windows use: .venv\Scripts\activate

# Install dependencies
uv add "mcp[cli]" httpx
  1. サーバー実装ファイルを作成します。

touch main.py

サーバーの実行

  1. MCP サーバーを起動します。

uv run main.py
  1. サーバーが起動し、接続を受け入れる準備が整います

Claudeデスクトップに接続しています

  1. 公式サイトからClaude Desktopをインストールする

  2. MCP サーバーを使用するように Claude Desktop を構成します。

~/Library/Application Support/Claude/claude_desktop_config.jsonを編集します。

{
    "mcpServers": {
        "mcp-server": {
            "command": "uv",  # It's better to use the absolute path to the uv command
            "args": [
                "--directory",
                "/ABSOLUTE/PATH/TO/YOUR/mcp-server",
                "run",
                "main.py"
            ]
        }
    }
}
  1. Claudeデスクトップを再起動します

トラブルシューティング

サーバーが Claude Desktop によって取得されていない場合は、次の手順に従ってください。

  1. 設定ファイルのパスと権限を確認してください

  2. 設定内の絶対パスが正しいことを確認します

  3. UVが適切に設置され、アクセス可能であることを確認する

  4. Claude Desktopのログにエラーメッセージがないか確認してください

ライセンス

このプロジェクトはMITライセンスの下で提供されています。詳細はLICENSEファイルをご覧ください。

Available Tools

1 tool
get_docsA

Search the latest docs for a given query and library. Supports langchain, openai, and llama-index.

Args: query: The query to search for (e.g. "Chroma DB") library: The library to search in (e.g. "langchain")

Returns: Text from the docs

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes
libraryYes

TDQS

A4.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden for behavioral disclosure. It notes that the tool searches 'latest docs' and returns text, implying a read-only operation, but does not mention potential network dependency, error cases, or any side effects. This is adequate but not rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured: a one-sentence purpose statement followed by clear Args/Returns sections. Every sentence adds value, and information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 2-parameter tool with no output schema, the description provides sufficient context: purpose, supported libraries, parameter guidance, and return type. It lacks explicit error handling or formatting details, but these are not critical for this simple search tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must fully explain the parameters. It does so effectively with an Args section providing both meaning and examples for 'query' and 'library', plus listing supported library values in the main description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Search the latest docs for a given query and library.' It specifies the resource (docs), the verb (search), and scope (latest), and distinguishes from sibling Chroma DB tools by focusing on doc search for specific libraries.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description indicates when to use the tool (when searching docs for langchain, openai, or llama-index) through the list of supported libraries. However, it lacks explicit exclusions or alternative tool references, so it doesn't fully meet the 'when-not/alternatives' criterion.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool update
    • First observedget_docs

TDQS

B3.4/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The tool has a single, clear purpose of searching documentation for specific libraries.

Naming Consistency5/5

The single tool name 'get_docs' follows a clear verb_noun pattern. Since there is only one tool, consistency is inherently perfect with no deviations to evaluate.

Tool Count2/5

A single tool is too few for most server purposes, as it severely limits functionality and scope. This feels thin and incomplete for a documentation search server, which might benefit from additional tools like browsing documentation structure or getting library lists.

Completeness2/5

The tool surface is severely incomplete for a documentation search domain. It only supports searching text, with no tools for browsing, listing available libraries, or accessing documentation metadata, creating significant gaps that will hinder agent workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

Appeared in Searches