Exercise 1: Define tools with local operations (⏳ 5 min)
🎯 Goal: Help the AI agent provide details for how much a listing costs, how many beds it has, what type of location it is, what amenities are available and any photos. The AI agent should also be able to provide details for a specific listing when you ask for more details about it.
Claude prompts:
- "What are some listings I can stay at? Just give me a really quick summary of each like descriptions, number of beds and cost."
- "Tell me more about the Cozy Yurt in Mraza. I want to know where it is and how much it costs and anything else important I should know about."
Bonus!
As a bonus, write helpful tool descriptions for your tools. You can do this by adding a comment above the operation (prefixed by #) that says exactly what the tool does and if it requires any parameters. This will override the auto-generated description from your schema.
A note on writing tool descriptions
Tool descriptions help AI agents understand what the tool does and how to best use it. GraphQL's declarative nature and typed schema makes this easy. You can also:
- Provide verbose and clear GraphQL operation names (e.g.
GetFiveRecentIssuesvsGetIssues)) - Add a comment above the operation (prefixed by
#) that says exactly what the tool does and if it requires any parameters. This will override the auto-generated description from your schema.
For more information on writing tool descriptions, check out the following resources:
Check your work
💭 Hints
Note: If you update the mcp.yaml file, you'll need to restart the MCP server for the changes to take effect. You'll also need to restart the MCP Inspector.
✅ Solution
query GetFeaturedListings {featuredListings {idtitledescriptionnumOfBedscostPerNightlocationType}}
query GetListingDetails($listingId: ID!) {listing(id: $listingId) {idtitledescriptionnumOfBedscostPerNightlocationTypeamenities {namecategory}photoThumbnail}}
operations:source: localpaths:- ./operations/GetFeaturedListings.graphql- ./operations/GetListingDetails.graphql