Repository navigation
chore(mcp): migrate to MCP Python SDK 2.3 (protocol 2025-11-25, v2 API) - #139
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
added 16 commits
November 24, 2026 21:18
mcp 2.3 renames ToolAnnotations fields to snake_case and requires context in ToolManager.call_tool. Export keeps the spec shape (by_alias), tests read both spellings via one helper and call the public MCPServer.call_tool. Contract artifact regenerated (69 tools). ADR numbers corrected to the FACTS.md canon: 13 visible, 69 full. Closed entries moved to the November archive (registry was 314 lines).
ManSio
force-pushed
the
chore/mcp-sdk-v2
branch
from
November 24, 2026 18:57
7aa77e7 to
937aa36
Compare
The real-corpus smoke is marked slow and is deselected by addopts, so gate-zero never ran it; CI did and hit ToolManager.call_tool(context). Uses mcp.call_tool and reads CallToolResult.content, keeping the 1.x tuple path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что и зачем
Переход на MCP Python SDK 2.3.0 (протокол до 2026-07-28, новый API). Причина: линия 1.x — maintenance mode, а наш пин стоял на
mcp==1.30. План, решения и принятые деградации —docs/adr/0008-mcp-sdk-v2.md.Что сделано
FastMCP→MCPServer(импорт с fallback на 1.x),serverInfo.version= версия проекта, транспортные параметры черезstreamable_http_app(...)version=вызывается только на 2.x (на 1.xFastMCPего не принимает — иначе падал дочерний процесс)isErrorдля JSON-конверта ошибок — через middleware (в 2.xrequest_handlersудалён); v1-путь сохранёнClient(server)и версионно-независимый_is_error(is_errorна 2.x,isErrorна 1.x); один шимmcp.server.fastmcpвtests/conftest.pymcp==2.3.0,mcp-types==2.3.0,httpx2==2.16.0,opentelemetry-api==1.45.2;sse-starletteостаётся транзитивной (3.4.5);httpxостаётся (наш код)error_handlerдо ветвления по версии, кастомные методы скипаются с debug-логом, каждый пункт — строка в ADR и guard-тестРешения (по фактам, не по вкусу)
grepпоsrc/ tests/ scripts/ adapters/ docs/— ни одного потребителя; смысл покрытintel_trigger_reindex,intel_reset_index,codebase(action="index", path="status")isErrorisErrorNotificationBroker(push в Zed)session._connection.outbound— та же приватная поверхность, из-за которой идёт миграция.progress.json(файл-контракт для агента) пишется без сессииToolErrorв каждом из 69 инструментовЭпоха 2026-07-28 — как есть (проверено заново)
initialize(2026-07-28)2025-11-25— handshake modern не умеетserver/discoverс per-request_metaпервым сообщениемsupportedVersions: ["2026-07-28"](+capabilities),tools/list= 17,tools/callработает;serverInfoв ответе нет — он приходит наinitialize(3.5.0)-32601/INVALID_REQUEST— ожидаемоМой первый probe не отправлял конверт, поэтому ADR раньше утверждал обратное — исправлено.
Проверка
После второго ревью (закрыто)
e07_equiv.pyзвалstreamablehttp_clientstreamable_http_client/ старое имя) + распаковка 2-tuple/3-tuple; локальноE-07 PASSED (3/3)на обеих линияхHost(421):transport_security=Noneвключает DNS-rebinding allowlistTransportSecuritySettings(enable_dns_rebinding_protection=False)на 2.x, 1.x-путь не изменён; регресс-тестtests/test_streamable_http_host.pyстроит настоящий ASGI-apphttpx2>=,opentelemetry-api>=вместо точных пиновhttpx2==2.16.0,opentelemetry-api==1.45.2вpyproject.tomlиrequirements.txtKNOWN_ISSUES.mdисправлен; ADR:serverInfoреально лежит в_meta,mcp.server.fastmcp— заглушка, риск «откат потребует ветки v1.x» снят (обе линии зелёные); докстрингerror_results;except ModuleNotFoundErrorне маскирует поломку внутри пакетаОсталось (осознанно, не «доделаю потом молча»)
NotificationBrokerна 2.x — отдельная задача (типизированные нотификации черезContext.sessionили публичный API). Сейчас: один WARNING в лог,progress.jsonработает, guard-тест пиннит состояние.KNOWN_ISSUES.md; либо отдельная job, либо отказ от 1.x после стабилизации.scripts/verify_client_snippets.py(5 клиентов) иtransport-equiv-e2e— в CI этого PR.Откат
mcp>=1.28,<2в lock +pip install -r— код держит fallback, ревёрт не нужен (при условии, что откат делается до удаления поддержки 1.x).Риски на шаг вперёд
httpxиhttpx2сосуществуют: наш код наhttpx, объекты внутрь SDK — толькоhttpx2(иначе тихая деградация).tests/conftest.pyшим исчезнет вместе с линией 1.x — тогда удалить и оставить прямые импортыMCPServer.