A Python-based server implementing the Model Context Protocol (MCP) that connects Claude and other AI assistants to Dungeons & Dragons 5e game information.
The Model Context Protocol (MCP) is a framework developed by Anthropic that enables AI assistants like Claude to communicate with external tools and services. This server leverages FastMCP, Anthropic's Python implementation of the protocol, to create a structured bridge between AI assistants and the D&D 5e API.
For a detailed explanation of MCP and how this project implements it, check out our blog article.
Clone this repository:
git clone https://github.com/yourusername/dnd-knowledge-navigator.git
cd dnd-knowledge-navigator
Install dependencies:
uv pip install -r requirements.txt
or
pip install .
Configure Claude Desktop (if using with Claude):
claude_desktop_config.json
file in your Claude Desktop configuration directory{
"mcpServers": {
"dnd": {
"command": "/path/to/uv",
"args": [
"--directory",
"/path/to/dnd-knowledge-navigator",
"run",
"dnd_mcp_server.py"
]
}
}
}
Run the server:
uv run python dnd_mcp_server.py
When connected to an AI assistant, the following tools are available:
search_all_categories
: Search across all D&D resources for specific termsverify_with_api
: Verify D&D statements against official API datacheck_api_health
: Check the health and status of the D&D 5e APIThe server includes a comprehensive source attribution system that:
The server includes a template system for formatting D&D content:
To disable templates, set TEMPLATES_ENABLED = False
in src/templates/config.py
.
The server includes a query enhancement system that improves search results:
To disable query enhancement, set parameters in the enhance_query
function to False
.
Comprehensive documentation is available in the docs/
directory:
The server maintains a local cache in the cache/
directory to minimize API calls and improve response time. This directory is excluded from git via .gitignore
.
Edit prompts.py
to modify or add new prompt templates, or resources.py
to adjust resource endpoints.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
The D&D Knowledge Navigator is organized as a Python package with the following structure:
dnd-knowledge-navigator/
├── dnd_mcp_server.py # Main server entry point
├── run_tests.py # Script to run all tests
├── setup.py # Package installation configuration
├── src/ # Source code directory
│ ├── __init__.py # Package initialization
│ ├── attribution/ # Source attribution system
│ ├── core/ # Core functionality
│ ├── query_enhancement/ # Query enhancement system
│ └── templates/ # Response formatting templates
├── tests/ # Test directory
│ ├── __init__.py # Test package initialization
│ └── test_*.py # Test files
└── docs/ # Documentation
For a more detailed explanation of the package structure, see Package Structure Documentation.
To install the package for development:
# Clone the repository
git clone https://github.com/yourusername/dnd-knowledge-navigator.git
cd dnd-knowledge-navigator
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install the package in development mode
pip install -e .
To start the D&D Knowledge Navigator server:
python dnd_mcp_server.py
To run all tests:
./run_tests.py
{
"mcpServers": {
"dnd": {
"env": {},
"args": [
"--directory",
"/path/to/dnd-knowledge-navigator",
"run",
"dnd_mcp_server.py"
],
"command": "uv"
}
}
}
Seamless access to top MCP servers powering the future of AI integration.