Skip to content

Commit dc49488

Browse files
authored
Merge pull request #225 from apollographql/GT-121-docs
Add documentation for validate tool and health check support
2 parents 39a4379 + 393e3f1 commit dc49488

File tree

2 files changed

+82
-22
lines changed

2 files changed

+82
-22
lines changed

docs/source/command-reference.mdx

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ All fields are optional.
134134
| `endpoint` | `URL` | `http://localhost:4000/` | The target GraphQL endpoint |
135135
| `graphos` | `GraphOS` | | Apollo-specific credential overrides |
136136
| `headers` | `Map<string, string>` | `{}` | List of hard-coded headers to include in all GraphQL requests |
137+
| `health_check` | `HealthCheck` | | Health check configuration |
137138
| `introspection` | `Introspection` | | Introspection configuration |
138139
| `logging` | `Logging` | | Logging configuration |
139140
| `operations` | `OperationSource` | | Operations configuration |
140141
| `overrides` | `Overrides` | | Overrides for server behavior |
141142
| `schema` | `SchemaSource` | | Schema configuration |
142143
| `transport` | `Transport` | | The type of server transport to use |
143144

144-
145145
#### GraphOS configuration
146146

147147
These fields are under the top-level `graphos` key and define your GraphOS graph credentials and endpoints.
@@ -153,6 +153,25 @@ These fields are under the top-level `graphos` key and define your GraphOS graph
153153
| `apollo_registry_url` | `URL` | | The URL to use for Apollo's registry |
154154
| `apollo_uplink_endpoints` | `URL` | | List of uplink URL overrides. You can also provide this with the `APOLLO_UPLINK_ENDPOINTS` environment variable |
155155

156+
#### Health check configuration
157+
158+
These fields are under the top-level `health_check` key.
159+
160+
| Option | Type | Default | Description |
161+
| :---------------------------- | :--------- | :---------- | :--------------------------------------------------------------------------------- |
162+
| `enabled` | `bool` | `false` | Enable health check endpoints |
163+
| `path` | `string` | `"/health"` | Custom health check endpoint path |
164+
| `readiness` | `object` | | Readiness check configuration |
165+
| `readiness.allowed` | `number` | `100` | Maximum number of rejections allowed in a sampling interval before marking unready |
166+
| `readiness.interval` | `object` | | Readiness check interval configuration |
167+
| `readiness.interval.sampling` | `duration` | `"5s"` | How often to check the rejection count |
168+
| `readiness.interval.unready` | `duration` | `"10s"` | How long to wait before recovering from unready state (default: 2 \* sampling) |
169+
170+
<Note>
171+
172+
Health checks are only available when using the `streamable_http` transport. The health check feature is inspired by Apollo Router's health check implementation.
173+
174+
</Note>
156175

157176
#### Introspection configuration
158177

@@ -166,7 +185,8 @@ These fields are under the top-level `introspection` key. Learn more about the M
166185
| `introspect.enabled` | `bool` | `false` | Enable introspection requests |
167186
| `search` | `object` | | Search tool configuration |
168187
| `search.enabled` | `bool` | `false` | Enable search tool |
169-
188+
| `validate` | `object` | | Validation tool configuration |
189+
| `validate.enabled` | `bool` | `false` | Enable validation tool |
170190

171191
#### Logging configuration
172192

@@ -176,7 +196,6 @@ These fields are under the top-level `logging` key.
176196
| :------ | :-------------------------------------------------- | :------- | :------------------------------ |
177197
| `level` | `oneOf ["trace", "debug", "info", "warn", "error"]` | `"info"` | The minimum log level to record |
178198

179-
180199
#### Operation source configuration
181200

182201
These fields are under the top-level `operations` key. The available fields depend on the value of the nested `source` key.
@@ -192,8 +211,7 @@ The default value for `source` is `"infer"`.
192211
| Manifest | `source` | `"manifest"` | | Load operations from a persisted queries manifest file |
193212
| Manifest | `path` | `FilePath` | | The path to the persisted query manifest |
194213
| Uplink | `source` | `"uplink"` | | Load operations from an uplink manifest. Note: This source requires an Apollo key and graph reference |
195-
| Infer | `source` | `"infer"` | * | Infer where to load operations based on other configuration options. |
196-
214+
| Infer | `source` | `"infer"` | \* | Infer where to load operations based on other configuration options. |
197215

