Skip to content

Commit 3b8f7f2

Browse files
authored
Merge pull request #383 from apollographql/mm/docs-define-tools
Docs: Clarify examples for defining tools
2 parents 8db122d + 18d4509 commit 3b8f7f2

File tree

1 file changed

+25
-45
lines changed

1 file changed

+25
-45
lines changed

docs/source/define-tools.mdx

Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,25 @@ You can also use the `operations` option to specify a directory. The server then
4848

4949
Files and directories specified with `operations` are hot reloaded. When you specify a file, the MCP tool is updated when the file contents are modified. When you specify a directory, operations exposed as MCP tools are updated when files are added, modified, or removed from the directory.
5050

51-
### From Operation Collection
51+
### From an operation collection
5252

53-
For graphs managed by GraphOS, Apollo MCP Server can get operations from an [Operation Collection](https://www.apollographql.com/docs/graphos/platform/explorer/operation-collections).
53+
For graphs managed by GraphOS, Apollo MCP Server can get operations from an [operation collection](/graphos/platform/explorer/operation-collections).
5454

55-
To use a GraphOS Operation Collection, you must:
55+
To use a GraphOS operation collection, you must set your graph credentials `APOLLO_GRAPH_REF` and `APOLLO_KEY` as environment variables.
5656

57-
- Set `APOLLO_GRAPH_REF` and `APOLLO_KEY` environment variables for a GraphOS graph
57+
Use the `operations.source: collection` option to specify that tools should be loaded from an operation collection.
5858

59-
Each variant will have its own default MCP Tools Collection, but you can specify any shared collection by using `operations` with `operations.source: collection`.
60-
Apollo MCP Server automatically fetches the default collection if no ID is specified.
59+
Specify the collection to use with the `operations.id` option. To view the ID of a collection, click the ••• button next to its entry, select **View details**, and copy the **Collection ID**.
6160

62-
```yaml title="Example config file for using a GraphOS Operation Collection"
61+
Each graph variant has its own default collection called **Default MCP Tools**. To use this default collection, specify `operations.id: default`.
62+
63+
```yaml title="Example config file for using the default MCP Tools operation collection"
6364
operations:
6465
source: collection
65-
id: <collection-id>
66+
id: default
6667
```
6768
68-
The MCP Server supports hot reloading of the GraphOS Operation Collection, so it can automatically pick up changes from GraphOS without restarting.
69+
The MCP Server supports hot reloading of the GraphOS operation collection, so it can automatically pick up changes from GraphOS without restarting.
6970
7071
### From persisted query manifests
7172
@@ -75,34 +76,19 @@ Set the persisted query manifest file for the MCP Server with the `operations` o
7576

7677
An example manifest is available in the [GitHub repo](https://github.com/apollographql/apollo-mcp-server/tree/main/graphql/weather/persisted_queries).
7778

78-
<ExpansionPanel title="Example command using --manifest">
79-
80-
From the root of a local MCP Server repo, run the `apollo-mcp-server` binary with the example persisted query manifest, `graphql/weather/persisted_queries/apollo.json`:
81-
82-
```yaml title="Example config for using Persisted Query Manifest"
83-
headers:
84-
"apollographql-client-name": "my-web-app"
79+
```yaml title="Example config for using persisted query manifest"
8580
operations:
8681
source: manifest
87-
path: <absolute path to this local repo>/graphql/weather/persisted_queries/apollo.json
88-
schema:
89-
source: local
90-
path: <absolute path to this local repo>/graphql/weather/api.graphql
82+
path: <PATH/TO/persisted-queries-manifest.json>
9183
```
9284

93-
```sh showLineNumbers=false
94-
apollo-mcp-server <path to the preceding config>
95-
```
96-
97-
</ExpansionPanel>
98-
9985
### From GraphOS-managed persisted queries
10086

10187
For graphs managed by GraphOS, Apollo MCP Server can get operations by reading persisted queries from GraphOS. The MCP Server uses Apollo Uplink to access the persisted queries.
10288

103-
To use GraphOS persisted queries, you must:
89+
To use GraphOS persisted queries, you must set your graph credentials `APOLLO_GRAPH_REF` and `APOLLO_KEY` as environment variables.
10490

105-
- Set `APOLLO_GRAPH_REF` and `APOLLO_KEY` environment variables for a GraphOS graph
91+
Use the `operations.source: uplink` option to specify that tools should be loaded from GraphOS-managed persisted queries.
10692

10793
<Tip>
10894

@@ -111,17 +97,8 @@ Use a [contract variant](/graphos/platform/schema-management/delivery/contracts/
11197
</Tip>
11298

11399
```yaml title="Example config using GraphOS-managed persisted queries"
114-
headers:
115-
"apollographql-client-name": "my-web-app"
116100
operations:
117101
source: uplink
118-
schema:
119-
source: local
120-
path: <absolute path to this git repo>/graphql/weather/api.graphql
121-
```
122-
123-
```sh title="Example command using GraphOS-managed persisted queries"
124-
apollo-mcp-server <path to the preceding config>
125102
```
126103

127104
The MCP Server supports hot reloading of GraphOS-managed persisted queries, so it can automatically pick up changes from GraphOS without restarting.
@@ -130,16 +107,23 @@ If you register a persisted query with a specific client name instead of `null`,
130107

131108
Use the `headers` option when running the MCP Server to pass the header to the router. The default name of the header expected by the router is `apollographql-client-name`. To use a different header name, configure `telemetry.apollo.client_name_header` in router YAML configuration.
132109

110+
```yaml title="Example config using GraphOS-managed persisted queries" {1-2}
111+
headers:
112+
"apollographql-client-name": "my-web-app"
113+
operations:
114+
source: uplink
115+
```
116+
133117
## Introspection tools
134118

135119
In addition to defining specific tools for pre-defined GraphQL operations, Apollo MCP Server supports introspection tools that enable AI agents to explore the graph schema and execute operations dynamically.
136120

137121
You can enable the following introspection tools:
138122

139-
- `introspect` - allows the AI model to introspect the schema of the GraphQL API by providing a specific type name to get information about, and a depth parameter to determine how deep to traverse the subtype hierarchy. The AI model can start the introspection by looking up the top-level `Query` or `Mutation` type.
140-
- `search` - allows the AI model to search for type information by providing a set of search terms. This can result in fewer tool calls than `introspect`, especially if the desired type is deep in the type hierarchy of the schema. Search results include all the parent type information needed to construct operations involving the matching type.
141-
- `validate` - validates a GraphQL operation against the schema without executing it. This allows AI models to verify that their operations are syntactically correct and conform to the schema before execution, preventing unintended side effects. Operations should be validated prior to calling the `execute` tool.
142-
- `execute` - executes an operation on the GraphQL endpoint
123+
- `introspect`: allows the AI model to introspect the schema of the GraphQL API by providing a specific type name to get information about, and a depth parameter to determine how deep to traverse the subtype hierarchy. The AI model can start the introspection by looking up the top-level `Query` or `Mutation` type.
124+
- `search`: allows the AI model to search for type information by providing a set of search terms. This can result in fewer tool calls than `introspect`, especially if the desired type is deep in the type hierarchy of the schema. Search results include all the parent type information needed to construct operations involving the matching type.
125+
- `validate`: validates a GraphQL operation against the schema without executing it. This allows AI models to verify that their operations are syntactically correct and conform to the schema before execution, preventing unintended side effects. Operations should be validated prior to calling the `execute` tool.
126+
- `execute`: executes an operation on the GraphQL endpoint
143127

144128
The MCP client can use these tools to provide schema information to the model and its context window, and allow the model to execute GraphQL operations based on that schema.
145129

@@ -197,8 +181,4 @@ introspection:
197181
leaf_depth: 1
198182
validate:
199183
enabled: true
200-
```
201-
202-
```sh title="Example command using introspection"
203-
apollo-mcp-server <path to the preceding config>
204184
```

0 commit comments

Comments
 (0)