Skip to content

Scope MCP tool-context metadata forwarding per server - #6792

Open
dimitarproynov wants to merge 1 commit into
spring-projects:mainfrom
dimitarproynov:dimitarproynov/hardern-mvc-meta-converter
Open

Scope MCP tool-context metadata forwarding per server#6792
dimitarproynov wants to merge 1 commit into
spring-projects:mainfrom
dimitarproynov:dimitarproynov/hardern-mvc-meta-converter

Conversation

@dimitarproynov

Copy link
Copy Markdown
Contributor

ToolContextToMcpMetaConverter.convert(ToolContext) had no way to know which MCP server a call was headed to, so any converter forwarding sensitive ToolContext entries (auth tokens, user identifiers) sent them to every registered MCP server, not just the ones that needed them.

Add a default convert(ToolContext, McpConnectionInfo) method, mirroring how McpToolFilter already scopes tool discovery per connection, so a converter can decide what to forward based on the destination server. The single-arg method remains and existing implementations keep working unchanged through the new default.

SyncMcpToolCallback and AsyncMcpToolCallback now call the connection-aware overload, using new McpConnectionInfo.from(...) factory methods that also replace duplicated construction logic in both tool callback providers.

ToolContextToMcpMetaConverter.convert(ToolContext) had no way to know
which MCP server a call was headed to, so any converter forwarding
sensitive ToolContext entries (auth tokens, user identifiers) sent
them to every registered MCP server, not just the ones that needed
them.

Add a default convert(ToolContext, McpConnectionInfo) method,
mirroring how McpToolFilter already scopes tool discovery per
connection, so a converter can decide what to forward based on the
destination server. The single-arg method remains and existing
implementations keep working unchanged through the new default.

SyncMcpToolCallback and AsyncMcpToolCallback now call the
connection-aware overload, using new McpConnectionInfo.from(...)
factory methods that also replace duplicated construction logic in
both tool callback providers.

Signed-off-by: Dimitar Proynov <dimitar.proynov@broadcom.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants