El Oráculo del Mazmorrero
MCP server for Dungeons & Dragons that provides tools for dice rolling, monster generation, inventory management, and AI-powered combat narration, plus resources and prompts.
README
El Oráculo del Mazmorrero
Práctica guiada (≈ 90–120 min) para construir tu primer servidor MCP en Python y conectarlo a Cursor, incluyendo una tool que llama al proxy de Azure OpenAI del curso.
| Primitiva | Qué construyes |
|---|---|
| Tools | tirar_dados, generar_monstruo, gestionar_inventario, narrar_combate_ia |
| Resources | oraculo://pregunta/{id} |
| Prompts | crear_personaje |
Requisitos
- Python 3.10+
- Cursor con soporte MCP
- Credenciales del proxy: URL (
AZURE_PROXY_ENDPOINT) y API key (AZURE_PROXY_KEY)
1. Clonar y preparar el entorno
git clone <url-de-este-repo>
cd practica_mcp_dungeons_and_dragons # o el nombre de la carpeta clonada
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
2. Explorar el servidor
Abre server.py. Está organizado en bloques:
- Tools locales — dados, monstruos, inventario (sin red).
- Resource — oráculo de solo lectura.
- Prompt — plantilla para crear un personaje.
- Tool con IA —
narrar_combate_iallama al proxy conhttpx(async).
Las credenciales nunca van en el código: se leen de variables de entorno.
3. Probar en aislamiento (MCP Inspector)
Con el venv activo:
mcp dev server.py
Checkpoint: debes ver 4 tools, 1 resource y 1 prompt.
Para probar narrar_combate_ia en el Inspector, exporta antes:
export AZURE_PROXY_ENDPOINT="https://tu-proxy/v1/chat/completions"
export AZURE_PROXY_KEY="tu-api-key"
mcp dev server.py
4. Conectar a Cursor
- Copia la plantilla de configuración:
cp .cursor/mcp.json.example .cursor/mcp.json
-
Edita
.cursor/mcp.jsony reemplaza:- Las rutas absolutas a
.venv/bin/pythony aserver.py AZURE_PROXY_ENDPOINTyAZURE_PROXY_KEYcon las del curso
- Las rutas absolutas a
-
Reinicia Cursor o ve a Settings → Tools & MCP y confirma el indicador verde.
-
En el chat del Agente, prueba:
Tira 2 dados de 20 caras para mi ataque.
Genera un monstruo de dificultad difícil para mi próximo encuentro.
Agrega "espada legendaria" a mi inventario y luego muéstrame qué tengo.
Narra con IA un combate entre mi héroe Aria y un Dragón juvenil, resultado: crítico.
5. Retos (elige al menos 2)
- Tool
curar_heroe(puntos)— rechaza negativos. - Persistencia del inventario en
inventario.json. - Resource
bestiario://listacon el bestiario en JSON. - Parámetro opcional
tonoennarrar_combate_ia(epico/comico/oscuro). - Un reintento si el proxy hace timeout.
Seguridad (imprescindible)
- No hardcodees la API key en
server.py. - No subas
.cursor/mcp.jsoncon secretos (ya está en.gitignore). Usamcp.json.example. - Valida parámetros de entrada antes de llamar APIs externas.
- No ejecutes servidores MCP de fuentes no verificadas sin revisar el código.
Solución de problemas
| Síntoma | Qué revisar |
|---|---|
| Servidor no aparece en Cursor | Rutas absolutas en mcp.json |
ModuleNotFoundError: mcp / httpx |
Que command apunte a .venv/bin/python |
Variables faltantes en narrar_combate_ia |
Bloque env de mcp.json |
| Error HTTP 4xx/5xx del proxy | URL, formato del body y contrato del proxy del curso |
Verificación rápida (sin Cursor)
source .venv/bin/activate
python scripts/smoke_test.py
Confirma que se registran las 4 tools, el resource y el prompt, e invoca las tools locales.
Guía completa de la clase
El guion pedagógico paso a paso está en PRACTICA.md (contexto, conceptos, rúbrica y discusión de seguridad).
Estructura del repo
.
├── server.py # Servidor MCP (FastMCP)
├── requirements.txt # mcp, httpx
├── PRACTICA.md # Guion completo de la clase
├── scripts/
│ └── smoke_test.py # Verificación local sin Cursor
├── .cursor/
│ └── mcp.json.example # Plantilla sin secretos
├── .env.example # Variables de entorno de ejemplo
├── .gitignore
└── README.md
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.