Pass session id's to MCP endpoints. (#466)
* Pass session id's to MCP endpoints. * Update src/ModelContextProtocol/Client/McpClient.cs Co-authored-by: Stephen Halter <halter73@gmail.com> * Update src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs Co-authored-by: Stephen Halter <halter73@gmail.com> * Make init callback asynchronous. * Address feedback. --------- Co-authored-by: Stephen Halter <halter73@gmail.com>
This commit is contained in:
parent
fa017c04c3
commit
d7d9eab3f8
1 changed files with 166 additions and 21 deletions
|
|
@ -128,6 +128,16 @@ public class Program
|
|||
""", McpJsonUtilities.DefaultOptions),
|
||||
},
|
||||
new Tool()
|
||||
{
|
||||
Name = "echoSessionId",
|
||||
Description = "Echoes the session id back to the client.",
|
||||
InputSchema = JsonSerializer.Deserialize<JsonElement>("""
|
||||
{
|
||||
"type": "object"
|
||||
}
|
||||
""", McpJsonUtilities.DefaultOptions),
|
||||
},
|
||||
new Tool()
|
||||
{
|
||||
Name = "sampleLLM",
|
||||
Description = "Samples from an LLM using MCP's sampling feature.",
|
||||
|
|
@ -168,6 +178,13 @@ public class Program
|
|||
Content = [new Content() { Text = "Echo: " + message.ToString(), Type = "text" }]
|
||||
};
|
||||
}
|
||||
else if (request.Params.Name == "echoSessionId")
|
||||
{
|
||||
return new CallToolResponse()
|
||||
{
|
||||
Content = [new Content() { Text = request.Server.SessionId, Type = "text" }]
|
||||
};
|
||||
}
|
||||
else if (request.Params.Name == "sampleLLM")
|
||||
{
|
||||
if (request.Params.Arguments is null ||
|
||||
|
|
|
|||
Loading…
Reference in a new issue