python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

How to maintain client-specific state across multiple calls to server?

Open samirbajaj opened this issue 1 year ago • 1 comments

I am looking for an API or pattern (or perhaps an example) of how I can maintain client-specific state across multiple calls to an MCP server.

In other words, if I have 'n' clients, I'd like to be able to determine on the server the identity of the client making the request (so that I can look up client-specific information in some database).

I couldn't find anything in the documentation about this -- it looks like the examples cited are all stateless. Maybe I missed something?

Thank you for your help.

PS - I'm using LangChain, where tools have a concept of "injected state" (implicitly made available to the tool) -- I guess that's what I'm looking for.

samirbajaj avatar Mar 23 '25 16:03 samirbajaj

I assume this will be addressed by https://github.com/modelcontextprotocol/python-sdk/issues/373 ?

samirbajaj avatar Mar 26 '25 14:03 samirbajaj