Skip to main content
Lesson 8 of 18·7 min

Connect to MCP

You're at the point where the theme park agent can already pull park IDs and live wait times, but it's missing key planning info that isn't available in the QTimes JSON API. In this lesson, you'll extend the agent with an external tool source so it can answer questions like park hours and crowd forecasts.

You'll connect the agent to an MCP server, bring in web extraction tooling, and make those tools available alongside your existing local tools. Then you'll update the agent's guidance so it knows when to look up a park ID first and when to fetch structured details from a park's web page.

This matters because real-world assistants rarely get everything from a single API. By combining live API data with structured extraction from web pages—and adding a weather input when it's relevant—you turn the agent into something that can reliably fill information gaps without building one-off scrapers.

"Tool access alone doesn't guarantee the right behavior—you have to teach the agent when to use the tool, and why."

— 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.