Skip to content

Commit 1926518

Browse files
committed
more instructions
1 parent b5d09b4 commit 1926518

File tree

5 files changed

+84
-1
lines changed

5 files changed

+84
-1
lines changed

exercises/02.tools/FINISHED.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ interactive, AI-powered systems that can do real work for users.
77
With these skills, you can create all sorts of tools—calculators, data fetchers,
88
workflow automators, and more. The possibilities are wide open!
99

10-
Keep going—there's a lot more to explore and build!
10+
Keep going—there's a lot more to explore and build! We're going to take tools a
11+
little further.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
11
# Database
2+
3+
👨‍💼 Our users played around with our Math MCP server and it was fun, but they
4+
actually want to write journal entries with their LLM. So let's get
5+
our journaling app ready to store real data! In this step, you'll:
6+
7+
- Import and initialize the database for EpicMe.
8+
- Make sure your server is set up to use the database instance.
9+
10+
For this first tool, we're just going to allow users to create tags for their
11+
journal entries. The code comments should guide you through the steps of
12+
changing our math tool to a `create_tag` tool.
13+
14+
This will lay the groundwork for tools that can create and manage journal tags
15+
and entries.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
11
# Database
2+
3+
👨‍💼 Database is ready! Our users are now happily creating tags! Now your EpicMe
4+
app can store and retrieve real journal data, setting the foundation for all the
5+
features to come.
6+
7+
Key takeaways:
8+
9+
- You connected your MCP server to a persistent database, moving beyond
10+
in-memory or static data.
11+
- This unlocks the ability to build tools that interact with real user
12+
content—an essential step for any practical application.
13+
14+
<callout-success>
15+
The specifics of what happens in your callbacks is up to you!
16+
</callout-success>
17+
18+
Onward to building and exposing real journaling tools!
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
11
# Error Handling
2+
3+
Example error response:
4+
5+
```json
6+
{
7+
"jsonrpc": "2.0",
8+
"id": 2,
9+
"result": {
10+
"content": [
11+
{
12+
"type": "text",
13+
"text": "Entry with id 123 not found"
14+
}
15+
],
16+
"isError": true
17+
}
18+
}
19+
```
20+
21+
- [📜 MCP Spec: Errors](https://modelcontextprotocol.io/specification/2025-03-26/server/tools#error-handling)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
11
# 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

Comments
 (0)