MCP Server Template (Python)
MCP Server Template (Python)
最小限の Model Context Protocol サーバーテンプレート(Render 用)です。フォークして、独自のツールを追加し、デプロイしてください。
含まれるもの
MCP Python SDK を使用した、Streamable HTTP トランスポート対応の MCP サーバー
MCP_API_TOKENによる Bearer トークン認証(デプロイ時に自動生成)パターンを示す 1 つのサンプルツール(
hello)Render のヘルスチェック用の
/healthエンドポイントワンクリックデプロイ用の
render.yamlBlueprintAI コーディングアシスタントが新しいツールの雛形を作成できるようにする
AGENTS.md
注: このテンプレートはデフォルトで無料プランでデプロイされます。無料サービスは 15 分間アイドル状態が続くとスピンダウンし、次のリクエスト時に 30 〜 60 秒のコールドスタートが発生します。この遅延の間に MCP クライアントがタイムアウトする可能性があります。確実に使用するには、Render ダッシュボードで 有料プラン にアップグレードしてください。Starter プランではサービスが継続的に稼働します。
Related MCP server: MCP Server Template (Python)
ローカルで始める
git clone https://github.com/render-examples/mcp-server-python.git
cd mcp-server-python
pip install -r requirements.txt
python server.pyサーバーは http://localhost:10000 で起動します。MCP エンドポイントは /mcp です。
テストの実行
pip install -r requirements.txt
pytest認証
サーバーは Bearer トークンを使用してリクエストを認証します。Render の Blueprint は初回デプロイ時にランダムな MCP_API_TOKEN を自動生成します。
デプロイ後にトークンを見つけるには、Render ダッシュボード > お使いのサービス > Environment に移動し、MCP_API_TOKEN の値をコピーしてください。
クライアントは Authorization ヘッダーにトークンを含める必要があります:
Authorization: Bearer YOUR_TOKENMCP_API_TOKEN が設定されていない場合(例: ローカル開発時)、認証は無効になり、すべてのリクエストが許可されます。
トークンの管理
最初のデプロイ後、トークンはお客様が管理できます:
ローテーションするには、Render ダッシュボードの Environment で
MCP_API_TOKENを更新します。サービスは新しい値で自動的に再起動します。新しいトークンを生成するには、次のいずれかを使用します:
openssl rand -base64 32python3 -c "import secrets; print(secrets.token_urlsafe(32))"パスワードマネージャーの生成機能(1Password、Bitwarden など)
トークンをソース管理にコミットしないでください。環境変数または
.envファイル(.gitignoreに含まれています)を使用してください。複数ユーザーまたは本番環境のセットアップでは、OAuth 2.1 へのアップグレードを検討してください。
MCP サーバーへの接続
Render にデプロイした後、MCP エンドポイントは次の場所で利用できます:
https://your-service-name.onrender.com/mcpCursor
プロジェクトの .cursor/mcp.json に追加します:
{
"mcpServers": {
"my-mcp-server": {
"url": "https://your-service-name.onrender.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}
}
}Claude Desktop
Claude Desktop の設定に追加します:
{
"mcpServers": {
"my-mcp-server": {
"type": "streamable-http",
"url": "https://your-service-name.onrender.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}
}
}Codex
codex mcp add --transport streamable-http \
--url https://your-service-name.onrender.com/mcp \
--header "Authorization: Bearer YOUR_TOKEN" \
my-mcp-serverまたは .codex/config.toml に追加します:
[mcp_servers.my-mcp-server]
url = "https://your-service-name.onrender.com/mcp"
http_headers = { Authorization = "Bearer YOUR_TOKEN" }ツールの追加
server.py 内の関数に @mcp.tool() を付けてデコレートすることで、ツールを追加します:
@mcp.tool()
def fetch_weather(city: str, units: str = "celsius") -> str:
"""Get the current weather for a city."""
# your implementation here
return f"Weather for {city}"docstring がツールの説明になり、MCP クライアントはそれを LLM に表示します。常に明確な説明を書いてください。
このリポジトリには
AGENTS.mdファイルが含まれています。AI コーディングアシスタント(Cursor、Copilot、Codex、Windsurf など)を使用している場合は、「新しいツールを追加」と依頼すると、AGENTS.mdの規則に自動的に従います。
プロジェクト構造
server.py MCP server with example tool and health check
requirements.txt Python dependencies
render.yaml Render Blueprint for deployment
.env.example Environment variable reference
tests/test_server.py Test suite (auth, health, tool calls)
pyproject.toml pytest configuration
AGENTS.md Instructions for AI coding assistants
CLAUDE.md Pointer to AGENTS.md for Claude Code詳細情報
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 Servers
- Flicense-qualityCmaintenanceA minimal MCP server template for Python with Streamable HTTP transport, bearer token authentication, and a hello tool, designed for deployment on Render.
- Flicense-qualityCmaintenanceA minimal MCP server template for Render with Streamable HTTP transport, bearer token authentication, and an example 'hello' tool. Enables developers to quickly scaffold and deploy their own MCP servers.
- Flicense-qualityCmaintenanceA minimal MCP server template for Render with Streamable HTTP transport, bearer token authentication, and an example 'hello' tool.
- Flicense-qualityCmaintenanceA minimal MCP server template for Render with Streamable HTTP transport, bearer token authentication, and an example 'hello' tool.
Related MCP Connectors
Primarily to be used as a template repository for developing MCP servers with FastMCP in Python, P…
An MCP server for Arcjet - the runtime security platform that ships with your AI code.
Remote ChromaDB vector database MCP server with streamable HTTP transport
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/truongvanhaoem-0111/mcp-server-python-msx1l7h1'
If you have feedback or need assistance with the MCP directory API, please join our Discord server