|
1 | 1 | # Advanced Tools |
| 2 | + |
| 3 | +In the previous exercise, you learned how to register simple tools and handle |
| 4 | +arguments using the Model Context Protocol (MCP). Now, you'll take things to the |
| 5 | +next level by building more realistic, stateful, and robust tools—tools that |
| 6 | +interact with a database, handle errors gracefully, and are organized for |
| 7 | +maintainability. |
| 8 | + |
| 9 | +In this exercise, you'll work on a journaling app called **EpicMe**. The app |
| 10 | +allows users to create and manage journal entries and tags. You'll expose these |
| 11 | +capabilities to clients through MCP tools, making it possible for users (and |
| 12 | +LLMs) to create tags, associate them with entries, and more—all through a |
| 13 | +standardized protocol. |
| 14 | + |
| 15 | +Here's what you'll encounter as you progress: |
| 16 | + |
| 17 | +- **Database Integration:** Instead of just returning static or computed values, |
| 18 | + your tools will now interact with a real database. This means you'll be able |
| 19 | + to persist and retrieve data, making your tools much more powerful and useful. |
| 20 | +- **Code Organization:** You'll refactor your code to keep tool definitions a |
| 21 | + bit more organized, moving them into a dedicated module. |
| 22 | +- **Class-based Server Structure:** You'll encapsulate your server and database |
| 23 | + logic in a class, preparing things for using Cloudflare's Durable Objects |
| 24 | + (my personal favorite way to build remote MCP servers). |
| 25 | +- **Robust Error Handling:** You'll add error handling to your tools, ensuring |
| 26 | + that clients receive clear feedback when something goes wrong, and that errors |
| 27 | + are surfaced in a way that's compatible with the MCP spec. |
| 28 | + |
| 29 | +By the end of this exercise, you'll have a solid foundation for building |
| 30 | +advanced, production-ready MCP tools that can power real applications. |
| 31 | + |
| 32 | +- 📜 [MCP Spec: Tools](https://modelcontextprotocol.io/specification/2025-03-26/server/tools) |
0 commit comments