Skip to main content
Lesson 5 of 18·7 min

Create a Tool

Lesson by lesson, your theme park agent is moving from "chatting from instructions" to reliably working with real-world data. In this lesson, you'll add the first missing building block: a tool the agent can use to translate a human park name into the canonical park ID.

You'll create a dedicated park lookup tool that queries a remote endpoint, validates inputs/outputs with schemas, and returns a small set of matches when the name is ambiguous. Then you'll test the tool directly in Mastra Studio, and finally wire it into your theme park agent so it can call the tool automatically during conversations.

This matters because every downstream Q Times request depends on having the correct park ID, not just a guessed park name. By validating the tool's return shape and inspecting tool calls in observability, you set up a dependable foundation for fetching live wait times next.

"Tools are for the moments your agent needs real context—like turning a park name into the one ID every other API call depends on."

— Guil Hernandez

Mentioned in the Lesson
Direct link to Mentioned in the Lesson

Code:

Relevant Mastra docs:

Join the Community
Direct link to Join the Community

Ask questions:

Follow Mastra:

  • X — follow Mastra for updates
  • YouTube — watch more tutorials
  • LinkedIn — follow for updates

Don’t miss the next Mastra lessons

Be notified the moment new lessons release and stay ahead of every update. We’ll email you about course improvements, new Mastra features, and upcoming live workshops. Unsubscribe anytime.