Skip to content

Conversation

@swcollard
Copy link
Contributor

@swcollard swcollard commented Sep 8, 2025

Auth in the MCP server works by having the user go through the OAuth flow to obtain an auth token. This auth token is then validated and passed to the upstream API in Tool calls for accessing the resources in that API. There has been a request to not perform this passthrough of validated tokens in the event that the upstream API does not share the same auth methods as the mcp server.

This PR adds an optional new parameter to the config.transport.auth config object, disable_auth_token_passthrough, which is false by default, that when true, will no longer pass through validated Auth tokens to the GraphQL API.

Contains fix for #280

@swcollard swcollard requested a review from a team as a code owner September 8, 2025 14:36
@apollo-librarian
Copy link

apollo-librarian bot commented Sep 8, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 2 changed, 0 removed
* (developer-tools)/apollo-mcp-server/(latest)/config-file.mdx
* (developer-tools)/apollo-mcp-server/(latest)/limitations.mdx

Build ID: a1a783ee498e7520d931c31a
Build Logs: View logs

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

@github-actions
Copy link

github-actions bot commented Sep 8, 2025

Changeset file missing for PR

All changes should include an associated changeset file.
Please refer to README for more information on generating changesets.

@swcollard swcollard requested a review from Copilot September 8, 2025 14:42

This comment was marked as outdated.

