Repository navigation
feat: implement dynamic MCP HTTP headers via header factory - #3583
Conversation
Refactors NewHeaderTransport to use a header factory instead of a static map. This allows for dynamic context-aware resolution of HTTP headers per-request, which is critical for refreshing OAuth tokens. Also fixes pre-existing Windows file permission test failures in tokenstore_test.go.
# Conflicts: # pkg/tools/mcp/mcp.go # pkg/tools/mcp/oauth_helpers.go # pkg/tools/mcp/oauth_test.go # pkg/tools/mcp/remote.go # pkg/tools/mcp/remote_test.go # pkg/upstream/headers.go
|
The underlying TODO has since been resolved on |
|
I see that ef6d626 covers MCP but it missed A2A toolsets. In main pkg/tools/a2a/a2a.go still evaluates headers statically at connection startup. My PR fixes this so A2A also gets per request expansion. It also includes a Windows file permission fix for the tokenstore tests. Should I update this PR to apply the new HeaderResolver pattern to a2a.go and keep the Windows fix? |
|
Yes to both: apply |
docker-agent 1.110.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>This release adds dynamic MCP HTTP headers, new shell safety policies, per-model custom pricing, and cache-stable dynamic prompts, along with fixes for elicitation delivery and session cost tracking. ## What's New - Adds dynamic MCP HTTP headers via a header factory, enabling context-aware HTTP header resolution instead of static headers fixed at startup - Adds a `safe-auto` safety policy for shell operations, providing a middle ground between prompting for every tool call and `--yolo` mode; safe calls beyond shell are auto-approved under this policy, with an opt-in `safer` mode available via `approve-safer` resume - Adds an optional `cost` block to model configuration, allowing explicit per-model token pricing for custom, locally-hosted, or uncatalogued models - Adds opt-in cache-stable dynamic prompts (`cache_stable_prompts` user setting), persisting frozen instruction snapshots and appending chronological updates when trusted context changes ## Bug Fixes - Fixes elicitation requests from concurrent background jobs being silently dropped and blocking the requesting handler indefinitely - Fixes session cost dropping after compaction (e.g., from $49 to $12) by keeping cost monotonic across compaction and preserving cost accounting across reload --- ## What's Changed * feat: implement dynamic MCP HTTP headers via header factory by @Piyush0049 in docker/docker-agent#3583 * fix(runtime): reliable, correlation-safe, non-blocking elicitation delivery (#3584) by @aheritier in docker/docker-agent#3587 * docs: update CHANGELOG.md for v1.109.0 by @docker-read-write[bot] in docker/docker-agent#3661 * Add opt-in cache-stable dynamic prompts by @rumpl in docker/docker-agent#3662 * fix(session): keep cost monotonic across compaction by @Sayt-0 in docker/docker-agent#3663 * feat(safer_shell): add safe-auto safety policy by @trungutt in docker/docker-agent#3647 * feat(config): declare explicit per-model token pricing with cost by @dgageot in docker/docker-agent#3664 **Full Changelog**: docker/docker-agent@v1.109.0...v1.110.0 </pre> <p>View the full release notes at <a href="https://github.com/docker/docker-agent/releases/tag/v1.110.0">https://github.com/docker/docker-agent/releases/tag/v1.110.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!14319
Description
This PR refactors
NewHeaderTransportin the upstream transport layer to use aheaderFactory(func(context.Context) map[string]string) instead of a static map for HTTP headers.Currently, the MCP remote client initializes with a static
map[string]string. This means whatever headers are present at startup are permanently hardcoded into the HTTP client for its lifespan. By migrating to a header factory, this PR enables dynamic, context-aware resolution of HTTP headers per-request.This is a critical architectural improvement that allows the agent to securely fetch fresh, short-lived tokens (like OAuth tokens) on every single request and pass dynamic execution metadata during MCP sessions.
Additional Fixes
pkg/tools/mcp/keyringstore/tokenstore_test.go. The test assertions were updated to expect0666file permissions on Windows instead of Unix-style0600. Go'sos.Statalways reports ACLs as0666or0444natively on Windows, regardless of the mode passed toos.WriteFile. This keeps the test suite completely green for Windows contributors without weakening application security.Testing
task testgo buildandgo vetare completely clean