[Proposal] Declarative tool registration & runtime filtering for version gating (#1557)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 28/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- csharp
- Domain
- api, backend-api-design
Research direction
Start by tracing McpServerToolCollection, McpServerOptions, and the handling of tools/list and tools/call. Review the related issues #1557 and #1216 to understand the intended filter contract and how static and request-scoped gating should coexist. Done means version or group metadata and request predicates support non-destructive filtering, direct calls reject unavailable tools, and shared state is not mutated across sessions.
Written by the indexing model from the issue text.
Description
Proposal: Declarative Tool Versioning & Runtime Header/Endpoint Gating
Motivation & Context
Addressing https://github.com/modelcontextprotocol/csharp-sdk/issues/1557 in conjunction with https://github.com/modelcontextprotocol/csharp-sdk/issues/1216.
Currently, MCP tools registered in McpServerToolCollection lack built-in version metadata or request-scoped filtering capabilities. Developers needing phased canary/beta rollouts must manually intercept tools/list and mutate ServerOptions.ToolCollection at runtime, which is error-prone and causes concurrency/state-bleed issues across sessions.
Proposed Design Alignment
To bridge the static endpoint scoping (#1216) and runtime header gating (#1557), we propose:
-
[McpServerTool]Metadata Extension:- Add optional
string? Versionorstring? Group. - Add optional
string? RequiredHeaderandstring? HeaderPattern(or route constraints).
- Add optional
-
Scoped
IToolFilter/ Request Predicate:- Instead of mutating
ToolCollectionduringtools/list, introduce a non-destructive filter hookFunc<McpContext, ToolMetadata, bool>inMcpServerOptions. - When handling
tools/listandtools/call, evaluate the active request context against registered predicates. - Non-matching tools are excluded from the enumeration and return standard
MethodNotFound/-32601if called directly without the qualifying header.
- Instead of mutating
-
Coexistence with #1216:
- Static route-mapped toolsets and dynamic header-gated tools share the same underlying filter contract.
This avoids destructive list mutation and cleanly supports progressive opt-in deployments.
AI assistance disclosure: AI was used to discover this opportunity and draft the change or text. The submission was checked against the prepared artifact and recorded verification evidence.
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 814
- Avg merge
- 9d 19h
- Merged PRs (30d)
- 4
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.
More from modelcontextprotocol/csharp-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelcontextprotocol/csharp-sdk#1867 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
modelcontextprotocol/csharp-sdk#1840 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/csharp-sdk#1836 ·
-
enhancement needs confirmation
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
modelcontextprotocol/csharp-sdk#678 · 1 comment ·
-
enhancement needs confirmation P3 ready for work
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/csharp-sdk#515 · 6 comments · 3 reactions ·
All issues in modelcontextprotocol/csharp-sdk
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·