Uh oh!
There was an error while loading. Please reload this page.
Get session id sample code #564 - #565
Conversation
scholtz
commented
Jun 29, 2025
is there anything i can help so that this sample code can be merged into the samples? |
| } | ||
| [McpServerTool(Name = "get_session"), Description("Returns current session id")] | ||
| public async Task<string?> GetSession(IMcpServer mcpServer) |
There was a problem hiding this comment.
This sample seems somewhat artificial to me -- the session id is mostly intended as a key for session state so it would be nice to have an example showcasing that.
halter73
commented
Aug 27, 2025
Hi @scholtz. Thanks for your contribution. I agree with @eiriktsarpalis that a little contrived and not substantial enough to warrant an entire sample. If there were some useful way to use the session id to key into session state in the new AspNetCoreMcpPerSessionTools added by #724, that might be interesting. I could see the AspNetCoreMcpPerSessionTools being the sample we end up using to demo more advanced features like querying the session ID. |
Sample code how to access the session id.
Motivation and Context
Showcase #564
When this issue will be solved I believe this may be useful information for everybody how to obtain session id in the tool.
How Has This Been Tested?
Through local mcp tool in vscode.
Breaking Changes
This is just a sample how i believe it should work.
Types of changes
Checklist
Additional context
This is example code on how to replicate issue #564
When this issue will be solved I believe this may be useful information for everybody how to obtain session id in the tool.