.mutation_mode(config.overrides.mutation_mode)
.disable_type_description(config.overrides.disable_type_description)
.disable_schema_description(config.overrides.disable_schema_description)
.disable_auth_token_passthrough(match transport {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we shorten this a bit via:

match transport {
    apollo_mcp_server::server::Transport::STDIO => false,
    _ { auth, .. } => auth.map(...).unwrap_or(false)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't quite get this syntax working? I think the match needs the enum name so it can pull the auth values from the struct. And the compiler isn't smart enough to pull it as an 'else' case?

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 taking care of this issue! Could you also update config-file.mdx to include the new setting?

@swcollard swcollard requested a review from Copilot September 9, 2025 19:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a configuration option to disable authorization token passthrough from the MCP server to upstream GraphQL APIs. This allows users to prevent validated auth tokens from being forwarded when the upstream API uses different authentication methods.

  • Added disable_auth_token_passthrough boolean configuration parameter with default value of false
  • Modified token propagation logic to respect the new configuration setting
  • Updated all relevant structs and initialization code to include the new parameter

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/apollo-mcp-server/src/auth.rs Added disable_auth_token_passthrough field to auth Config struct
crates/apollo-mcp-server/src/main.rs Added logic to extract and apply the configuration from transport settings
crates/apollo-mcp-server/src/server.rs Added parameter to Server struct and builder method
crates/apollo-mcp-server/src/server/states.rs Added field to internal Config struct and initialization
crates/apollo-mcp-server/src/server/states/starting.rs Passed configuration to Running state
crates/apollo-mcp-server/src/server/states/running.rs Added conditional logic to skip token passthrough and updated test data
.changesets/feat_auth_token_passthrough_disable.md Added changeset documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

let transport = config.transport.clone();

Ok(Server::builder()
.transport(config.transport)
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The config.transport is being cloned unnecessarily. Since it's moved into the builder on line 115, you can use the cloned transport variable instead of cloning again.

Suggested change
.transport(config.transport)
.transport(transport)

Copilot uses AI. Check for mistakes.
Comment on lines +215 to +217
if !self.disable_auth_token_passthrough
&& let Some(token) = axum_parts.extensions.get::<ValidToken>()
{
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The condition logic is duplicated between lines 215-217 and 248-250. Consider extracting this into a helper method to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
@swcollard swcollard requested a review from a team as a code owner September 9, 2025 19:27
@swcollard swcollard merged commit 5e90732 into develop Sep 9, 2025
9 checks passed
@swcollard swcollard deleted the auth_token_passthrough_disable branch September 9, 2025 20:08
@apollo-bot2 apollo-bot2 mentioned this pull request Sep 12, 2025
@esilverm esilverm mentioned this pull request Sep 12, 2025
esilverm added a commit that referenced this pull request Sep 16, 2025
* fix(ci): pin to specific stable rust version (#287)

This commit pins the rust-toolchain to a specific rust version (1.89.0)
for compatibility guarantees. Renovate will handle warning on outdated
versions of stable rust.

A minimal supported rust version was also added to the underlying crates
to ensure compatibility guarantees as the stable verison increments in
future updates.

* feat: Implement Test Coverage Measurement and Reporting

* chore: add changeset

* feat: remove unnecessary codecov setting

* feat: add codecov badge

* feat: add codecov config file

* feat: add code coverage docs to CONTRIBUTING.md

* test: add tests for uplink schema event

* ci: prevent draft PRs from verifying changeset

* chore: add changeset

* ci: trigger verify changeset workflow when PR becomes ready for review

* ci: update github checkout actions

* feat: Configuration for disabling authorization token passthrough (#336)

* Allow config for not forwarding Auth tokens to GraphQL API

* use serde default to make new config optional

* Changeset

* Fix default case in main.rs

* Add new config option to documentation

* Redirect /docs/apollo-mcp-server/guides to fix 404 (#349)

Co-authored-by: Samuel Collard <[email protected]>
Co-authored-by: Michelle Mabuyo <[email protected]>

* chore: update RMCP version to latest (#328)

This commit updates the RMCP dependency to the latest version 0.6.4.
Sadly, schemars was also updated with this, so a lot of unrelated
changes were needed to conform with the new stable schemars version.

* chore(release): bumping to version 0.8.0

* chore(release): changelog for 0.8.0

---------

Co-authored-by: Apollo Bot <[email protected]>
Co-authored-by: Armando Locay <[email protected]>
Co-authored-by: Nicholas Cioli <[email protected]>
Co-authored-by: Dale Seo <[email protected]>
Co-authored-by: Dale Seo <[email protected]>
Co-authored-by: Samuel Collard <[email protected]>
Co-authored-by: apollo-bot2 <[email protected]>
Co-authored-by: Samuel Collard <[email protected]>
Co-authored-by: Michelle Mabuyo <[email protected]>
esilverm added a commit that referenced this pull request Sep 16, 2025
* Redirect /docs/apollo-mcp-server/guides to fix 404

* Fix bullet point formatting

* Add load balancer configuration details for Apollo MCP

Added instructions for configuring load balancers with Apollo MCP Server to ensure session affinity.

* Update docs/source/deploy.mdx

Co-authored-by: Michelle Mabuyo <[email protected]>

* Update deploy.mdx

* Releasing 0.8.0 (#356)

* fix(ci): pin to specific stable rust version (#287)

This commit pins the rust-toolchain to a specific rust version (1.89.0)
for compatibility guarantees. Renovate will handle warning on outdated
versions of stable rust.

A minimal supported rust version was also added to the underlying crates
to ensure compatibility guarantees as the stable verison increments in
future updates.

* feat: Implement Test Coverage Measurement and Reporting

* chore: add changeset

* feat: remove unnecessary codecov setting

* feat: add codecov badge

* feat: add codecov config file

* feat: add code coverage docs to CONTRIBUTING.md

* test: add tests for uplink schema event

* ci: prevent draft PRs from verifying changeset

* chore: add changeset

* ci: trigger verify changeset workflow when PR becomes ready for review

* ci: update github checkout actions

* feat: Configuration for disabling authorization token passthrough (#336)

* Allow config for not forwarding Auth tokens to GraphQL API

* use serde default to make new config optional

* Changeset

* Fix default case in main.rs

* Add new config option to documentation

* Redirect /docs/apollo-mcp-server/guides to fix 404 (#349)

Co-authored-by: Samuel Collard <[email protected]>
Co-authored-by: Michelle Mabuyo <[email protected]>

* chore: update RMCP version to latest (#328)

This commit updates the RMCP dependency to the latest version 0.6.4.
Sadly, schemars was also updated with this, so a lot of unrelated
changes were needed to conform with the new stable schemars version.

* chore(release): bumping to version 0.8.0

* chore(release): changelog for 0.8.0

---------

Co-authored-by: Apollo Bot <[email protected]>
Co-authored-by: Armando Locay <[email protected]>
Co-authored-by: Nicholas Cioli <[email protected]>
Co-authored-by: Dale Seo <[email protected]>
Co-authored-by: Dale Seo <[email protected]>
Co-authored-by: Samuel Collard <[email protected]>
Co-authored-by: apollo-bot2 <[email protected]>
Co-authored-by: Samuel Collard <[email protected]>
Co-authored-by: Michelle Mabuyo <[email protected]>

---------

Co-authored-by: Samuel Collard <[email protected]>
Co-authored-by: Michelle Mabuyo <[email protected]>
Co-authored-by: Alyssa Hursh <[email protected]>
Co-authored-by: Lenny Burdette <[email protected]>
Co-authored-by: Evan Silverman <[email protected]>
Co-authored-by: Armando Locay <[email protected]>
Co-authored-by: Nicholas Cioli <[email protected]>
Co-authored-by: Dale Seo <[email protected]>
Co-authored-by: Dale Seo <[email protected]>
Co-authored-by: Samuel Collard <[email protected]>
@apollo-bot2 apollo-bot2 mentioned this pull request Sep 24, 2025
@DaleSeo DaleSeo mentioned this pull request Sep 24, 2025
DaleSeo pushed a commit that referenced this pull request Sep 24, 2025
* Allow config for not forwarding Auth tokens to GraphQL API

* use serde default to make new config optional

* Changeset

* Fix default case in main.rs

* Add new config option to documentation
DaleSeo pushed a commit that referenced this pull request Sep 24, 2025
* Allow config for not forwarding Auth tokens to GraphQL API

* use serde default to make new config optional

* Changeset

* Fix default case in main.rs

* Add new config option to documentation
DaleSeo pushed a commit that referenced this pull request Sep 29, 2025
* Allow config for not forwarding Auth tokens to GraphQL API

* use serde default to make new config optional

* Changeset

* Fix default case in main.rs

* Add new config option to documentation
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.

4 participants