Skip to content

Conversation

@leonid-zats
Copy link

@leonid-zats leonid-zats commented Oct 12, 2025

Generated description

Below is a concise technical summary of the changes proposed in this PR:

graph LR
main_("main"):::modified
initialize_with_token_refresh_("initialize_with_token_refresh"):::modified
TokenManager_new_("TokenManager.new"):::modified
TokenManager_set_config_manager_("TokenManager.set_config_manager"):::modified
TokenManager_set_headers_("TokenManager.set_headers"):::added
TokenManager_get_valid_token_("TokenManager.get_valid_token"):::modified
TokenManager_refresh_access_token_("TokenManager.refresh_access_token"):::modified
ConfigManager_update_auth_token_("ConfigManager.update_auth_token"):::modified
TokenManager_headers_("TokenManager.headers"):::added
Starting_start_("Starting.start"):::modified
Running_("Running"):::modified
Running_call_tool_("Running.call_tool"):::modified
Running_headers_("Running.headers"):::added
main_ -- "Passes shared headers for token refresh and header updates" --> initialize_with_token_refresh_
initialize_with_token_refresh_ -- "Creates TokenManager with support for shared headers injection" --> TokenManager_new_
initialize_with_token_refresh_ -- "Injects config manager for token persistence in TokenManager" --> TokenManager_set_config_manager_
initialize_with_token_refresh_ -- "Injects shared headers for automatic token authorization updates" --> TokenManager_set_headers_
initialize_with_token_refresh_ -- "Obtains fresh token, triggers shared headers update" --> TokenManager_get_valid_token_
TokenManager_refresh_access_token_ -- "Writes refreshed token to config file for persistence" --> ConfigManager_update_auth_token_
TokenManager_refresh_access_token_ -- "Updates shared Authorization header with refreshed token asynchronously" --> TokenManager_headers_
Starting_start_ -- "Creates Running state with shared headers for auth propagation" --> Running_
Running_call_tool_ -- "Reads shared headers to propagate auth tokens in requests" --> Running_headers_
classDef added stroke:#15AA7A
classDef removed stroke:#CD5270
classDef modified stroke:#EDAC4C
linkStyle default stroke:#CBD5E1,font-size:13px
Loading

Implements a shared, mutable header map (Arc<RwLock>) to dynamically update authentication tokens across the dc-mcp-server without re-reading configuration. Ensures that all outgoing GraphQL requests utilize the most recently refreshed token, improving the reliability of the Model Context Protocol (MCP) server's interaction with GraphQL APIs.

Latest Contributors(2)
UserCommitDate
leonid-zatsscheduled-refreshOctober 12, 2025
[email protected]Releasing-0.8.0-356September 16, 2025
This pull request is reviewed by Baz. Review like a pro on (Baz).

- Helpful for debugging

## MCP Client Configuration
**Note**: The `apollo_key` can reference environment variables using `${DC_API_KEY}` syntax.
Copy link

Choose a reason for hiding this comment

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

Should apollo_key be apollo-key to match the configuration examples above? The config uses hyphens but this note uses underscores.

Suggested change
**Note**: The `apollo_key` can reference environment variables using `${DC_API_KEY}` syntax.
**Note**: The `apollo-key` can reference environment variables using `${DC_API_KEY}` syntax.

Finding type: Naming and Typos

Comment on lines 190 to 194
config_manager.update_auth_token(&token_response.access_token)
.map_err(|e| {
error!("Failed to write refreshed token to config file: {}", e);
e
})?;
Copy link

Choose a reason for hiding this comment

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

The function now fails completely if config writing fails, even when token refresh succeeded. Should config write failures be non-fatal since the primary operation (token refresh) succeeded?

Suggested change
config_manager.update_auth_token(&token_response.access_token)
.map_err(|e| {
error!("Failed to write refreshed token to config file: {}", e);
e
})?;
if let Err(e) = config_manager.update_auth_token(&token_response.access_token) {
error!("Failed to write refreshed token to config file: {}", e);
} else {
info!("✅ Refreshed token written to config file");
}

Finding type: Logical Bugs

@leonid-zats leonid-zats merged commit 86a1651 into main Oct 12, 2025
2 checks passed
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.

1 participant