-
Notifications
You must be signed in to change notification settings - Fork 579
feat: add request-level extra headers support for MCP tool execution #2126
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
Merged
Pratham-Mishra04
merged 1 commit into
v1.5.0
from
03-17-feat_added_support_for_extra_headers_in_mcp_execute_tool
Mar 18, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| - feat: add DisableAutoToolInject to MCPToolManagerConfig to suppress automatic MCP tool injection per request | ||
| - feat: add BifrostContextKeyMCPAddedTools to context to track MCP tools added to the request | ||
| - refactor: standardize empty array conventions in bifrost. Empty array means deny all, ["*"] means allow all for models/tools/keys. | ||
| - refactor: standardize empty array conventions in bifrost. Empty array means deny all, ["*"] means allow all for models/tools/keys. | ||
| - feat: add support for request-level extra headers in MCP tool execution using BifrostContextKeyMCPExtraHeaders key in context. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package utils | ||
|
|
||
| import ( | ||
| "net/http" | ||
|
|
||
| "github.com/maximhq/bifrost/core/schemas" | ||
| ) | ||
|
|
||
| // GetHeadersForToolExecution sets additional headers for tool execution. | ||
| // It returns the headers for the tool execution. | ||
| func GetHeadersForToolExecution(ctx *schemas.BifrostContext, client *schemas.MCPClientState) http.Header { | ||
| if ctx == nil || client == nil || client.ExecutionConfig == nil { | ||
| return make(http.Header) | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| headers := make(http.Header) | ||
| if client.ExecutionConfig.Headers != nil { | ||
| for key, value := range client.ExecutionConfig.Headers { | ||
| headers.Add(key, value.GetValue()) | ||
| } | ||
| } | ||
| // Give priority to extra headers in the context | ||
| if extraHeaders, ok := ctx.Value(schemas.BifrostContextKeyMCPExtraHeaders).(map[string][]string); ok { | ||
| filteredHeaders := make(http.Header) | ||
| for key, values := range extraHeaders { | ||
| if client.ExecutionConfig.AllowedExtraHeaders.IsAllowed(key) { | ||
| for i, value := range values { | ||
| if i == 0 { | ||
| filteredHeaders.Set(key, value) | ||
| } else { | ||
| filteredHeaders.Add(key, value) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| // Add the filtered headers to the headers | ||
| if len(filteredHeaders) > 0 { | ||
| for k, values := range filteredHeaders { | ||
| for i, v := range values { | ||
| if i == 0 { | ||
| headers.Set(k, v) | ||
| } else { | ||
| headers.Add(k, v) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Pratham-Mishra04 marked this conversation as resolved.
|
||
| return headers | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.