Fix McpClientPrompt/Resource types to use RequestOptions like McpClientTool does#1370
Conversation
…source.ReadAsync, and McpClientResourceTemplate.ReadAsync Co-authored-by: stephentoub <[email protected]>
|
@copilot it looks like you didn't need to modify any tests? That implies this functionality is not well tested. Please ensure there are appropriate tests in place to exercise these methods, e.g. validating that meta can be passed through RequestOptions. |
|
Somehow these slipped through when RequestOptions was added. McpClientTool was updated, but McpClientPrompt and McpClientResource* were not. |
…ClientResource, and McpClientResourceTemplate Co-authored-by: stephentoub <[email protected]>
Added three tests in e409b83 that validate meta passthrough via
Each test registers a server-side handler that echoes back |
… RequestOptions + tests Co-authored-by: stephentoub <[email protected]>
Updates
McpClientPrompt,McpClientResource, andMcpClientResourceTemplateto accept aRequestOptions?parameter, matching the pattern already used byMcpClientTool.CallAsync. This enables users to pass metadata, serialization options, and progress tracking when using these convenience wrapper types.Changes Made
McpClientPrompt.GetAsync: ReplacedJsonSerializerOptions? serializerOptionsparameter withRequestOptions? optionsand pass it directly toMcpClient.GetPromptAsyncinstead of wrapping in a newRequestOptions. Removed unusedSystem.Text.Jsonusing directive.McpClientResource.ReadAsync: AddedRequestOptions? optionsparameter and passes it through toMcpClient.ReadResourceAsync.McpClientResourceTemplate.ReadAsync: AddedRequestOptions? optionsparameter and passes it through toMcpClient.ReadResourceAsync.Tests Added
McpClientPromptTests.GetAsync_WithRequestOptions_PassesMetaToServer— Registers a server-side prompt that echoes back_metaas JSON, callsprompt.GetAsync()withRequestOptionscontaining metadata, and verifies the metadata arrives at the server.McpClientResourceTests.ReadAsync_WithRequestOptions_PassesMetaToServer— Registers a server-side resource that echoes back_meta, callsresource.ReadAsync()withRequestOptionscontaining metadata, and verifies passthrough.McpClientResourceTemplateConstructorTests.ReadAsync_WithRequestOptions_PassesMetaToServer— Registers a server-side resource template that echoes back_meta, callstemplate.ReadAsync()with arguments andRequestOptionscontaining metadata, and verifies passthrough.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.