-
Notifications
You must be signed in to change notification settings - Fork 5
chore: add snippet for prescribed tool with descriptions #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add snippet for prescribed tool with descriptions #79
Conversation
Signed-off-by: Ratnakar Asara <rasara@us.ibm.com>
Signed-off-by: Ratnakar Asara <rasara@us.ibm.com>
ddebrunner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice snippet, I think some minor cleanup to better introduce the concept, as it's totally new.
| @@ -0,0 +1,110 @@ | |||
| # Prescribed Tools with Descriptions | |||
|
|
|||
| This sample demonstrates how to use the `@tool` directive with prescribed operations that contains descriptions that can be used through to create MCP (Model Context Protocol) tools. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"prescribed tools"
"persisted operations"
are the terms
Not "prescribed operations"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to qualify "operation" as "GraphQL operation" (with a link to the spec) as the first mention.
|
|
||
| ## Overview | ||
|
|
||
| The sample implements a mock weather service API with a simple operations, Weather forecast for a city |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"simple operations"
Remove "simple", and there's only a single operation right?
| - The `@sdl` directive that includes persisted operations | ||
|
|
||
| 2. An operations file (`operations.graphql`) that contains: | ||
| - Documented GraphQL operations with descriptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Documented ... with descriptions" is redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a single operation though?
| # Prescribed Tools with Descriptions | ||
|
|
||
| This sample demonstrates how to use the `@tool` directive with prescribed operations that contains descriptions that can be used through to create MCP (Model Context Protocol) tools. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an overview of what a "prescribed tool" is would be essential at this point.
| ) | ||
| ``` | ||
|
|
||
| The operation itself can include descriptions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add "(new to GraphQL September 2025)"
| @@ -0,0 +1,183 @@ | |||
| schema | |||
| @sdl( | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a useful comment
| files: [] | ||
| executables: [{ document: "operations.graphql", persist: true }] | ||
| ) | ||
| @tool(name: "weather-lookup", prescribed: "WeatherForecast") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a useful comment
| }, | ||
| forecast: [ | ||
| { | ||
| date: forecastDates[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test is subject to failure if it's run around midnight
|
@asararatnakar Can you "refactor" this a little to just be how to define a prescribed tool, and drop the mentions of "with descriptions (i.e. put it in I think this is the way we want to encourage prescribed tool definitions, thus the "with descriptions" is not really important, though it is important that we show operations having descriptions. Then in the future I could see a "with descriptions" variant, that shows how descriptions in |
Signed-off-by: Ratnakar Asara <rasara@us.ibm.com>
ddebrunner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GTG - the link to persisted docs in the spec is wrong though
| @@ -0,0 +1,141 @@ | |||
| # Prescribed Tools | |||
|
|
|||
| A **prescribed tool** is a tool that maps to a specific [GraphQL operation](https://spec.graphql.org/September2025/#sec-Language.Operations) in a [persisted document](https://spec.graphql.org/September2025/#sec-Persisted-Documents). The `@tool(prescribed:)` argument links the tool definition to an operation name in a persisted document. This approach provides a structured way to expose specific GraphQL operations as tools that can be called by AI models. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
persisted document is not a GraphQL spec concept, at least not that spec, maybe a reference to the persisted snippet.
Description
This snippet shows how to use prescribed tool using
@tooldirective to define operations with descriptions.also demonstrates how these descriptions help create MCP tools that AI models can understand and use.