modelcontextprotocol / modelcontextprotocol/csharp-sdk
MCP Apps: Add [McpAppResource] attribute and resource-collection processing in WithMcpApps()
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 814
- Avg merge
- 9d 19h
- Merged PRs (30d)
- 4
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100