-
Notifications
You must be signed in to change notification settings - Fork 45
Add section on SDL docstrings for tool definitions #376
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -233,4 +233,19 @@ | |||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
```sh title="Example command using introspection" | ||||||||||||||||||||||||||||||||
apollo-mcp-server <path to the preceding config> | ||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
## Adding SDL Docstrings | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Apollo MCP Server also supports adding [SDL docstrings](apollo-server/schema/schema#descriptions-docstrings) to tool defintions. This form of documentation can make it easier for LLMs to determine which tool is best for any given prompt. Apollo recommends adding docstrings to any tool you define so you can be sure your MCP tools are used appropriately. | ||||||||||||||||||||||||||||||||
Check failure on line 240 in docs/source/define-tools.mdx
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Docstrings are a great way to provide more specific information about what your operations do than the default description provided by your GraphQL operation. Use this feature to describe the options available from the tool or explain why the operation is useful and your MCP client will be able to make better choices of which tool to use. | ||||||||||||||||||||||||||||||||
Check notice on line 242 in docs/source/define-tools.mdx
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
```graphql | ||||||||||||||||||||||||||||||||
# Get the detailed weather forecast for a given location | ||||||||||||||||||||||||||||||||
query GetForecast($coordinate: InputCoordinate!) { | ||||||||||||||||||||||||||||||||
forecast(coordinate: $coordinate) { | ||||||||||||||||||||||||||||||||
detailed | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+245
to
+250
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if the example operation shows that docstrings can also be added for input arguments.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Watson shared this code snippet as an example.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we add these to an operation / tool though, should it be referred to as docstrings? Technically they are comments |
||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||
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'm not sure this should be our primary guidance. In my view, it's more effective to encourage deverlops to write clear, descriptive schema documentation from the start. If the schema itself is well-documented, those descriptions can be leveraged across all MCP server instances, making additional docstrings less necessary. This approach also reinforces best practices in GraphQL, where thorough schema descriptions have always been the standard. I'd prefer we nudge users toward improving their schema documentation rather than relying on docstrings as a workaround.