5. Exercise 1: Define tools
1m

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 (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. 's declarative nature and typed schema makes this easy. You can also:

  • Provide verbose and clear (e.g. GetFiveRecentIssues vs GetIssues))
  • Add a comment above the (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:

  • Writing tools for agents
  • Best practices for tool definitions

Check your work

How much does the Cozy Yurt in Mraza cost?

💭 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

GetFeaturedListings operation
query GetFeaturedListings {
featuredListings {
id
title
description
numOfBeds
costPerNight
locationType
}
}
GetListingDetails operation
query GetListingDetails($listingId: ID!) {
listing(id: $listingId) {
id
title
description
numOfBeds
costPerNight
locationType
amenities {
name
category
}
photoThumbnail
}
}
mcp.yaml
operations:
source: local
paths:
- ./operations/GetFeaturedListings.graphql
- ./operations/GetListingDetails.graphql
Previous