Skip to main content
Glama
jhj0517

MCP Python Tutorial

by jhj0517

MCP Pythonチュートリアル

鍛冶屋のバッジモックデータを備えたシンプルなローカル DB を使用した Python の MCP チュートリアル アプリ

インストールと実行

Smithery経由でインストール

Smithery経由で Claude Desktop 用の Python MCP チュートリアル サーバーを自動的にインストールするには:

npx -y @smithery/cli install @jhj0517/mcp-python-tutorial --client claude

手動インストール

  1. このリポジトリをクローンする

  2. 依存関係をインストールします:

pip install -r requirements.txt
  1. MCP サーバーを開発モードで実行します。

mcp dev localdb_app.py
  1. MCPサーバーのデフォルトポートは5173です。http http://localhost:5173にアクセスしてください。

Related MCP server: xmcp Demo Application

MCPの機能

このチュートリアルアプリは、MCPのコアコンセプトを実証します。tutorial_app /mcp_server.pyでロールごとのアノテーションを確認できます。

@mcp.resource

基本的に、このアノテーションは、RESTAPI のGETと同様に、エージェントがリソースを「取得」することに関するものです。

  • users://all - すべてのユーザーを取得

  • users://{user_id}/profile - ユーザーのプロフィールを取得する

  • posts://all - すべての投稿を取得する

  • posts://{post_id} - IDで投稿を取得する

@mcp.tool

これは、RESTAPI のPOSTと同様に、エージェントが新しいリソースを「生成」することです。

  • create_user - 新しいユーザーを作成する

  • create_post - 新しい投稿を作成する

  • search_posts - タイトルまたは内容で投稿を検索

@mcp.prompt

これは、LLM と便利にやりとりするための再利用可能なテンプレートです。

  • user_profile_analysis - ユーザーのプロフィールの分析を生成する

  • post_feedback - 投稿のフィードバックのための対話型プロンプト

[!NOTE] 詳細な注釈については、次をお読みください: https://github.com/modelcontextprotocol/python-sdk?tab=readme-ov-file#core-concepts

クライアントに接続中

MCPサーバーをセットアップしたら、MCPサーバーを使用してエージェントを構築するLLMクライアントが必要です。以下のガイドは、 Claude Desktopをクライアントとして接続する方法を説明します。

  1. Claude Desktopは、MCPサーバーの依存関係をインストールするためにuv使用します。まず、 uvをインストールします。

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  1. uvを使用して MCP サーバーの依存関係をインストールします。

# Create virtual environment and activate it
uv venv
.venv\Scripts\activate

uv pip install -r requirements.txt
  1. Claude Desktop のダウンロードはこちら:

  1. claude_desktop_config.jsonファイルを見つけるか作成します。場所は OS によって異なります。

  • ウィンドウズ:

C:\Users\%USER%\AppData\Roaming\Claude\claude_desktop_config.json
  • MacOS/Linux:

~/Library/Application\ Support/Claude/claude_desktop_config.json
  1. claude_desktop_config.jsonmcpServers属性を追加します。

{
    "mcpServers": {
        "local_db": {
            "command": "uv",
            "args": [
                "--directory",
                "/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
                "run",
                "localdb_app.py"
            ]
        }
    }
}

注: 複数のMCPサーバーを導入し、それぞれに専用の関心と専門知識を持たせることもできます。関心を分離することは、すべてを単一のMCPサーバーに実装するよりも効果的です。

  1. Claude Desktop を再起動します。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A minimal demonstration server showcasing MCP protocol capabilities including tools, resources, and prompts with basic examples like hello world functionality.
    2
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A demonstration MCP server showcasing the xmcp framework's structured approach to defining tools, prompts, and resources with automatic discovery from their respective directories.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    A Python-based MCP server demonstrating tools for math calculations, time retrieval, and echo messages, along with resources and prompt templates.
    -

Latest Blog Posts

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/jhj0517/mcp-python-tutorial'

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