Add client-side tool call interceptor (annotation-aware policy enforcement)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
Research direction
Start by reading McpClientTool.ProtocolTool.Annotations and the McpClientOptions and McpClientHandlers APIs, then compare them with the server-side AddCallToolFilter pipeline. Define how the proposed ToolCallFilter can inspect annotations and enforce policy across client tool invocation paths, with tests showing blocked destructive calls and allowed calls proceeding through next.
Written by the indexing model from the issue text.
Description
The MCP C# SDK v1.1.0 exposes ToolAnnotations via McpClientTool.ProtocolTool.Annotations, but provides no built-in mechanism for a host to inspect those annotations and decide whether to allow invocation.
The server-side filter pipeline (WithRequestFilters(f => f.AddCallToolFilter(...))) has no client-side equivalent. McpClientOptions has no ToolCallPolicy or BeforeToolCall hook. McpClientHandlers only handles server→client requests (Sampling, Elicitation).
Proposed API
var client = await McpClient.CreateAsync(transport, new McpClientOptions
{
ToolCallFilter = async (toolName, annotations, args, next, ct) =>
{
if (annotations?.DestructiveHint == true)
throw new ToolBlockedException("Requires confirmation");
return await next(toolName, args, ct);
}
});
Without this, hosts must manually wrap every McpClientTool before passing to an IChatClient, and any unwrapped path bypasses policy entirely.
See also: https://modelcontextprotocol.io/blog/2026-03-16-tool-annotations (lethal trifecta attack pattern)
- 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
-
bug needs response
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Adyen/adyen-dotnet-api-library#1869 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
difficulty/starter 🚀 good first issue kind/bug platform/ios 🍎 project/non-ui ⚙️ triage/untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
unoplatform/uno#24650 ·
-
area-ai untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dotnet/extensions#7783 ·
-
untriaged
Difficulty 1/5 Under an hour Newbie friendliness 88/100
dotnet/dotnet-api-docs#13095 ·