Skip to content

Allow JsonSerializerOptions parameters for user-defined and inputs and hardcode everything else to the source generator.#182

Merged
eiriktsarpalis merged 4 commits intomodelcontextprotocol:mainfrom
eiriktsarpalis:non-generic-abstractions
Apr 2, 2025
Merged

Allow JsonSerializerOptions parameters for user-defined and inputs and hardcode everything else to the source generator.#182
eiriktsarpalis merged 4 commits intomodelcontextprotocol:mainfrom
eiriktsarpalis:non-generic-abstractions

Conversation

@eiriktsarpalis
Copy link
Copy Markdown
Member

@eiriktsarpalis eiriktsarpalis commented Apr 1, 2025

This PR updates the JSON serialization aspects of the IMcpClient and IMcpServer abstractions in the following ways:

  • Removes serialization concerns from the core IMcpEndpoint signature by making its SendRequestAsync non generic.
  • JSON-RPC parameter and result serialization is now exclusively handled using extension methods over the abstractions.
  • Extension methods accepting user-defined objects now accept an optional JsonSerializerOptions overload that can be used to override serialization settings.
  • Serialization of the built-in implementations now hardcode to the source generator where applicable.

@eiriktsarpalis eiriktsarpalis force-pushed the non-generic-abstractions branch from 0e8c530 to 0b2a071 Compare April 2, 2025 09:45
@eiriktsarpalis eiriktsarpalis marked this pull request as ready for review April 2, 2025 09:45
Comment thread src/ModelContextProtocol/McpEndpointExtensions.cs Outdated
Comment thread src/ModelContextProtocol/Protocol/Types/CallToolRequestParams.cs
Comment thread src/ModelContextProtocol/Utils/Json/McpJsonUtilities.cs Outdated
@eiriktsarpalis eiriktsarpalis force-pushed the non-generic-abstractions branch from 69b3c77 to becdd3e Compare April 2, 2025 15:37
Comment thread src/ModelContextProtocol/McpEndpointExtensions.cs
Comment thread src/ModelContextProtocol/Client/McpClientExtensions.cs
@eiriktsarpalis eiriktsarpalis merged commit f1af251 into modelcontextprotocol:main Apr 2, 2025
8 checks passed
@eiriktsarpalis eiriktsarpalis deleted the non-generic-abstractions branch April 2, 2025 17:43
@jeffhandley jeffhandley added the breaking-change This issue or PR introduces a breaking change label Feb 20, 2026
@jeffhandley
Copy link
Copy Markdown
Contributor

Adding the breaking-change label retroactively during release notes revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This issue or PR introduces a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants