fix(agentgateway): support MCP 2.x field names - #295
Merged
Conversation
Resolve conflicts in _lob.py and _customer.py: keep main's enriched tool-error log (includes tool.url) and use the mcp_is_error compat helper for the error condition.
jplbrun
marked this pull request as ready for review
August 31, 2026 19:22
betinacosta
reviewed
Sep 1, 2026
betinacosta
previously approved these changes
Sep 1, 2026
Contributor
SDK Module Review
0 finding(s): 0 posted as inline comment(s) on the affected lines, 0 not tied to a code line (listed above). Generated by sdk-review-skill · v1 |
betinacosta
approved these changes
Sep 1, 2026
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.
Description
mcp 2.0.0renamed several result-object fields from camelCase to snake_case (the wire types moved into a newmcp-typespackage where every field is snake_case with a camelCase alias). Attribute access uses the Python field name, so code reading the old camelCase names raisesAttributeErroron mcp 2.x.agentgatewayread three such attributes:init_result.serverInfoserverInfoserver_infot.inputSchemainputSchemainput_schemaresult.isErrorisErroris_errorOn mcp 2.x,
init_result.serverInforaisesAttributeError: 'InitializeResult' object has no attribute 'serverInfo'. In the LoB tool-listing path this is caught silently per-server, so 0 tools load — the agent LLM receives an empty tool list and answers "tool not available" for every prompt. Network calls succeed and no exception propagates to the caller, which is what made this so hard to diagnose.Fix: version-agnostic reader helpers, keeping
mcp>=1.1.0so the SDK works on both mcp 1.x and 2.x — no forced upgrade for users, no dropped support.src/sap_cloud_sdk/agentgateway/_compat.py— threegetattr-based helpers (mcp_server_name,mcp_input_schema,mcp_is_error) that read the snake_case (2.x) name first and fall back to camelCase (1.x). They also subsume the previous defensiveserverInfo/.nameNone-guards._lob.py/_customer.py— the three raw attribute accesses now go through the helpers.pyproject.tomlunchanged (mcp>=1.1.0).Related Issue
Closes #274
Type of Change
How to Test
Reproduce before and verify after
Save the following reproducer as
/tmp/repro_issue_274.py. It calls the actual LoB tool-discovery function with real MCP 2 response models; only the network boundary is replaced so no MCP server or credentials are required.Check out
mainand run the reproducer with MCP 2:git switch main UV_CACHE_DIR=/tmp/uv-cache uv run --isolated --with 'mcp==2.0.0' \ python /tmp/repro_issue_274.pyThe current code fails in
_lob.list_server_tools()with:Check out this PR branch and run the exact same command:
Expected output:
Checklist
Breaking Changes
None.
Additional Notes
N/A