Skip to content

Python: Bug: MCP plugin raises TypeError for undefined required parameter in MCP tool inputSchema #11457

@KanchiShimono

Description

@KanchiShimono

Describe the bug
When using the MCP plugin, an error occurs during the connection process to the MCP server.
The error is triggered by the conversion logic for Kernel Function Parameters when an MCP tool does not specify the required parameter in MCP tool inputSchema.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Python file named main.py with the provided code snippet.
  2. Execute the code using the command uv run main.py.
  3. Observe the error raised during the connection attempt.

Expected behavior
The MCP plugin should successfully connect to the MCP server without raising errors

Screenshots
N/A

Platform

  • Language: Python
  • Source: pip package version 1.27.2
  • AI model: N/A
  • IDE: N/A
  • OS: N/A

Additional context

Code Snippet

import asyncio

from semantic_kernel.connectors.mcp import MCPStdioPlugin


async def main() -> None:
    async with MCPStdioPlugin(name="playwright", command="npx", args=["@playwright/[email protected]"]) as mcp_plugin:
        pass


if __name__ == "__main__":
    asyncio.run(main())

Stack Trace

Traceback (most recent call last):
  File "/python/semantic_kernel/connectors/mcp.py", line 230, in __aenter__
    await self.connect()
  File "/python/semantic_kernel/connectors/mcp.py", line 169, in connect
    func.__kernel_function_parameters__ = get_parameters_from_mcp_tool(tool)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python/semantic_kernel/connectors/mcp.py", line 112, in get_parameters_from_mcp_tool
    is_required=prop_name in required,
                ^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

Metadata

Metadata

Assignees

Labels

.NETIssue or Pull requests regarding .NET codebugSomething isn't workingpythonPull requests for the Python Semantic Kernel

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions