MCP Server Sample

MIT License
1

Integrations

  • References the MCP SDK available through PyPI, which is used to implement the server's functionality.

MCP サーバー サンプル

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

MCP サーバーの例

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

参考文献:

MCPとは何ですか?

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

主なメリット

  • LLMに直接接続できる、構築済みの統合のリストが増えています
  • LLMプロバイダーとベンダーを切り替える柔軟性
  • インフラストラクチャ内でデータを保護するためのベストプラクティス

アーキテクチャの概要

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パッケージマネージャー

インストール

Python プロジェクトに MCP を追加する Python プロジェクトを管理するには、uv を使用することをお勧めします。

UV 管理プロジェクトをまだ作成していない場合は、作成します。

uv init mcp-server-sample cd mcp-server-sample

次に、プロジェクトの依存関係に MCP を追加します。

uv add "mcp[cli]

あるいは、依存関係に pip を使用するプロジェクトの場合:

pip install "mcp[cli]"

スタンドアロン MCP 開発ツールの実行 uv で mcp コマンドを実行するには:

uv run mcp

クイックスタート

計算ツールといくつかのデータを公開するシンプルな MCP サーバーを作成しましょう。

# server.py from mcp.server.fastmcp import FastMCP # Create an MCP server mcp = FastMCP("Demo") # Add an addition tool @mcp.tool() def add(a: int, b: int) -> int: """Add two numbers""" return a + b # Add a dynamic greeting resource @mcp.resource("greeting://{name}") def get_greeting(name: str) -> str: """Get a personalized greeting""" return f"Hello, {name}!"

次のコマンドを実行すると、このサーバーを Claude Desktop にインストールしてすぐに操作することができます。

mcp install server.py

あるいは、MCP Inspector を使用してテストすることもできます。

mcp dev server.py

アントニオ・スカペラートが❤️を込めて作りました

ライセンス

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

-
security - not tested
A
license - permissive license
-
quality - not tested

さまざまな LLM クライアントと統合する機能的な MCP サーバーを構築する方法を示すモデル コンテキスト プロトコル サーバーの教育用実装。

  1. MCP サーバーの例
    1. MCPとは何ですか?
    2. アーキテクチャの概要
    3. MCPコアコンセプト
    4. システム要件
    5. ライセンス

Related MCP Servers

  • A
    security
    A
    license
    A
    quality
    A beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.
    Last updated -
    3
    9
    36
    JavaScript
    Apache 2.0
  • A
    security
    A
    license
    A
    quality
    An educational implementation of a Model Context Protocol server that demonstrates how to build a functional MCP server for integrating with various LLM clients like Claude Desktop.
    Last updated -
    1
    88
    Python
    MIT License
    • Apple
    • Linux
  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol (MCP) server that enables Claude or other LLMs to fetch content from URLs, supporting HTML, JSON, text, and images with configurable request parameters.
    Last updated -
    Python
    MIT License
  • -
    security
    -
    license
    -
    quality
    A specialized server that helps users create new Model Context Protocol (MCP) servers by providing tools and templates for scaffolding projects with various capabilities.
    Last updated -
    1
    TypeScript

View all related MCP servers

ID: t48j3ey546