198216
#### Overrides configuration
199217

@@ -206,7 +224,6 @@ These fields are under the top-level `overrides` key.
206224
| `enable_explorer` | `bool` | `false` | Expose a tool that returns the URL to open a GraphQL operation in Apollo Explorer. Note: This requires a GraphOS graph reference |
207225
| `mutation_mode` | `oneOf ["none", "explicit", "all"]` | `"none"` | Defines the mutation access level for the MCP server |
208226

209-
210227
#### Schema source configuration
211228

212229
These fields are under the top-level `schema` key. The available fields depend on the value of the nested `source` key.
@@ -216,8 +233,7 @@ The default value for `source` is `"uplink"`.
216233
| :----- | :------- | :--------- | :------ | :---------------------------------------------------------------------------------- |
217234
| Local | `source` | `"local"` | | Load schema from local file |
218235
| Local | `path` | `FilePath` | | Path to the GraphQL schema |
219-
| Uplink | `source` | `"uplink"` | * | Fetch the schema from uplink. Note: This requires an Apollo key and graph reference |
220-
236+
| Uplink | `source` | `"uplink"` | \* | Fetch the schema from uplink. Note: This requires an Apollo key and graph reference |
221237

222238
#### Transport configuration
223239

@@ -226,17 +242,16 @@ The default value for `type` is `"stdio"`.
226242

227243
| Type | Option | Type | Default | Description |
228244
| :------------- | :-------- | :------------------ | :---------- | :---------------------------------------------------------------------------------------------------------------------------- |
229-
| stdio | `type` | `"stdio"` | * | Use standard IO for communication between the server and client |
245+
| stdio | `type` | `"stdio"` | \* | Use standard IO for communication between the server and client |
230246
| SSE | `type` | `"sse"` | | Host the MCP server on the supplied configuration, using SSE for communication. Note: Deprecated in favor of `StreamableHTTP` |
231247
| SSE | `address` | `IpAddr` | `127.0.0.1` | The IP address to bind to |
232248
| SSE | `port` | `u16` | `5000` | The port to bind to |
233249
| StreamableHTTP | `type` | `"streamable_http"` | | Host the MCP server on the configuration, using streamable HTTP messages. |
234250
| StreamableHTTP | `address` | `IpAddr` | `127.0.0.1` | The IP address to bind to |
235251
| StreamableHTTP | `port` | `u16` | `5000` | The port to bind to |
236252

237-
238253
### Mapping rover dev options
239254

240255
You can use the [`rover dev`](/rover/commands/dev) command of Rover CLI v0.32 or later to run an Apollo MCP Server instance for local development.
241256

242-
Running `rover dev --mcp` starts an MCP Server. An optional configuration file path can be provided to configure the MCP server via `rover dev --mcp <PATH/TO/CONFIG>`.
257+
Running `rover dev --mcp` starts an MCP Server. An optional configuration file path can be provided to configure the MCP server via `rover dev --mcp <PATH/TO/CONFIG>`.

docs/source/guides/index.mdx

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ From the root of a local MCP Server repo, run the `apollo-mcp-server` binary wit
104104

105105
```yaml title="Example config for using Persisted Query Manifest"
106106
headers:
107-
'apollographql-client-name': 'my-web-app'
107+
"apollographql-client-name": "my-web-app"
108108
operations:
109109
source: manifest
110110
path: <absolute path to this local repo>/graphql/weather/persisted_queries/apollo.json
@@ -135,7 +135,7 @@ Use a [contract variant](/graphos/platform/schema-management/delivery/contracts/
135135

136136
```yaml title="Example config using GraphOS-managed persisted queries"
137137
headers:
138-
'apollographql-client-name': 'my-web-app'
138+
"apollographql-client-name": "my-web-app"
139139
operations:
140140
source: uplink
141141
schema:
@@ -161,6 +161,7 @@ You can enable the following introspection tools:
161161

