Skip to content

fix(mcp): use configured MCP server URL and unwrap taskgroup errors - #583

Open
omkargaikwad23 wants to merge 1 commit into
mainfrom
fix/mcp-client-preserve-url
Open

fix(mcp): use configured MCP server URL and unwrap taskgroup errors#583
omkargaikwad23 wants to merge 1 commit into
mainfrom
fix/mcp-client-preserve-url

Conversation

@omkargaikwad23

@omkargaikwad23 omkargaikwad23 commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Preserve configured URLs: Removed URL alteration logic in mcp_client.py that forced an /mcp suffix onto every endpoint. Configured URLs are now trusted directly (with whitespace trimmed), allowing endpoints with custom paths (e.g. https://<host>/mcp/<service> or https://<host>/api/v1/mcp) to work without being broken by redundant path appending.
  • Unwrap TaskGroup errors: Added a compact _format_error helper in mcp_client.py to extract leaf errors from nested ExceptionGroup / TaskGroup exceptions, replacing the generic "unhandled errors in a TaskGroup (1 sub-exception)" with actionable error causes in reports and UI views.

Testing

  • Verified live capability discovery against Streamable HTTP MCP endpoints with custom subpaths.
  • Ran pytest across test suite (122 passed).
  • Verified style check with pycodestyle (0 errors).
  • Verified all internal products: https://screenshot-v2.corp.google.com/1fg3a2cfjaq2g

…up errors

Do not alter or append /mcp to the configured MCP server URL, allowing endpoints with explicit paths (e.g. /mcp/instance_manage) to function as intended. Add _format_error to unpack ExceptionGroup/TaskGroup leaf errors for actionable error reporting.
@omkargaikwad23

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@omkargaikwad23

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@omkargaikwad23 omkargaikwad23 changed the title fix(mcp): trust configured MCP server URL and unwrap taskgroup errors fix(mcp): use configured MCP server URL and unwrap taskgroup errors Aug 28, 2026

@wangauone wangauone left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM with some minor comments

"""Raised when a tools spec cannot be fetched or parsed."""


def sanitize_url(url: str) -> str:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We have the same function in here https://github.com/GoogleCloudPlatform/evalbench/blob/main/evalbench/generators/models/mcp_tools.py#L93-L109. Do we also want to make some similar changes there as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's out of scope for now as those files are related to mcp-readability flow. Maybe I can check with owner of the file.

if not rstripped_url.endswith("/mcp"):
return f"{rstripped_url}/mcp"
return rstripped_url
def _format_error(e: BaseException) -> str:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Ideally, it would be good to have a mcp_client_test.py to do some testing. : ) But I think it is okay to limit the scope of this PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sg! I will create a followup PR to add required test files.

stripped_url = (url or "").strip()
if stripped_url.startswith(("http://", "https://")):
url_with_scheme = stripped_url
elif "localhost" in stripped_url:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We will lost the capability to parse the value like localhost:8080 or sqladmin.googleapis.com (value without http prefix)? Just want to make sure this is the expected behavior

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's correct. We are assuming the fully qualified URL will be provided for now. We can definitely revisit this and add support for scheme-less URLs in the future if needed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants