modelcontextprotocol / modelcontextprotocol/python-sdk

Support MCP client session resumption (sessionId reuse) in Python SDK

未关闭
#2,116 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement P2 v2
主要语言
Python
星标
24.3k
派生
4k
平均合并
1 天 1 小时
30 天内合并 PR
31

描述

Description

Summary

The Python MCP SDK currently appears to create a new session whenever a client is instantiated. It would be valuable to support resuming an existing MCP session using a previously issued sessionId, similar to functionality discussed and addressed in the C# SDK (see modelcontextprotocol/csharp-sdk#946).

This would enable persistent and stateful workflows in agent-based systems.

Problem

At present, there does not appear to be a documented way in the Python SDK to:

  • Reuse an existing sessionId
  • Resume a previously established MCP session
  • Control session lifecycle independently of the client object's lifetime

Why This Is Important

  • In agent-driven architectures , session continuity allows:
  • More efficient orchestration
  • Reduced overhead from repeated session initialization

As MCP adoption grows across SDKs (C#, TypeScript, Python), having consistent session lifecycle capabilities improves cross-language parity and developer experience.

References

https://github.com/modelcontextprotocol/csharp-sdk/issues/946

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先追踪 Python SDK 如何创建和管理客户端会话,然后查看链接的 C# SDK issue,以了解会话恢复的上下文。完成后应包括一种受支持的方式来重新使用之前签发的 sessionId、独立于客户端生命周期恢复会话,以及记录相关行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api, backend
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。