162162
- `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.
163163
- `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.
164+
- `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.
164165
- `execute` - executes an operation on the GraphQL endpoint
165166

166167
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.
@@ -177,18 +178,14 @@ introspection:
177178
enabled: true
178179
introspect:
179180
enabled: true
181+
validate:
182+
enabled: true
180183
```
181184

182185
```sh title="Example command using introspection"
183186
apollo-mcp-server <path to the preceding config>
184187
```
185188

186-
{/*
187-
### Documenting tools
188-
189-
TODO
190-
\*/}
191-
192189
## Deploying the MCP server
193190

194191
There are two ways to deploy and operate the MCP server.
@@ -211,7 +208,7 @@ endpoint: https://thespacedevs-production.up.railway.app/
211208
operations:
212209
source: local
213210
paths:
214-
- /data/operations/
211+
- /data/operations/
215212
schema:
216213
source: local
217214
path: /data/api.graphql
@@ -260,7 +257,7 @@ You can inspect a local Apollo MCP Server by running it with MCP Inspector.
260257
operations:
261258
source: local
262259
paths:
263-
- <absolute path to this git repo>/graphql/weather/operations/
260+
- <absolute path to this git repo>/graphql/weather/operations/
264261
schema:
265262
source: local
266263
path: <absolute path to this git repo>/graphql/weather/api.graphql
@@ -301,7 +298,7 @@ You can also deploy the server as a container using the instructions in [Deployi
301298
operations:
302299
source: local
303300
paths:
304-
- <absolute path to this git repo>/graphql/weather/operations/
301+
- <absolute path to this git repo>/graphql/weather/operations/
305302
schema:
306303
source: local
307304
path: <absolute path to this git repo>/graphql/weather/api.graphql
@@ -328,6 +325,54 @@ npx @modelcontextprotocol/inspector
328325

329326
1. Click **Connect** and **List Tools**. You should see the tools for the operations you provided.
330327

328+
## Health checks
329+
330+
Apollo MCP Server provides health check endpoints for monitoring server health and readiness. This feature is useful for load balancers, container orchestrators, and monitoring systems.
331+
332+
### Configuration
333+
334+
Health checks are only available when using the `streamable_http` transport and must be explicitly enabled:
335+
336+
```yaml title="Example health check configuration"
337+
transport:
338+
type: streamable_http
339+
address: 127.0.0.1
340+
port: 5000
341+
health_check:
342+
enabled: true
343+
path: /health
344+
readiness:
345+
allowed: 50
346+
interval:
347+
sampling: 10s
348+
unready: 30s
349+
```
350+
351+
### Endpoints
352+
353+
The health check provides different responses based on query parameters:
354+
355+
| Endpoint | Description | Response |
356+
| :------------------ | :----------------- | :--------------------------------------------------------------- |
357+
| `GET /health` | Basic health check | Always returns `{"status": "UP"}` |
358+
| `GET /health?live` | Liveness check | Returns `{"status": "UP"}` if server is alive |
359+
| `GET /health?ready` | Readiness check | Returns `{"status": "UP"}` if server is ready to handle requests |
360+
361+
### Probes
362+
363+
The server tracks failed requests and automatically marks itself as unready if too many failures occur within a sampling interval:
364+
365+
- **Sampling interval**: How often the server checks the rejection count (default: 5 seconds)
366+
- **Allowed rejections**: Maximum failures allowed before becoming unready (default: 100)
367+
- **Recovery time**: How long to wait before attempting to recover (default: 2x sampling interval)
368+
369+
When the server becomes unready:
370+
371+
- The `/health?ready` endpoint returns HTTP 503 with `{"status": "DOWN"}`
372+
- After the recovery period, the rejection counter resets and the server becomes ready again
373+
374+
This allows external systems to automatically route traffic away from unhealthy servers and back when they recover.
375+
331376
## Custom scalars configuration
332377

333378
You can specify a custom scalars configuration JSON file to map a custom scalar to a [JSON schema type](https://json-schema.org/understanding-json-schema/reference/type). The JSON file is an object with custom scalar names as keys and JSON schema types as values:

0 commit comments

Comments
 (0)