Skip to content

Bug: ChatCompletionAgent fails with Pydantic validation when MCPStdioPlugin is added for azure mcp server #11758

@Pavkum007

Description

@Pavkum007

Describe the bug
pydantic\main.py", line 253, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
pydantic_core.pydantic_core.ValidationError: 1 validation error for ChatCompletionAgent
name
String should match pattern '^[0-9A-Za-z
]+$' [type=string_pattern_mismatch, input_value='auth-method', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/string_pattern_mismatch

To Reproduce
Here is the code snippet

 async def main():
    # 1. Create the agent
    async with MCPStdioPlugin(
        name="Azure_MCP_Server",
        description="Azure MCP Plugin",
        command="npx",
        args=["-y", "@azure/mcp@latest", "server", "start"],
    ) as my_plugin:
        agent = ChatCompletionAgent(
            service=AzureChatCompletion(),
            name="MyAgent",
            instructions="Answer questions about my Azure resources",
            plugins=[my_plugin],
        )

        for user_input in USER_INPUTS:
            # 2. Create a thread to hold the conversation
            # If no thread is provided, a new thread will be
            # created and returned with the initial response
            thread: ChatHistoryAgentThread | None = None

            print(f"# User: {user_input}")
            # 3. Invoke the agent for a response
            response = await agent.get_response(messages=user_input, thread=thread)
            print(f"# {response.name}: {response} ")
            thread = response.thread

            # 4. Cleanup: Clear the thread
            await thread.delete() if thread else None


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

Expected behavior
It should successfully configure the MCPStdio (MCP server) for azure mcp

Platform

  • Language: Python
  • Source: Semantic Kernel version 1.28.1
  • AI model: Azure OpenAI:GPT-4o
  • IDE: VS Code
  • OS: Windows

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

ai connectorAnything related to AI connectorsbugSomething isn't workingpythonPull requests for the Python Semantic Kerneltriage

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions