Repository navigation
fix(py/plugins/mcp): say which server failed and why - #6930
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a name parameter to McpConnection to distinguish between different MCP servers/clients, particularly when they share the same command. Error messages and logs have been updated to include this name via a new _target property. Additionally, several module-level constants in _connection.py and _tools.py were made private, and error handling was improved to report malformed replies as protocol errors with proper causes. Test suites were updated to accommodate these changes and verify the new behavior. I have no feedback to provide as there are no review comments.
d535af1 to
9ae52c1
Compare
huangjeff5
left a comment
There was a problem hiding this comment.
heads up: feat/py-mcp-host got rebased onto main today, so GitHub shows the whole genkit-mcp package as added and this conflicts. The real change is git diff d535af1cc..HEAD; that is what I reviewed. The conflict is in mcp_connection_test.py.
Tried the three cases by hand: a missing binary reads UNAVAILABLE: MCP connection to 'my-broken-client' ('/usr/bin/nonexistent-binary-xyz') failed: [Errno 2] No such file or directory, two servers sharing python3 are told apart, and a malformed tools/list is INTERNAL ... ValidationError with the cause kept. Approving with two rebase notes.
9ae52c1 to
e9ca2fe
Compare
a75a256 to
73c5554
Compare
huangjeff5
left a comment
There was a problem hiding this comment.
Re-checked on main: the three threads hold. Verified the error strings by hand for a client, a hosted server, and the same server name on two hosts. A malformed tools/list is INTERNAL with the cause kept. Error text carries name/host/command only, no args or env.
Merge note: landing this before #6957/#6958 is easiest. Both build McpConnection without name and will need it on rebase.
py/packages/genkit-mcp/src/genkit_mcp/_host.py:289: Question, not for this PR:get_active_toolsskips an unreachable or timed-out server, but a malformedtools/listraises_ProtocolErrorand fails the whole host listing. Main did the same before (as a bare ValidationError). Should a malformed reply be skipped the same way?
|
Agreed it should probably match the unreachable/timeout case. I'll pick that up as a follow-up rather than widen this PR: genkit-ai/genkit-python#200 |
|
Ported to genkit-python in genkit-ai/genkit-python#72 ( |
Upstream-Commit: genkit-ai/genkit@d0d2e7a Upstream-PR: genkit-ai/genkit#6930 Upstream-Commit: genkit-ai/genkit@494584f Upstream-PR: genkit-ai/genkit#7153 Co-authored-by: Hilary Chukwuma <holaryc@gmail.com>
Why
Connection errors named only the server's command, so two servers in a host that run the same command (say, two
npxservers) gave identical errors, and timeout and startup errors dropped the reason the SDK or OS gave. A server that sent a malformedtools/listortools/callresult escaped as a raw pydanticValidationErrorinstead of aGenkitError. Part of #6194.Changes
[Errno 2] No such file or directory._ProtocolError(INTERNAL) with the original exception as its cause. The package's own errors pass through unchanged and the connection stays open._connection.pyand_tools.pyare now_-prefixed.Verification
_ProtocolErrorcaused by theValidationError, the connection stays open, and the server env stays out of a rendered traceback._answered_error.