Exercise 2: MCP: Trivia + Images Servers¶
Connect Claude to two MCP servers: one for trivia questions and one for Wikipedia images.
Lab: Lab 03 overview
Visual identity
The Lab 03 starter is a fresh codebase — the theme you built in Lab 02 is not present. Before the exercises below, ask Claude to re-apply your visual identity: "Apply our visual identity from CLAUDE.md to @src/templates/play.html and @src/static/style.css."
Theory: MCP (Model Context Protocol)
What it is. An open standard for connecting AI tools to external data sources. Your starter includes two MCP servers: trivia-content and wiki-images.
Configuration in .claude/settings.json:
{
"mcpServers": {
"trivia-content": {
"command": "uv",
"args": ["run", "python", "mcp_server/trivia_content_server.py"]
},
"wiki-images": {
"command": "uv",
"args": ["run", "python", "mcp_server/wiki_images_server.py"]
}
}
}
Gotcha. No internet? Switch to mcp_server/trivia_content_server_offline.py (trivia) and mcp_server/wiki_images_server_offline.py (images), same tool names with canned data.
Key commands: /mcp (list tools), claude mcp add <name> --command <cmd>
Further reading: Connect Claude Code to tools via MCP
Hands-on¶
Template prompts are scaffolding
Use the sample prompts below as a baseline, then adapt topic, constraints, and voice to your own concept so your quiz content does not look like everyone else's.
Part 1: Register the MCP Servers¶
- Run
/exitto close Claude, then run these two commands from thestarter/directory:This saves the config toclaude mcp add trivia-content -s project -- uv run python mcp_server/trivia_content_server.py claude mcp add wiki-images -s project -- uv run python mcp_server/wiki_images_server.py.mcp.jsonin the project root (project-scoped). Relaunchclaude. - Run
/mcp. You will see both server names (trivia-contentandwiki-images). Click a server name to expand it and see its status and the list of tools it exposes, with name and description for each.
Part 2: Fetch Real Trivia¶
- Ask:
- No quiz yet? First:
Create a quiz called "<theme>" with topic "<topic>" using POST /quizzes.
Part 3: Add Images¶
The API persists an optional image_url on each question (src/schemas/quiz.py). Claude can set it when calling POST /quizzes/{id}/questions so the URL is stored with the question, not only in chat.
- Ask:
Missing endpoints?
Some API routes may be absent — for example, a route to update image_url on an existing question. If Claude encounters a 404 or method-not-allowed error, ask it to investigate and add the missing route. This is an intentional gap in the starter.
Part 4: Reflect¶
- Ask Claude to list every MCP tool call it made in this session.
No internet?
Use offline servers:
- trivia: "args": ["mcp_server/trivia_content_server_offline.py"]
- images: "args": ["mcp_server/wiki_images_server_offline.py"]
Checkpoint
- [x]
/mcpshows both servers - [x] Quiz 1 has real trivia fetched via MCP
- [x] Questions have image URLs
- [x] Both MCP tools were called at least once