You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
cannot import name 'MCPStdioPlugin' from partially initialized module 'semantic_kernel.connectors.mcp'
To Reproduce
Steps to reproduce the behavior:
import asyncio
import os
from datetime import datetime
from pathlib import Path
from semantic_kernel.agents import ChatCompletionAgent, ChatHistoryAgentThread
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
from semantic_kernel.connectors.mcp import MCPStdioPlugin
from semantic_kernel.functions import KernelArguments
from semantic_kernel.kernel import Kernel
from semantic_kernel.connectors.openapi_plugin import OpenAPIFunctionExecutionParameters
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
async def main():
async with (
MCPStdioPlugin(
name="Github",
description="Github Plugin",
command="docker",
args=["run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server"],
env={"GITHUB_PERSONAL_ACCESS_TOKEN": os.getenv("GITHUB_PERSONAL_ACCESS_TOKEN")},
) as github_plugin,
):
print("Github plugin started")
if __name__ == "__main__":
asyncio.run(main())
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
cannot import name 'MCPStdioPlugin' from partially initialized module 'semantic_kernel.connectors.mcp' (most likely due to a circular import) (/Users/uday/git/uday31in/sk-mcp-client/.venv/lib/python3.13/site-packages/semantic_kernel/connectors/mcp.py)
File "/Users/uday/git/uday31in/sk-mcp-client/mcp.py", line 8, in <module>
from semantic_kernel.connectors.mcp import MCPStdioPlugin
File "/Users/uday/git/uday31in/sk-mcp-client/mcp.py", line 8, in <module>
from semantic_kernel.connectors.mcp import MCPStdioPlugin
ImportError: cannot import name 'MCPStdioPlugin' from partially initialized module 'semantic_kernel.connectors.mcp' (most likely due to a circular import) (/Users/uday/git/uday31in/sk-mcp-client/.venv/lib/python3.13/site-packages/semantic_kernel/connectors/mcp.py)
Platform
Language: Python
Source: semantic-kernel==1.28.1
AI model:GPT-4o
IDE: VS Code
OS: Mac
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
Bug: cannot import name 'MCPStdioPlugin' from partially initialized module 'semantic_kernel.connectors.mcp'
Python: Bug: cannot import name 'MCPStdioPlugin' from partially initialized module 'semantic_kernel.connectors.mcp'
Apr 28, 2025
Your script is named mcp.py, which shadows the installed mcp package required by Semantic Kernel.
This causes a circular import error because semantic_kernel.connectors.mcp tries to import from the real mcp package, but ends up importing your script instead.
Please rename your script (for example, rename mcp.py to mcp_client.py or main.py).
Describe the bug
cannot import name 'MCPStdioPlugin' from partially initialized module 'semantic_kernel.connectors.mcp'
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
Platform
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: