EfeSenerr/demo_mcp_learn
If you are the rightful owner of demo_mcp_learn and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The LOTR MCP Demo is a project that integrates the Model Context Protocol with the Microsoft Agent Framework to create a collaborative AI system for generating Lord of the Rings-inspired poetry.
LOTR MCP Demo
A demonstration project showcasing Model Context Protocol (MCP) integration with the Microsoft Agent Framework. This project features multi-agent systems that bring Middle-earth to life through collaborative AI agents.
Features
- MCP Server: Custom MCP server (
lotr_mcp_server.py) that fetches authentic LOTR quotes from The One API - Two Unique Scenarios:
🎭 Poetry Collaboration (Default)
- Poet Agent: Generates four-line poems inspired by LOTR quotes
- Critic Agent: Reviews poems for accuracy, tone, and adherence to Middle-earth lore
- Iterative Refinement: Agents collaborate in a ping-pong pattern to refine poetry until approved
🕵️ Mystery Solving (New!)
- Sauron (Mystery Weaver): The Dark Lord crafts cryptic mysteries with hidden clues
- Gandalf the Grey (Detective): Wise wizard who analyzes clues and builds theories
- Bilbo Baggins (Investigator): Applies hobbit-sense and notices overlooked details
- Collaborative Investigation: Gandalf and Bilbo work together to solve Sauron's mysteries
Prerequisites
- Python 3.8+
- GitHub Personal Access Token (for GitHub Models API)
- The One API Key (from the-one-api.dev)
Setup
-
Install dependencies:
pip install -e . -
Create a
.envfile with your API keys:GITHUB_TOKEN=your_github_token ONE_API_KEY=your_one_api_key -
Run the demo:
Poetry Scenario (default):
python main.py # OR explicitly SCENARIO=poetry python main.pyMystery Scenario:
SCENARIO=mystery python main.pyOr in PowerShell:
$env:SCENARIO="mystery"; python main.py
Configuration
You can customize the behavior with environment variables:
SCENARIO: Choose betweenpoetryormystery(default:mystery)PING_PONG_LIMIT: Max iterations for poetry refinement (default:5)MYSTERY_MAX_TURNS: Max turns for mystery investigation (default:8)GITHUB_TOKEN: Your GitHub Personal Access TokenONE_API_KEY: Your The One API key
How It Works
Poetry Scenario Flow
- The Poet agent calls the MCP tool to fetch a random LOTR quote
- It paraphrases the quote and composes a four-line poem
- The Critic agent reviews the poem for lore accuracy and quality
- If revisions are needed, the Poet refines the poem based on feedback
- The cycle continues until the Critic approves or the iteration limit is reached
Mystery Scenario Flow
- Sauron uses the MCP tool to fetch a LOTR quote for inspiration
- Sauron crafts a dark mystery with 3-5 hidden clues set in Middle-earth
- Gandalf receives the mystery and begins analysis, forming theories
- Gandalf and Bilbo take turns investigating:
- Gandalf applies wizard wisdom and lore knowledge
- Bilbo notices practical details and challenges assumptions
- When Gandalf proposes a solution, Bilbo verifies it
- If both agree, the mystery is solved! Otherwise, investigation continues
Project Structure
lotr_mcp_server.py- MCP server implementation for fetching LOTR quotesmain.py- Multi-agent orchestration with both scenariospyproject.toml- Project dependencies and metadata.github/agents/- Agent personality definitions:Sauron.md- The Mystery WeaverGandalf.md- The Wise DetectiveBilboBot.md- The Observant Investigator
Agent Personalities
Sauron the Mystery Weaver 🌋
- Temperature: 0.9 (highly creative)
- Role: Creates cryptic mysteries with hidden clues
- Style: Dark, ominous, master of deception
Gandalf the Grey 🧙
- Temperature: 0.7 (balanced reasoning)
- Role: Lead detective and lore expert
- Style: Wise, methodical, shares reasoning process
Bilbo Baggins 🍃
- Temperature: 0.6 (grounded and practical)
- Role: Observant investigator with hobbit-sense
- Style: Friendly, detail-oriented, draws on adventure experience
Example Output
Mystery Scenario:
🌋 Sauron weaves a dark mystery...
"In the halls of Imladris, three artifacts have vanished..."
🧙 Gandalf analyzes the clues...
THEORY: The disappearance aligns with the lunar cycle...
🍃 Bilbo observes...
OBSERVATION: But wait, the smallest artifact wouldn't fit through...
✅ Mystery solved!