Add server-side Streamable HTTP transport support (#330)
- Changes IJsonRpcMessage to an abstract base class so RelatedTransport will always be available - Streamable HTTP supports multiple concurrent HTTP request with their own indpendent SSE response streams - RelatedTransport indicates the source or destination of the JsonRpcMessage - Changes the default RequestId to a JSON number for better compatibility with MCP servers in the wild
This commit is contained in:
parent
7d77be68cf
commit
7dcba357d4
1 changed files with 1637 additions and 395 deletions
|
|
@ -0,0 +1,25 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ModelContextProtocol.Protocol.Messages;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a JSON-RPC message used in the Model Context Protocol (MCP) and that includes an ID.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// In the JSON-RPC protocol, messages with an ID require a response from the receiver.
|
||||
/// This includes request messages (which expect a matching response) and response messages
|
||||
/// (which include the ID of the original request they're responding to).
|
||||
/// The ID is used to correlate requests with their responses, allowing asynchronous
|
||||
/// communication where multiple requests can be sent without waiting for responses.
|
||||
/// </remarks>
|
||||
public abstract class JsonRpcMessageWithId : JsonRpcMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the message identifier.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Each ID is expected to be unique within the context of a given session.
|
||||
/// </remarks>
|
||||
[JsonPropertyName("id")]
|
||||
public RequestId Id { get; init; }
|
||||
}
|
||||
Loading…
Reference in a new issue