MCP Python Tutorial
MCP Pythonチュートリアル
モックデータを備えたシンプルなローカル DB を使用した Python の MCP チュートリアル アプリ
インストールと実行
Smithery経由でインストール
Smithery経由で Claude Desktop 用の Python MCP チュートリアル サーバーを自動的にインストールするには:
npx -y @smithery/cli install @jhj0517/mcp-python-tutorial --client claude手動インストール
このリポジトリをクローンする
依存関係をインストールします:
pip install -r requirements.txtMCP サーバーを開発モードで実行します。
mcp dev localdb_app.pyMCPサーバーのデフォルトポートは
5173です。httphttp://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をクライアントとして接続する方法を説明します。
Claude Desktopは、MCPサーバーの依存関係をインストールするために
uv使用します。まず、uvをインストールします。
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"uvを使用して MCP サーバーの依存関係をインストールします。
# Create virtual environment and activate it
uv venv
.venv\Scripts\activate
uv pip install -r requirements.txtClaude Desktop のダウンロードはこちら:
claude_desktop_config.jsonファイルを見つけるか作成します。場所は OS によって異なります。
ウィンドウズ:
C:\Users\%USER%\AppData\Roaming\Claude\claude_desktop_config.jsonMacOS/Linux:
~/Library/Application\ Support/Claude/claude_desktop_config.jsonclaude_desktop_config.jsonにmcpServers属性を追加します。
{
"mcpServers": {
"local_db": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
"run",
"localdb_app.py"
]
}
}
}注: 複数のMCPサーバーを導入し、それぞれに専用の関心と専門知識を持たせることもできます。関心を分離することは、すべてを単一のMCPサーバーに実装するよりも効果的です。
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.
This server cannot be installed
Maintenance
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
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA minimal demonstration server showcasing MCP protocol capabilities including tools, resources, and prompts with basic examples like hello world functionality.2MIT
- FlicenseNot gradedqualityDmaintenanceA demonstration MCP server showcasing the xmcp framework's structured approach to defining tools, prompts, and resources with automatic discovery from their respective directories.-
- FlicenseNot gradedqualityDmaintenanceA Python-based MCP server demonstrating tools for math calculations, time retrieval, and echo messages, along with resources and prompt templates.-
- FlicenseCqualityCmaintenanceA simple MCP server demonstrating resources, tools, and prompts using a local task list. It enables reading, creating, and analyzing tasks through MCP.1-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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