Skip to content

split execute and instrospection #45

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### 📚 Documentation
-->

## [UNRELEASED]

### ❗ BREAKING ❗
- split out the execute tool into separate --execute-introspection flag, `--introspection` is now `--introspection --execute-introspection`

Comment on lines +18 to +20
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm starting to have second thoughts about this. It may confuse people if this stops working, and it's yet more options they have to enable. I wonder if we could leave ---introspection as is, but then add --introspect and ---execute to override and enable/disable individual tools? The clients also generally have a way to disable specific tools.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, we have the same option in rover, and would need an update there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chatted about this in standup but, but for the history I agree! we are going to try to do a backwards compatible enum here and as a fallback we could add a --disable-execute instead

## [0.2.0] - 2025-05-21

### 🚀 Features
Expand Down
9 changes: 7 additions & 2 deletions crates/apollo-mcp-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ struct Args {
#[arg(long)]
sse_port: Option<u16>,

/// Expose the schema to the MCP client through `introspect` and `execute` tools
#[arg(long, short = 'i')]
/// Expose the schema to the MCP client through `introspect` tool
#[arg(long, short = 'i', required_if_eq("execute_introspection", "true"))]
introspection: bool,

/// Allow the use of the `execute` tool with operations build from the schema tool
#[arg(long)]
execute_introspection: bool,

/// Enable use of uplink to get the schema and persisted queries (requires APOLLO_KEY and APOLLO_GRAPH_REF)
#[arg(long, short = 'u')]
uplink: bool,
Expand Down Expand Up @@ -173,6 +177,7 @@ async fn main() -> anyhow::Result<()> {
.explorer(args.explorer)
.headers(default_headers)
.introspection(args.introspection)
.execute_introspection(args.execute_introspection)
.mutation_mode(args.allow_mutations)
.disable_type_description(args.disable_type_description)
.disable_schema_description(args.disable_schema_description)
Expand Down
16 changes: 15 additions & 1 deletion crates/apollo-mcp-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub struct Server {
endpoint: String,
headers: HeaderMap,
introspection: bool,
execute_introspection: bool,
explorer: bool,
custom_scalar_map: Option<CustomScalarMap>,
mutation_mode: MutationMode,
Expand All @@ -70,6 +71,7 @@ impl Server {
endpoint: String,
headers: Headers,
introspection: bool,
execute_introspection: bool,
explorer: bool,
custom_scalar_map: Option<CustomScalarMap>,
mutation_mode: MutationMode,
Expand All @@ -88,6 +90,7 @@ impl Server {
endpoint,
headers,
introspection,
execute_introspection,
explorer,
custom_scalar_map,
mutation_mode,
Expand Down Expand Up @@ -189,6 +192,7 @@ struct Configuring {
endpoint: String,
headers: HeaderMap,
introspection: bool,
execute_introspection: bool,
explorer: bool,
custom_scalar_map: Option<CustomScalarMap>,
mutation_mode: MutationMode,
Expand All @@ -205,6 +209,7 @@ impl Configuring {
endpoint: self.endpoint,
headers: self.headers,
introspection: self.introspection,
execute_introspection: self.execute_introspection,
explorer: self.explorer,
custom_scalar_map: self.custom_scalar_map,
mutation_mode: self.mutation_mode,
Expand All @@ -228,6 +233,7 @@ impl Configuring {
endpoint: self.endpoint,
headers: self.headers,
introspection: self.introspection,
execute_introspection: self.execute_introspection,
explorer: self.explorer,
custom_scalar_map: self.custom_scalar_map,
mutation_mode: self.mutation_mode,
Expand All @@ -243,6 +249,7 @@ struct SchemaConfigured {
endpoint: String,
headers: HeaderMap,
introspection: bool,
execute_introspection: bool,
explorer: bool,
custom_scalar_map: Option<CustomScalarMap>,
mutation_mode: MutationMode,
Expand All @@ -269,6 +276,7 @@ impl SchemaConfigured {
endpoint: self.endpoint,
headers: self.headers,
introspection: self.introspection,
execute_introspection: self.execute_introspection,
explorer: self.explorer,
custom_scalar_map: self.custom_scalar_map,
mutation_mode: self.mutation_mode,
Expand All @@ -284,6 +292,7 @@ struct OperationsConfigured {
endpoint: String,
headers: HeaderMap,
introspection: bool,
execute_introspection: bool,
explorer: bool,
custom_scalar_map: Option<CustomScalarMap>,
mutation_mode: MutationMode,
Expand All @@ -301,6 +310,7 @@ impl OperationsConfigured {
endpoint: self.endpoint,
headers: self.headers,
introspection: self.introspection,
execute_introspection: self.execute_introspection,
explorer: self.explorer,
custom_scalar_map: self.custom_scalar_map,
mutation_mode: self.mutation_mode,
Expand Down Expand Up @@ -329,6 +339,7 @@ struct Starting {
endpoint: String,
headers: HeaderMap,
introspection: bool,
execute_introspection: bool,
explorer: bool,
custom_scalar_map: Option<CustomScalarMap>,
mutation_mode: MutationMode,
Expand Down Expand Up @@ -362,7 +373,9 @@ impl Starting {
serde_json::to_string_pretty(&operations)?
);

let execute_tool = self.introspection.then(|| Execute::new(self.mutation_mode));
let execute_tool = self
.execute_introspection
.then(|| Execute::new(self.mutation_mode));

let root_query_type = self
.introspection
Expand Down Expand Up @@ -698,6 +711,7 @@ impl StateMachine {
endpoint: server.endpoint,
headers: server.headers,
introspection: server.introspection,
execute_introspection: server.execute_introspection,
explorer: server.explorer,
custom_scalar_map: server.custom_scalar_map,
mutation_mode: server.mutation_mode,
Expand Down
6 changes: 4 additions & 2 deletions docs/source/command-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ apollo-mcp-server [OPTIONS] --directory <DIRECTORY>
| :-------------------------------------------------- |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `-d, --directory <DIRECTORY>` | The working directory to use. Defaults the current working directory. |
| `-s, --schema <SCHEMA>` | The path to the GraphQL API schema file. |
| `-c, --custom-scalars-config <CUSTOM_SCALARS_CONFIG>` | The path to the GraphQL custom_scalars_config file. [Learn more](/apollo-mcp-server/guides/#custom-scalars). |
| `-c, --custom-scalars-config <CUSTOM_SCALARS_CONFIG>` | The path to the GraphQL custom_scalars_config file. [Learn more](/apollo-mcp-server/guides/#custom-scalars). |
| `-e, --endpoint <ENDPOINT>` | The GraphQL endpoint the server will invoke.<br />[default: `http://127.0.0.1:4000`] |
| `--header <HEADERS>` | Headers to send to the endpoint. |
| `--sse-port <SSE_PORT>` | Start the server using the SSE transport on the given port (default: 5000). |
| `--sse-address <SSE_ADDRESS>` | The IP address to bind the SSE server to (default: 127.0.0.1). |
| `-i, --introspection` | Expose the schema to the MCP client through `introspect` and `execute` tools. [Learn more](/apollo-mcp-server/guides/#from-schema-introspection). |
| `-i, --introspection` | Expose the schema to the MCP client through the `introspect` tool. [Learn more](/apollo-mcp-server/guides/#from-schema-introspection). |
| `--execute-introspection` | Expose the schema to the MCP client through the `execute` tool. [Learn more](/apollo-mcp-server/guides/#from-schema-introspection). |
| `-u, --uplink` | Enable use of uplink to get the schema and persisted queries (requires `APOLLO_KEY` and `APOLLO_GRAPH_REF`). [Learn more](/apollo-mcp-server/guides/#from-graphos-managed-persisted-queries). |
| `-x, --explorer` | Expose a tool to open queries in Apollo Explorer (requires `APOLLO_KEY` and `APOLLO_GRAPH_REF`). |
| `-o, --operations [<OPERATIONS>...]` | Operation files to expose as MCP tools. [Learn more](/apollo-mcp-server/guides/#from-operation-schema-files). |
Expand All @@ -93,6 +94,7 @@ The mapping of `rover dev` options to MCP Server options:
| `--mcp-sse-port <PORT>` | `--sse-port <PORT>` |
| `--mcp-sse-address <ADDRESS>` | `--sse-address <ADDRESS>` |
| `--mcp-introspection` | `-i, --introspection` |
| `--mcp-execute-introspection` | `--execute-introspection` |
| `--mcp-uplink` | `-u, --uplink` |
| `--mcp-operations [<OPERATIONS>...]` | `-o, --operations [<OPERATIONS>...]` |
| `--mcp-header <HEADERS>` | `--header <HEADERS>` |
Expand Down
2 changes: 1 addition & 1 deletion docs/source/guides/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Use the `--header` option when running the MCP Server to pass the header to the

For use cases where not all operations can be pre-defined, Apollo MCP Server supports tool creation based on introspection of the graph schema. This allows AI agents to explore a graph and execute operations dynamically.

To enable these schema-aware tools, run the MCP Server with the `--introspection` option, which exposes two new tools:
To enable these schema-aware tools, run the MCP Server with the `--introspection` option, which exposes the introspect tool, and `--execute-introspection` which enables the execute tool

* `introspect` - returns information about schema types
* `execute` - executes an operation on the GraphQL endpoint
Expand Down
4 changes: 2 additions & 2 deletions graphql/TheSpaceDevs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ npx @modelcontextprotocol/inspector

This option is typically used when you have built the source repository and use the binary outputs in the `target/build/*` folder.

There are operations located at `./operations/*.graphql` for you to use in your configuration. You can provide a set of operations in your MCP configuration along with the `--introspection` option that enables the LLM to generate a dynamic operation along with the ability to execute it.
There are operations located at `./operations/*.graphql` for you to use in your configuration. You can provide a set of operations in your MCP configuration along with the `--introspection` option that enables the LLM to generate a dynamic operation.

Here is an example configuration you can use _(Note: you must provide your fill path to the binary in the command. Make sure to replace the command with the path to where you cloned the repository)_:

Expand All @@ -55,7 +55,7 @@ Here is an example configuration you can use _(Note: you must provide your fill

## Using Server-Side-Events (SSE) with Apollo MCP server

There are operations located at `./operations/*.graphql` for you to use in your configuration. You can provide a set of operations in your MCP configuration along with the `--introspection` option that enables the LLM to generate a dynamic operation along with the ability to execute it.
There are operations located at `./operations/*.graphql` for you to use in your configuration. You can provide a set of operations in your MCP configuration along with the `--introspection` option that enables the LLM to generate a dynamic operation.

### Running SSE with `rover dev`

Expand Down