fix: make header names python-safe by saurabhkoshatwar · Pull Request #592 · googleapis/mcp-toolbox-sdk-python · GitHub
Skip to content

fix: make header names python-safe - #592

Open
saurabhkoshatwar wants to merge 5 commits into
googleapis:mainfrom
saurabhkoshatwar:skoshatwar/issue-fix-580
Open

saurabhkoshatwar wants to merge 5 commits into
googleapis:mainfrom
saurabhkoshatwar:skoshatwar/issue-fix-580

Conversation

@saurabhkoshatwar

@saurabhkoshatwar saurabhkoshatwar commented Mar 14, 2026

Copy link
Copy Markdown

Fixes #580

Summary

  • Allow Toolbox tools to use parameter/header names that are not valid Python identifiers (e.g. X-Application-ID).
  • Introduce a Python‑safe field name mapping so function signatures and Pydantic models stay valid while preserving the original parameter names over the wire.

Details

  • Sanitize schema parameter names into Python‑safe field names and use those in inspect.Parameter and Pydantic models.
  • Maintain a mapping from Python‑safe names back to original schema names in ToolboxTool so requests still use the exact header/parameter names defined in tools.yaml.

@anubhav756

Copy link
Copy Markdown
Contributor

@anubhav756

Copy link
Copy Markdown
Contributor

Thanks for the PR @saurabhkoshatwar !

Could you please take a look at the integration test failure?

I'm also thinking if we could add any more integration/unit tests to verify this change. For instance to see if there could still be any validation failures while actually using hyphenated parameters?

@anubhav756 anubhav756 added priority: p2 Moderately-important priority. Fix may not be included in next release. help wanted labels Mar 16, 2026
@anubhav756
anubhav756 force-pushed the skoshatwar/issue-fix-580 branch 2 times, most recently from 99c3383 to 992c3a5 Compare March 25, 2026 06:26
@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@anubhav756

Copy link
Copy Markdown
Contributor

Thanks for the PR @saurabhkoshatwar !

Could you please take a look at the integration test failure?

I'm also thinking if we could add any more integration/unit tests to verify this change. For instance to see if there could still be any validation failures while actually using hyphenated parameters?

@saurabhkoshatwar Bumping this up in case it got missed :)

@anubhav756
anubhav756 force-pushed the skoshatwar/issue-fix-580 branch from 992c3a5 to de80c29 Compare March 27, 2026 21:37
@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@saurabhkoshatwar

Copy link
Copy Markdown
Author

@anubhav756 could you please rerun the tests? Thanks!

@anubhav756
anubhav756 force-pushed the skoshatwar/issue-fix-580 branch from a5305cd to d092006 Compare March 31, 2026 09:56
@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@saurabhkoshatwar
saurabhkoshatwar force-pushed the skoshatwar/issue-fix-580 branch from 3ab9bb9 to 8aa416d Compare April 1, 2026 15:13
@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@saurabhkoshatwar
saurabhkoshatwar force-pushed the skoshatwar/issue-fix-580 branch from 8aa416d to 610a9ca Compare April 10, 2026 01:21
@saurabhkoshatwar

Copy link
Copy Markdown
Author

@anubhav756, please rerun /gcbrun

@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

@anubhav756

Copy link
Copy Markdown
Contributor

@anubhav756, please rerun /gcbrun

@saurabhkoshatwar Done!

@Deeven-Seru

Copy link
Copy Markdown
Contributor

@anubhav756 anubhav756 removed their assignment Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p2 Moderately-important priority. Fix may not be included in next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP Toolbox HTTP Source - Header Parameter don't allow headers with hyphen.

3 participants