Skip to content

fix(py/plugins/mcp): name hosted server in client errors - #7166

Closed
yumin2002 wants to merge 1 commit into
genkit-ai:mainfrom
yumin2002:fix-mcp-host-error-context
Closed

yumin2002 wants to merge 1 commit into
genkit-ai:mainfrom
yumin2002:fix-mcp-host-error-context

Conversation

@yumin2002

@yumin2002 yumin2002 commented Nov 10, 2026 •

Copy link
Copy Markdown

Why

Fixes genkit-ai/genkit-python#204. When a server runs behind McpHost, three McpClient paths still identify it as a standalone client. Two hosts can each contain a server with the same name, so messages such as MCP client 'git' is closed do not identify which host failed.

Connection errors already include the host after #6930, but client-level closed and restarted errors, and the cross-event-loop close timeout warning, do not.

Changes

  • Name hosted client lifecycle errors as MCP server <name> on host <host>, while preserving the existing standalone client text.
  • Log hosted close timeouts with server and host fields, while retaining client for standalone clients.
  • Cover both logging modes and pin the hosted reconnect and disconnect error messages.

Verification

  • .venv/bin/python -m pytest py/packages/genkit-mcp/tests (257 passed)
  • .venv/bin/ruff format --check on the three changed files
  • .venv/bin/ruff check on the three changed files
  • git diff --check origin/main...HEAD

@huangjeff5 I noticed your note in #6930 that Python changes should go to genkit-python now. Should I move this genkit-ai/genkit-python#204 follow-up there? If this PR is still targeting the correct repository, would you mind taking a look? Thank you!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves error messages and logging for MCP clients and hosted servers by dynamically identifying whether the connection is a standalone client or a hosted server. It introduces a _target property to format the target name and host appropriately, updating connection-closed and connection-failed exceptions to use this property. Corresponding unit tests have been added and updated to verify these changes. I have no feedback to provide as there are no review comments.

@MichaelDoyle

Copy link
Copy Markdown
Contributor

Hi @yumin2002 — heads up that Genkit Python SDK development has moved to https://github.com/genkit-ai/genkit-python! Could you re-open this PR over there (file paths map 1:1 after stripping the leading py/ prefix; see also genkit-ai/genkit-python#72), and link/close this PR once moved? cc @huangjeff5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

py/plugins/mcp: client errors for a hosted server don't name its host

2 participants