Skip to content

Fix McpClientPrompt/Resource types to use RequestOptions like McpClientTool does#1370

Merged
stephentoub merged 3 commits intomainfrom
copilot/fix-mcpclientprompt-resource-types
Feb 24, 2026
Merged

Fix McpClientPrompt/Resource types to use RequestOptions like McpClientTool does#1370
stephentoub merged 3 commits intomainfrom
copilot/fix-mcpclientprompt-resource-types

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

Updates McpClientPrompt, McpClientResource, and McpClientResourceTemplate to accept a RequestOptions? parameter, matching the pattern already used by McpClientTool.CallAsync. This enables users to pass metadata, serialization options, and progress tracking when using these convenience wrapper types.

Changes Made

  • McpClientPrompt.GetAsync: Replaced JsonSerializerOptions? serializerOptions parameter with RequestOptions? options and pass it directly to McpClient.GetPromptAsync instead of wrapping in a new RequestOptions. Removed unused System.Text.Json using directive.
  • McpClientResource.ReadAsync: Added RequestOptions? options parameter and passes it through to McpClient.ReadResourceAsync.
  • McpClientResourceTemplate.ReadAsync: Added RequestOptions? options parameter and passes it through to McpClient.ReadResourceAsync.

Tests Added

  • McpClientPromptTests.GetAsync_WithRequestOptions_PassesMetaToServer — Registers a server-side prompt that echoes back _meta as JSON, calls prompt.GetAsync() with RequestOptions containing metadata, and verifies the metadata arrives at the server.
  • McpClientResourceTests.ReadAsync_WithRequestOptions_PassesMetaToServer — Registers a server-side resource that echoes back _meta, calls resource.ReadAsync() with RequestOptions containing metadata, and verifies passthrough.
  • McpClientResourceTemplateConstructorTests.ReadAsync_WithRequestOptions_PassesMetaToServer — Registers a server-side resource template that echoes back _meta, calls template.ReadAsync() with arguments and RequestOptions containing 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.

…source.ReadAsync, and McpClientResourceTemplate.ReadAsync

Co-authored-by: stephentoub <[email protected]>
@stephentoub
Copy link
Contributor

@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.

@stephentoub stephentoub marked this pull request as ready for review February 24, 2026 03:27
@stephentoub stephentoub changed the title [WIP] Fix McpClientPrompt resource types to use RequestOptions Fix McpClientPrompt resource types to use RequestOptions Feb 24, 2026
@stephentoub
Copy link
Contributor

Somehow these slipped through when RequestOptions was added. McpClientTool was updated, but McpClientPrompt and McpClientResource* were not.

@stephentoub stephentoub added the breaking-change This issue or PR introduces a breaking change label Feb 24, 2026
@stephentoub stephentoub added this to the 1.0.0 (GA) milestone Feb 24, 2026
…ClientResource, and McpClientResourceTemplate

Co-authored-by: stephentoub <[email protected]>
@stephentoub stephentoub changed the title Fix McpClientPrompt resource types to use RequestOptions Fix McpClientPrompt/Resource types to use RequestOptions Feb 24, 2026
Copy link
Contributor Author

Copilot AI commented Feb 24, 2026

@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 met...

Added three tests in e409b83 that validate meta passthrough via RequestOptions for each wrapper type:

  • McpClientPromptTests.GetAsync_WithRequestOptions_PassesMetaToServer
  • McpClientResourceTests.ReadAsync_WithRequestOptions_PassesMetaToServer
  • McpClientResourceTemplateConstructorTests.ReadAsync_WithRequestOptions_PassesMetaToServer

Each test registers a server-side handler that echoes back context.Params?.Meta as JSON, then calls the wrapper's method with RequestOptions { Meta = ... } and asserts the metadata values are received on the server side.

Copilot AI changed the title Fix McpClientPrompt/Resource types to use RequestOptions Fix McpClientPrompt/Resource types to use RequestOptions like McpClientTool does Feb 24, 2026
Copilot AI requested a review from stephentoub February 24, 2026 03:43
Copilot AI added a commit that referenced this pull request Feb 24, 2026
… RequestOptions + tests

Co-authored-by: stephentoub <[email protected]>
@stephentoub stephentoub merged commit 8c46411 into main Feb 24, 2026
16 of 17 checks passed
@stephentoub stephentoub deleted the copilot/fix-mcpclientprompt-resource-types branch February 24, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This issue or PR introduces a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants