You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/define-tools.mdx
+25-45Lines changed: 25 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,24 +48,25 @@ You can also use the `operations` option to specify a directory. The server then
48
48
49
49
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.
50
50
51
-
### From Operation Collection
51
+
### From an operation collection
52
52
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).
54
54
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.
56
56
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.
58
58
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**.
61
60
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"
63
64
operations:
64
65
source: collection
65
-
id: <collection-id>
66
+
id: default
66
67
```
67
68
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.
69
70
70
71
### From persisted query manifests
71
72
@@ -75,34 +76,19 @@ Set the persisted query manifest file for the MCP Server with the `operations` o
75
76
76
77
An example manifest is available in the [GitHub repo](https://github.com/apollographql/apollo-mcp-server/tree/main/graphql/weather/persisted_queries).
77
78
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"
85
80
operations:
86
81
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>
91
83
```
92
84
93
-
```sh showLineNumbers=false
94
-
apollo-mcp-server <path to the preceding config>
95
-
```
96
-
97
-
</ExpansionPanel>
98
-
99
85
### From GraphOS-managed persisted queries
100
86
101
87
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.
102
88
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.
104
90
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.
106
92
107
93
<Tip>
108
94
@@ -111,17 +97,8 @@ Use a [contract variant](/graphos/platform/schema-management/delivery/contracts/
111
97
</Tip>
112
98
113
99
```yaml title="Example config using GraphOS-managed persisted queries"
114
-
headers:
115
-
"apollographql-client-name": "my-web-app"
116
100
operations:
117
101
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>
125
102
```
126
103
127
104
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`,
130
107
131
108
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.
132
109
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
+
133
117
## Introspection tools
134
118
135
119
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.
136
120
137
121
You can enable the following introspection tools:
138
122
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
143
127
144
128
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.
0 commit comments