fix(aws-diagram-mcp-server): use str for diagram_type param for Gemini compatibility#2430
Conversation
…for Gemini compatibility The get_diagram_examples tool's diagram_type parameter used a DiagramType(str, Enum) which does not emit "type": "string" in the JSON schema. Gemini requires an explicit "type" field in tool parameter schemas and rejects calls without it. Change the parameter type to str with a default of 'all' so the schema includes "type": "string". Convert to DiagramType internally, falling back to ALL for unrecognized values. Closes #661
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2430 +/- ##
=======================================
Coverage 90.86% 90.86%
=======================================
Files 974 974
Lines 71139 71143 +4
Branches 11546 11546
=======================================
+ Hits 64638 64642 +4
Misses 3984 3984
Partials 2517 2517 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request fixes a compatibility issue with Gemini backends by changing the get_diagram_examples tool's diagram_type parameter from a DiagramType enum to a plain str type. The Gemini backend requires an explicit "type" field in the JSON schema for tool parameters, which is omitted when using enum types. The change ensures the generated schema includes "type": "string", making the tool callable from Gemini environments.
Changes:
- Modified
diagram_typeparameter fromDiagramTypeenum tostrwith internal conversion to maintain type safety - Updated default value from
DiagramType.ALLto string'all' - Added fallback logic to use
DiagramType.ALLfor unrecognized string values - Added comprehensive test suite covering string input, invalid values, and all valid enum values
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/aws-diagram-mcp-server/awslabs/aws_diagram_mcp_server/server.py |
Changed mcp_get_diagram_examples parameter type to str, added string-to-enum conversion with fallback |
src/aws-diagram-mcp-server/tests/test_server.py |
Added TestMcpGetDiagramExamplesStringInput test class with 4 tests covering string inputs and edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address code quality bot warning about iterating over a type by wrapping DiagramType in list() to make the iteration explicit.
…i compatibility (awslabs#2430) * fix(aws-diagram-mcp-server): use str type for diagram_type parameter for Gemini compatibility The get_diagram_examples tool's diagram_type parameter used a DiagramType(str, Enum) which does not emit "type": "string" in the JSON schema. Gemini requires an explicit "type" field in tool parameter schemas and rejects calls without it. Change the parameter type to str with a default of 'all' so the schema includes "type": "string". Convert to DiagramType internally, falling back to ALL for unrecognized values. Closes awslabs#661 * fix: use list() to explicitly iterate DiagramType enum in test Address code quality bot warning about iterating over a type by wrapping DiagramType in list() to make the iteration explicit.
…i compatibility (awslabs#2430) * fix(aws-diagram-mcp-server): use str type for diagram_type parameter for Gemini compatibility The get_diagram_examples tool's diagram_type parameter used a DiagramType(str, Enum) which does not emit "type": "string" in the JSON schema. Gemini requires an explicit "type" field in tool parameter schemas and rejects calls without it. Change the parameter type to str with a default of 'all' so the schema includes "type": "string". Convert to DiagramType internally, falling back to ALL for unrecognized values. Closes awslabs#661 * fix: use list() to explicitly iterate DiagramType enum in test Address code quality bot warning about iterating over a type by wrapping DiagramType in list() to make the iteration explicit.
Summary
get_diagram_examplestool'sdiagram_typeparameter fromDiagramTypeenum tostrso the generated JSON schema includes"type": "string""type"field in tool parameter schemas and rejects function calls when it's missing (the enum-based schema omits it)DiagramTypeinternally, falling back toALLfor unrecognized valuesTestMcpGetDiagramExamplesStringInputtest class with 4 tests covering plain string input, invalid input fallback, and all valid enum valuesCloses #661
Test plan
ruff checkandruff formatcleanpyrightclean (0 errors)get_diagram_examplestool is now callableBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.