Skip to content

Commit dd96fc4

Browse files
KanchiShimonoglorious-beard
authored andcommitted
Python: Fix TypeError when required is missing in MCP tool’s inputSchema (microsoft#11458)
### Motivation and Context Resolves microsoft#11457 ### Description Fixed an issue where a `TypeError` would occur when the inputSchema of a tool listed from the MCP server did not include any required parameters. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
1 parent 66956aa commit dd96fc4

File tree

1 file changed

+1
-1
lines changed
  • python/semantic_kernel/connectors

1 file changed

+1
-1
lines changed

python/semantic_kernel/connectors/mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def get_parameter_from_mcp_prompt(prompt: Prompt) -> list[dict[str, Any]]:
102102
def get_parameters_from_mcp_tool(tool: Tool) -> list[dict[str, Any]]:
103103
"""Creates an MCPFunction instance from a tool."""
104104
properties = tool.inputSchema.get("properties", None)
105-
required = tool.inputSchema.get("required", None)
105+
required = tool.inputSchema.get("required", [])
106106
# Check if 'properties' is missing or not a dictionary
107107
if not properties:
108108
return []

0 commit comments

Comments
 (0)