Lab 4 — Build the BookTracker MCP Server
Summary — what this page covers Attendees create
BookTracker.Mcpwith 3+ typed tools wired to real services, then connect it to Claude Code and invoke a tool live — committed. This is the moment Day 1 and Day 2 join up.
Duration: 30 min · Deliverable: BookTracker.Mcp with 3+ tools connected to Claude Code — committed
Part A — Scaffold the server (≈10 min)
Create the BookTracker.Mcp project, add the package, and configure the host with Streamable
HTTP transport. Reference the Core/Data projects and register the services/DbContext your tools
will use.
dotnet add BookTracker.Mcp package ModelContextProtocol
builder.Services.AddMcpServer().WithHttpTransport().WithToolsFromAssembly();
// + AddDbContext / register BookTracker services
app.MapMcp();
Part B — Define 3+ tools (≈10 min)
Define 3+ typed tools — e.g. search_books, get_reading_progress, add_book — each as an
attributed method that takes typed parameters and injects a real BookTracker service. Write a strong,
trigger-style description on each (this is what makes the model call them reliably). Reuse
existing services; don't reimplement query logic.
Part C — Connect to Claude Code (≈10 min)
Register the running server with Claude Code, confirm it's connected, and invoke a tool:
claude mcp add --transport http booktracker http://localhost:5000/mcp
claude mcp list # should show: booktracker - connected
Then ask Claude Code something like "Search BookTracker for books about space" and watch your
search_books tool execute against the real database.
Checkpoint
-
BookTracker.Mcpbuilds and runs - 3+ tools defined with typed schemas and clear descriptions
- Tools call real BookTracker services
- Claude Code lists and successfully invokes a tool
- Committed to your fork
Bonus — Production MCP Deployment
No time pressure. Take the server toward production: containerize it (Dockerfile), add authentication (require a token) and audit logging (one entry per tool call), and write a short deployment path doc — how a teammate would run it and point Claude Code at it.