MCP Apps: Add [McpAppResource] attribute and resource-collection processing in WithMcpApps()

Open
#1,636 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp

Research direction

Start by comparing the existing McpAppUi attribute and WithMcpApps() processing with the resource-side SetResourceUi path. Add the resource attribute and resource-collection handling, or implement the minimum in Program.cs using SetResourceUi(). Update the sample so typed McpUiResourceMeta and McpUiResourceCsp types are exercised instead of raw JSON.

Written by the indexing model from the issue text.

Description

enhancement P3 ready for work

From PR #1484 review comment by @halter73:

The tool-side has three layers (attribute → builder → programmatic), but resource-side currently only has programmatic (SetResourceUi). There's no [McpAppResource] attribute and WithMcpApps() doesn't process the resource collection.

Server authors using attribute-based registration currently fall back to raw JSON strings in [McpMeta] to set UI metadata on resources, bypassing the typed McpUiResourceMeta / McpUiResourceCsp types.

Preferred approach:
Add [McpAppResource] mirroring [McpAppUi] and extend WithMcpApps() to iterate options.ResourceCollection. Then the sample can drop the raw JSON and use:

[McpServerResource(...)]
[McpAppResource(ConnectDomains = new[] { "https://api.weather.gov" }, PrefersBorder = true)]
public static string GetWeatherForecastUi() => ...;

Minimum:
Update the sample to call SetResourceUi() from a manual-registration code path in Program.cs so the typed types are exercised somewhere in user-facing docs.

Related to #1607.

Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelcontextprotocol/csharp-sdk

All issues in modelcontextprotocol/csharp-sdk

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.