Skip to content

Conversation

jcaudle
Copy link
Contributor

@jcaudle jcaudle commented Sep 23, 2025

Updated best practices and tool definition docs to reference and explain the use of SDL docstrings for improving tool descriptions. Added guidance and an example to help users document their GraphQL operations for better LLM integration.

Updated best practices and tool definition docs to reference and explain the use of SDL docstrings for improving tool descriptions. Added guidance and an example to help users document their GraphQL operations for better LLM integration.
@jcaudle jcaudle requested review from a team as code owners September 23, 2025 00:17
@apollo-librarian
Copy link

apollo-librarian bot commented Sep 23, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 3 changed, 0 removed
* (developer-tools)/apollo-mcp-server/(latest)/best-practices.mdx
* (developer-tools)/apollo-mcp-server/(latest)/config-file.mdx
* (developer-tools)/apollo-mcp-server/(latest)/define-tools.mdx

Build ID: cc65526d70e7908e54329e93
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/cc65526d70e7908e54329e93

Copy link
Contributor

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this! I have a couple of suggestions.


## 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apollo recommends adding docstrings to any tool you define so you can be sure your MCP tools are used appropriately.

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.

Comment on lines +245 to +250
# Get the detailed weather forecast for a given location
query GetForecast($coordinate: InputCoordinate!) {
forecast(coordinate: $coordinate) {
detailed
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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
# Get the detailed weather forecast for a given location
query GetForecast($coordinate: InputCoordinate!) {
forecast(coordinate: $coordinate) {
detailed
}
}
# Get the detailed weather forecast for a given location
query GetForecast(
# latitude and longitude
$coordinate: InputCoordinate!
) {
forecast(coordinate: $coordinate) {
detailed
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watson shared this code snippet as an example.

# Get the schema change proposals related to a given graph id
# If the count of proposals returned is less than the totalCount, use offset to paginate through the rest of proposals
query GetSchemaChangeProposals(
  $graphId: ID!
  # Valid values: "APPROVED", "CLOSED", "DRAFT", "IMPLEMENTED", "OPEN".
  # Default to ["OPEN"] if not provided.
  $filterByStatus: [ProposalStatus!]
  # Filter proposals to only affected subgraph names
  $filterBySubgraph: [String!]
  # Filter proposals to specific source variants
  $filterBySourceVariant: [String!]
  # Use for pagination
  $offset: Int
  # Defaults to 5, don't exceed 25
  $limit: Int = 5
) {
  graph(id: $graphId) {
    id
    name
    proposals(
      filterBy: { 
        status: $filterByStatus
        subgraphs: $filterBySubgraph
        sourceVariants: $filterBySourceVariant 
      }
      offset: $offset
      limit: $limit
    ) {
      totalCount
      proposals {
        id
        createdAt
        activities {
          nodes {
            activity
            createdAt
          }
        }
        status
        displayName
      }
    }
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

The 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants