python-mcp-server-generator
Qué hace
Este programa crea un 'servidor' en Python que permite a otras IAs (como Claude) usar funciones que tú defines. Expone tus funciones, una base de datos o una API para que la IA pueda interactuar con ellas.
Cuándo usarla
- ✓Cuando quieres que una IA acceda a datos de una base de datos.
- ✓Cuando quieres que una IA ejecute una función específica en tu ordenador.
- ✓Cuando quieres crear un puente entre una IA y una API existente.
Link de la skill
https://github.com/github/awesome-copilot/blob/main/skills/python-mcp-server-generator/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Crea un servidor en Python que me permita dividir números usando IA.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
Escribes código en Python que define las funciones que la IA puede usar. El programa organiza estas funciones y las prepara para que la IA pueda llamarlas y recibir resultados.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
Python MCP Server Generator
Create a Model Context Protocol (MCP) server in Python with the official MCP Python SDK v2. SDK v2 supports the MCP specification revision 2026-07-28. The same server also serves clients that use earlier revisions.
Workflow
Copy this checklist and track your progress:
- Step 1: Create the project.
- Step 2: Write the server.
- Step 3: Write the tests.
- Step 4: Run the tests until they pass.
- Step 5: Configure the client.
Step 1: Create the project
Run these commands:
uv init --app --no-package project-name
cd project-name
uv add "mcp[cli]>=2,<3"
uv add --dev pytest
Then delete main.py. The server goes in server.py.
- Without
--no-package, uv makes asrc/package layout, and the tests cannot importserver.py. uv initmakes the.gitignorefile. Do not write a different one.
Step 2: Write the server
Start from this template:
from mcp.server import MCPServer
from mcp.server.mcpserver.exceptions import ToolError
mcp = MCPServer("Demo", version="0.1.0")
@mcp.tool()
def divide(a: float, b: float) -> float:
"""Divide a by b."""
if b == 0:
raise ToolError("b must not be zero.")
return a / b
if __name__ == "__main__":
mcp.run() # stdio is the default transport
Then change the template for the request of the user:
- Replace
dividewith the tools that the user needs. - Give each tool full type hints and a docstring. The SDK makes the input schema from the type hints. The docstring becomes the tool description.
- Return a Pydantic model or a
TypedDictwhen the client needs machine-readable data. The SDK makes the output schema from the return type. - Use
async deffor I/O. The SDK runs a sync tool on a worker thread. - Mark a read-only tool with
@mcp.tool(annotations=ToolAnnotations(read_only_hint=True))(frommcp.types). Usedestructive_hint=Truefor a destructive tool. - Add resources (
@mcp.resource("users://{user_id}")) and prompts (@mcp.prompt()) only when the user asks for them.
Use stdio by default. Read references/streamable-http.md only when the user asks for a remote server or an HTTP server.
Step 3: Write the tests
Put test_server.py next to server.py. Write a test for each tool and for each ToolError:
import pytest
from mcp import Client
from server import mcp
@pytest.mark.anyio
async def test_divide():
async with Client(mcp) as client:
result = await client.call_tool("divide", {"a": 6, "b": 3})
assert result.structured_content == {"result": 2.0}
@pytest.mark.anyio
async def test_divide_by_zero():
async with Client(mcp) as client:
result = await client.call_tool("divide", {"a": 1, "b": 0})
assert result.is_error
assert "must not be zero" in result.content[0].text
- The in-memory
Clientneeds no subprocess and no port. It connects with the 2026-07-28 revision. - The
mcppackage installsanyio, which supplies theanyiomarker. Do not addpytest-asyncio.
Step 4: Run the tests until they pass
- Run
uv run pytest. - If a test fails, read the error. Fix the server or the test.
- Run
uv run pytestagain. - Continue only when all tests pass.
Step 5: Configure the client
For VS Code, write .vscode/mcp.json:
{
"servers": {
"demo": {
"type": "stdio",
"command": "uv",
"args": ["--directory", "/absolute/path/to/project", "run", "server.py"]
}
}
}
For Claude Desktop, run uv run mcp install server.py.
Tell the user these commands:
uv run server.pystarts the stdio server. The server waits for a host on stdin and prints nothing.uv run mcp dev server.pyopens the MCP Inspector. The Inspector needs Node.js.
Gotchas
SDK v2 and the 2026-07-28 revision changed many SDK v1 patterns. Do not copy SDK v1 examples.
- SDK v2 removed
FastMCPandmcp.server.fastmcp. Import the server class withfrom mcp.server import MCPServer. - Import
Context,Image,Audio,Resolve,Elicit,ElicitationResult,AcceptedElicitation,Message,UserMessage, andAssistantMessagefrommcp.server.mcpserver.
…
Preguntas frecuentes
¿Qué es MCP?
MCP significa Model Context Protocol (Protocolo de Contexto de Modelo). Es una forma estandarizada para que los programas (servidores) y las IAs se comuniquen entre sí.
¿Qué es un 'servidor' en este contexto?
Es un programa que 'escucha' y está listo para recibir peticiones de la IA, realizar tareas y devolver resultados.
¿Puedo usar esto para crear un cliente de IA?
No, este programa sirve para crear el 'servidor' que usará la IA, no el programa en el que se ejecuta la propia IA.
Detalles
Descripción original del autor
Use this skill when the user wants to create a new Model Context Protocol (MCP) server in Python. Also use it to expose Python functions, an API, or a database to AI clients as MCP tools. The skill makes a uv project with the MCP Python SDK v2 (MCPServer), typed tools, in-memory tests, and client configuration. Do not use it for an MCP client or for a server in another language.
repo: github/awesome-copilot
Popularidad
- Estrellas en GitHub
- 40 mil
- Posición en el ranking
- #7351
- Licencia
- MIT
- Actualizada
- 15/10/2026
Comentarios
- …
Más skills de este repositorio
acquire-codebase-knowledge
40 milAyuda a tu agente a entender y documentar un proyecto de código existente. Es útil para incorporar a nuevas personas o tener una visión general de la arquitectura.
acreadiness-assess
40 milPermite a tu agente evaluar qué tan preparado está un proyecto para la IA y generar un informe. Es útil para saber qué tan bien está listo un proyecto para usar herramientas de IA.
acreadiness-generate-instructions
40 milAyuda a tu agente a crear instrucciones para herramientas de IA basadas en una evaluación. Es útil para mejorar cómo la IA interactúa con el código y cerrar las brechas detectadas.
acreadiness-policy
40 milPermite a tu agente ayudar a definir o aplicar políticas para la evaluación de proyectos de IA. Es útil para estandarizar cómo se evalúan los proyectos y garantizar el cumplimiento.
Skills parecidas
add-model-provider
394 milPermite que tu agente conecte un nuevo proveedor de modelos de IA a OpenClaw con comandos de configuración seguros, mantenga las claves API fuera del texto plano y haga una prueba en vivo.
acp-router
394 milAyuda a tu agente a enviar una tarea a un asistente de programación como Claude Code o Cursor a través de OpenClaw, para que el trabajo se ejecute en esa herramienta.
browser-automation
394 milEnseña a tu agente a controlar páginas web paso a paso, incluidos los inicios de sesión, las pestañas y la recuperación cuando una página deja de responder.