modelcontextprotocol / modelcontextprotocol/csharp-sdk

Dictionary<string, JsonElement> overload for CallToolAsync

Open
#640 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Currently, if a caller has a Dictionary<string, JsonElement>, they must convert each JsonElement to object to use the CallToolAsync API since it requires Dictionary<string, object?>. But given internally CallToolAsync already special handles JsonElement and underlying SendRequestAsync supports JsonElement, would it make sense to add an overload that accepts Dictionary<string, JsonElement>? This would avoid requiring callers to perform to-object conversion or rely on implementation details by casting.

We encountered this in Azure MCP Server, and due to the Dictionary<string, object?> constraint, it requires unnecessary conversions or serialization and deserialization operations within hot path

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.

Research direction

Start in src/ModelContextProtocol.Core/Client/McpClientExtensions.cs, around the CallToolAsync implementation and the linked handling at line 1088. Check how SendRequestAsync accepts JsonElement, then verify that the API supports a Dictionary<string, JsonElement> without caller-side conversion or serialization overhead.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.