MCP Server Template (Python)
MCP Server Template (Python)
Минимальный шаблон сервера Model Context Protocol для Render. Форкните его, добавьте свои инструменты и разверните.
Что включено
Рабочий MCP-сервер с использованием MCP Python SDK с транспортом Streamable HTTP
Аутентификация по bearer-токену через
MCP_API_TOKEN(автоматически генерируется при деплое)Один пример инструмента (
hello) для демонстрации паттернаЭндпоинт
/healthдля проверок состояния RenderBlueprint
render.yamlдля развёртывания в один кликФайл
AGENTS.md, чтобы ИИ-ассистенты программирования могли создавать новые инструменты за вас
Примечание: Этот шаблон по умолчанию разворачивается на бесплатном тарифе. Бесплатные сервисы выключаются после 15 минут бездействия, что вызывает холодный запуск в течение 30–60 секунд при следующем запросе. MCP-клиенты могут не дождаться ответа из-за этой задержки. Для надёжного использования перейдите на платный тариф в Render Dashboard — тариф 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-токена. Blueprint Render автоматически генерирует случайный MCP_API_TOKEN при первом деплое.
Чтобы найти токен после развёртывания, перейдите в Render Dashboard > ваш сервис > Environment и скопируйте значение MCP_API_TOKEN.
Клиенты должны включать токен в заголовок Authorization:
Authorization: Bearer YOUR_TOKENКогда MCP_API_TOKEN не задан (например, во время локальной разработки), аутентификация отключена и все запросы пропускаются.
Управление токеном
После первичного развёртывания токен полностью в вашем управлении:
Смените его, обновив
MCP_API_TOKENв Render Dashboard в разделе Environment. Сервис автоматически перезапустится с новым значением.Сгенерируйте новый токен одним из способов:
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. Если вы используете ИИ-ассистента программирования (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