Problem
Currently, the client can only send \Mcp-Param-*\ headers (SEP-2243 custom parameter headers) if \ListToolsAsync\ has been called first. This is because the transport relies on a cached \Tool\ definition (populated during \ListToolsAsync) to know which parameters have \x-mcp-header\ annotations and what header names to use.
If a caller already has prior knowledge of the tool schema (e.g., from a previous session, hardcoded configuration, or an out-of-band source), there is no way to provide that information without first calling \ListToolsAsync.
Note: \Mcp-Method\ and \Mcp-Name\ headers are not affected — they are derived directly from the request parameters and always sent regardless of whether \ListToolsAsync\ was called.
Current behavior
- \ListToolsAsync\ → caches \Tool\ objects in \McpClientImpl._toolCache\
- \CallToolAsync\ → \McpClientImpl.SendRequestAsync\ looks up tool by name in cache → attaches \Tool\ to
equest.Context.Items\
- \StreamableHttpClientSessionTransport.AddMcpRequestHeaders\ reads \Tool\ from context → extracts \x-mcp-header\ annotations → sends \Mcp-Param-*\ headers
If step 1 is skipped, no \Mcp-Param-*\ headers are sent (silently).
Desired behavior
Allow callers to provide tool schema information without requiring a \ListToolsAsync\ call, so that \Mcp-Param-*\ headers can be sent based on prior knowledge.
Possible approaches
- *Accept a \Tool\ object in \CallToolAsync* — add an overload or option property where the caller provides the tool definition
- Expose a method to pre-populate the cache — e.g., \RegisterTool(Tool tool)\ that adds tools without querying the server
- *Accept explicit headers in \RequestOptions* — let the caller provide custom headers directly, bypassing the schema-based mechanism
Related
Problem
Currently, the client can only send \Mcp-Param-*\ headers (SEP-2243 custom parameter headers) if \ListToolsAsync\ has been called first. This is because the transport relies on a cached \Tool\ definition (populated during \ListToolsAsync) to know which parameters have \x-mcp-header\ annotations and what header names to use.
If a caller already has prior knowledge of the tool schema (e.g., from a previous session, hardcoded configuration, or an out-of-band source), there is no way to provide that information without first calling \ListToolsAsync.
Note: \Mcp-Method\ and \Mcp-Name\ headers are not affected — they are derived directly from the request parameters and always sent regardless of whether \ListToolsAsync\ was called.
Current behavior
equest.Context.Items\
If step 1 is skipped, no \Mcp-Param-*\ headers are sent (silently).
Desired behavior
Allow callers to provide tool schema information without requiring a \ListToolsAsync\ call, so that \Mcp-Param-*\ headers can be sent based on prior knowledge.
Possible approaches
Related