Skip to main content
Glama
truongvanhaoem-0111

MCP Server Template (Python)

MCP Server Template (Python)

Минимальный шаблон сервера Model Context Protocol для Render. Форкните его, добавьте свои инструменты и разверните.

Что включено

  • Рабочий MCP-сервер с использованием MCP Python SDK с транспортом Streamable HTTP

  • Аутентификация по bearer-токену через MCP_API_TOKEN (автоматически генерируется при деплое)

  • Один пример инструмента (hello) для демонстрации паттерна

  • Эндпоинт /health для проверок состояния Render

  • Blueprint 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 32

    • python3 -c "import secrets; print(secrets.token_urlsafe(32))"

    • Генератор менеджера паролей (1Password, Bitwarden и т.д.)

  • Не коммитьте токены в систему контроля версий. Используйте переменные окружения или файлы .env (они указаны в .gitignore).

  • Для многопользовательских или производственных сред рассмотрите переход на OAuth 2.1.

Подключение к вашему MCP-серверу

После развёртывания на Render ваш MCP-эндпоинт доступен по адресу:

https://your-service-name.onrender.com/mcp

Cursor

Добавьте в .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

Подробнее

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • F
    license
    -
    quality
    C
    maintenance
    A minimal MCP server template for Python with Streamable HTTP transport, bearer token authentication, and a hello tool, designed for deployment on Render.
  • F
    license
    -
    quality
    C
    maintenance
    A 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.
  • F
    license
    -
    quality
    C
    maintenance
    A minimal MCP server template for Render with Streamable HTTP transport, bearer token authentication, and an example 'hello' tool.
  • F
    license
    -
    quality
    C
    maintenance
    A minimal MCP server template for Render with Streamable HTTP transport, bearer token authentication, and an example 'hello' tool.

View all related MCP servers

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

View all MCP Connectors

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/truongvanhaoem-0111/mcp-server-python-msx1l7h1'

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