-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJsonRpcResponse.cs
More file actions
39 lines (31 loc) · 1.14 KB
/
JsonRpcResponse.cs
File metadata and controls
39 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// The Sisk Framework source code
// Copyright (c) 2024- PROJECT PRINCIPIUM and all Sisk contributors
//
// The code below is licensed under the MIT license as
// of the date of its publication, available at
//
// File name: JsonRpcResponse.cs
// Repository: https://github.com/sisk-http/core
using System.Net;
using System.Text.Json.Serialization;
namespace Sisk.ModelContextProtocol;
sealed class JsonRpcResponse {
[JsonPropertyName ( "jsonrpc" )]
public string Version => "2.0";
[JsonPropertyName ( "result" )]
public JsonValue Result { get; }
[JsonPropertyName ( "id" )]
public JsonValue Id { get; }
public JsonRpcResponse ( JsonValue result, JsonValue id ) {
Result = result;
Id = id;
}
}
class McpJsonResponse : HttpResponse {
public McpJsonResponse ( object obj, string? sessionId ) : base ( System.Net.HttpStatusCode.OK ) {
Headers [ HttpKnownHeaderNames.ContentType ] = "application/json; charset=utf-8";
if (sessionId is { })
Headers [ "Mcp-Session-Id" ] = sessionId;
Content = new ByteArrayContent ( McpProvider.Json.SerializeUtf8Bytes ( obj ) );
}
}