Chapter 58: Building TutorClaw
You built one MCP tool in Chapter 57. Now you build a real product: TutorClaw, an AI tutor with 9 tools that teaches the rest of this book.
TutorClaw is the case study that ties Part 5 together. You design 9 tools, describe each one to Claude Code using the mcp-builder skill, steer the implementation, and verify the result. The same describe-steer-verify cycle from Chapter 57, scaled to a real product.
Everything runs locally. JSON files store learner state. Markdown files hold course content. Stripe is the one external service because monetization IS the product. No database servers, no cloud storage, no deployment infrastructure. You spend your time on product design, tool quality, context engineering, and agent identity, not SSL certificates and boto3 scripts.
📚 Teaching Aid
What You'll Learn
By the end of this chapter, you will have built a complete 9-tool MCP server, connected it to OpenClaw, tested it end-to-end from WhatsApp, added Stripe monetization, written a full pytest suite, and given your agent a distinct identity as a tutor.
What This Chapter IS
- Building a real OpenClaw product end-to-end (9 tools, monetization, identity)
- The describe-steer-verify workflow from Chapter 57, scaled to a full application
- Product thinking: tool design, context engineering, tier gating, agent personality
- Stripe integration as the one external service (test mode throughout)
What This Chapter Is NOT
- Not MCP basics (covered in Chapter 57)
- Not hand-written Python (Claude Code writes the code; you steer)
- Not infrastructure setup (no databases, cloud storage, or VPS deployment)
- Not the economics analysis (Chapter 59 covers unit economics in depth)
- Not the architecture decision history (Chapter 60 covers pivots and meta-lessons)
Teaching Aid
| # | Lesson | What You Build |
|---|---|---|
| 1 | The Application Blueprint | Product mental model via a designed tutoring session transcript |
| 2 | Designing the Tool Surface | 9-tool specification with input/output contracts and tier access rules |
| 3 | Build the State Tools | register_learner, get_learner_state, update_progress with JSON persistence |
| 4 | Build the Content Tools | get_chapter_content, get_exercises with local markdown files |
| 5 | Build the Pedagogy Tools | generate_guidance, assess_response with PRIMM-Lite teaching methodology |
| 6 | Build the Code and Upgrade Tools | submit_code (mock sandbox) and get_upgrade_url (mock Stripe) |
| 7 | The Full Cycle Test | All 9 tools in one server, 5-tool chain verified from WhatsApp |
| 8 | Expected vs Actual | Write acceptance criteria, test a PRIMM session, grade the gaps |
| 9 | The Agent's Instruction Manual | AGENTS.md that orchestrates 9 tools without code |
| 10 | Context Engineer Your Tools | Two-layer descriptions, NEVER statements, cross-tool references |
| 11 | The Test Suite | pytest suite for all 9 tools: valid, invalid, tier gating, state persistence |
| 12 | All Tests Green | Debug failures, add edge cases, achieve full green suite |
| 13 | Tier Gating | check_tier() enforcement, exchange counting, free vs paid access |
| 14 | Stripe Checkout | get_upgrade_url with real Stripe, webhook handler, test card payment |
| 15 | Test the Payment Flow | End-to-end free-to-paid upgrade via WhatsApp with Stripe test mode |
| 16 | The Shim Skill | PRIMM-Lite offline fallback when the MCP server is unreachable |
| 17 | The Dedicated Agent | SOUL.md and IDENTITY.md giving TutorClaw a distinct tutor personality |
| 18 | Route and Bind | Bind TutorClaw to a WhatsApp group; peer-based routing, not keywords |
| 19 | Harden and Polish | Input validation, error messages, structured JSON logging |
| 20 | Publish to ClawHub | ClawHub package manifest and publishing workflow |
| 21 | The Full Engine | Spec-vs-implementation audit, scaling roadmap preview |
| 22 | Chapter Quiz | 50 scenario-based questions across all 6 phases |
Six Phases
Phase 1: Blueprint (L1-L2) establishes the mental model: 9 tools, tier access, platform inversion. Design every tool on paper before writing a single line of code.
Phase 2: Local Build (L3-L8) builds all 9 tools using Claude Code and the mcp-builder skill. JSON for state, local files for content, mock auth. Each tool gets careful design time via describe-steer-verify.
Phase 3: The Harness (L9-L12) adds the context that makes 9 tools work together: AGENTS.md for orchestration, refined tool descriptions for accurate selection, and a pytest suite that proves everything works.
Phase 4: Monetize (L13-L15) adds the business layer: tier gating, Stripe checkout, and a complete free-to-paid upgrade flow. Stripe is the one external integration because monetization IS the product.
Phase 5: Identity and Polish (L16-L19) gives TutorClaw a personality: shim skill for offline resilience, SOUL.md and IDENTITY.md for agent identity, channel routing for scope, and hardening for production readiness.
Phase 6: Reflect and Ship (L20-L21) publishes to ClawHub and audits the complete system against the original design. Everything you built locally is the product. Database servers, cloud storage, and deployment are scaling challenges for later, not product challenges for now.
Prerequisites
- Chapter 57: Extend Your Claw with MCP (you have a working tutorclaw-mcp project with the mcp-builder skill)
- Part 4: Python proficiency (you drove the TDG cycle with Claude Code)
- Chapter 56: Meet Your Personal AI Employee (OpenClaw platform understanding)