Repository: microsoft/semantic-kernel
File: python/samples/concepts/mcp/azure_ai_agent_with_mcp_plugin.py (Python)

Code before:
# Copyright (c) Microsoft. All rights reserved.

import asyncio

from azure.identity.aio import DefaultAzureCredential

from semantic_kernel.agents import (
    AzureAIAgent,
    AzureAIAgentSettings,
    ChatHistoryAgentThread,
)
from semantic_kernel.connectors.mcp import MCPStdioPlugin
from semantic_kernel.contents.chat_message_content import ChatMessageContent
from semantic_kernel.contents.utils.author_role import AuthorRole

"""
The following sample demonstrates how to create a chat completion agent that
answers questions about Github using a Semantic Kernel Plugin from a MCP server. 
The Chat Completion Service is passed directly via the ChatCompletionAgent constructor.
Additionally, the plugin is supplied via the constructor.
"""


async def main():
    # 1. Create the agent
    ai_agent_settings = AzureAIAgentSettings.create()

    async with (
        MCPStdioPlugin(
            name="github",
            description="Github Plugin",
            command="npx",
            args=["-y", "@modelcontextprotocol/server-github"],
        ) as github_plugin,
        DefaultAzureCredential() as creds,
        AzureAIAgent.create_client(
            credential=creds,
            conn_str=ai_agent_settings.project_connection_string.get_secret_value(),
        ) as client,
    ):
        agent_definition = await client.agents.create_agent(
            model=ai_agent_settings.model_deployment_name,

Review comment (suggestion):
```suggestion
The following sample demonstrates how to create a AzureAIAgent that
```

Code after:
# Copyright (c) Microsoft. All rights reserved.

import asyncio

from azure.identity.aio import DefaultAzureCredential

from semantic_kernel.agents import AzureAIAgent, AzureAIAgentSettings, AzureAIAgentThread
from semantic_kernel.connectors.mcp import MCPStdioPlugin

"""
The following sample demonstrates how to create a AzureAIAgent that
answers questions about Github using a Semantic Kernel Plugin from a MCP server.
"""


async def main():
    async with (
        # 1. Login to Azure and create a Azure AI Project Client
        DefaultAzureCredential() as creds,
        AzureAIAgent.create_client(credential=creds) as client,
        # 2. Create the MCP plugin
        MCPStdioPlugin(
            name="github",
            description="Github Plugin",
            command="npx",
            args=["-y", "@modelcontextprotocol/server-github"],
        ) as github_plugin,
    ):
        # 3. Create the agent, with the MCP plugin and the thread
        agent = AzureAIAgent(
            client=client,
            definition=await client.agents.create_agent(
                model=AzureAIAgentSettings.create().model_deployment_name,
                name="GithubAgent",
                instructions="You are a microsoft/semantic-kernel Issue Triage Agent. "
                "You look at all issues that have the tag: 'triage' and 'python'."
                "When you find one that is untriaged, you will suggest a new assignee "
                "based on the issue description, look at recent closed PR's for issues in the same area. "
                "You will also suggest additional context if needed, like related issues or a bug fix. ",
            ),
            plugins=[github_plugin],  # add the sample plugin to the agent
        )