MCP Server Template (Python)
Plantilla de servidor MCP (Python)
Una plantilla de servidor mínima de Model Context Protocol para Render. Haz un fork, añade tus propias herramientas y despliega.
Qué incluye
Un servidor MCP funcional que utiliza el MCP Python SDK con transporte HTTP Streamable
Autenticación mediante token Bearer a través de
MCP_API_TOKEN(generado automáticamente al desplegar)Una herramienta de ejemplo (
hello) para mostrar el patrónUn endpoint
/healthpara las comprobaciones de salud de RenderUn Blueprint
render.yamlpara el despliegue con un clicUn
AGENTS.mdpara que los asistentes de programación con IA puedan crear nuevas herramientas por ti
Nota: Esta plantilla se despliega en el plan gratuito por defecto. Los servicios gratuitos se apagan después de 15 minutos de inactividad, lo que provoca arranques en frío de 30 a 60 segundos en la siguiente solicitud. Los clientes MCP pueden agotar el tiempo de espera durante esta demora. Para un uso fiable, actualiza a un plan de pago en el Render Dashboard — el plan Starter mantiene tu servicio en funcionamiento continuo.
Related MCP server: MCP Server Template (Python)
Primeros pasos en local
git clone https://github.com/render-examples/mcp-server-python.git
cd mcp-server-python
pip install -r requirements.txt
python server.pyEl servidor arranca en http://localhost:10000. El endpoint MCP está en /mcp.
Ejecutar las pruebas
pip install -r requirements.txt
pytestAutenticación
El servidor autentica las solicitudes mediante un token Bearer. El Blueprint de Render genera automáticamente un MCP_API_TOKEN aleatorio en el primer despliegue.
Para encontrar tu token después de desplegar, ve a Render Dashboard > tu servicio > Entorno y copia el valor de MCP_API_TOKEN.
Los clientes deben incluir el token en la cabecera Authorization:
Authorization: Bearer YOUR_TOKENCuando MCP_API_TOKEN no está configurado (p. ej., durante el desarrollo local), la autenticación está deshabilitada y se permiten todas las solicitudes.
Gestión de tu token
Después del despliegue inicial, el token es tuyo y puedes gestionarlo:
Rota el token actualizando
MCP_API_TOKENen el Render Dashboard, en la sección Entorno. El servicio se reinicia automáticamente con el nuevo valor.Genera un nuevo token con cualquiera de estos métodos:
openssl rand -base64 32python3 -c "import secrets; print(secrets.token_urlsafe(32))"El generador de un gestor de contraseñas (1Password, Bitwarden, etc.)
No hagas commit de los tokens al control de versiones. Usa variables de entorno o archivos
.env(que están en.gitignore).Para configuraciones multiusuario o de producción, considera actualizar a OAuth 2.1.
Conexión a tu servidor MCP
Después de desplegar en Render, tu endpoint MCP está disponible en:
https://your-service-name.onrender.com/mcpCursor
Añade lo siguiente al .cursor/mcp.json de tu proyecto:
{
"mcpServers": {
"my-mcp-server": {
"url": "https://your-service-name.onrender.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}
}
}Claude Desktop
Añade lo siguiente a la configuración de 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-serverO añade lo siguiente a .codex/config.toml:
[mcp_servers.my-mcp-server]
url = "https://your-service-name.onrender.com/mcp"
http_headers = { Authorization = "Bearer YOUR_TOKEN" }Añadir herramientas
Añade herramientas a server.py decorando una función con @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}"El docstring se convierte en la descripción de la herramienta, que los clientes MCP muestran a los LLM. Escribe siempre una descripción clara.
Este repositorio incluye un archivo
AGENTS.md. Si usas un asistente de programación con IA (Cursor, Copilot, Codex, Windsurf, etc.), puedes pedirle que "añada una nueva herramienta" y seguirá automáticamente las convenciones deAGENTS.md.
Estructura del proyecto
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 CodeMás información
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