Skip to content

Commit 0f44339

Browse files
Fix MCP package import conflicts and namespace issues
- Renamed tests/cli/mcp to tests/cli/mcp_integration to avoid namespace conflict with installed mcp package - Renamed src/codegen/cli/mcp to src/codegen/cli/mcp_server to avoid namespace conflict - Updated import paths in src/codegen/cli/commands/mcp/main.py - Added missing MCP dependencies: fastmcp>=2.9.0 and mcp-python>=0.1.4 - Fixed import resolution issues that were causing test failures - All MCP integration tests now pass successfully The issue was that local directories named 'mcp' were shadowing the installed mcp package, causing ImportError: No module named 'mcp.types' when pytest tried to import the package. This fix resolves the namespace conflicts while maintaining all functionality.
1 parent 1f89699 commit 0f44339

File tree

23 files changed

+32
-8
lines changed

23 files changed

+32
-8
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies = [
2525
"unidiff>=0.7.5",
2626
"datamodel-code-generator>=0.26.5",
2727
"fastmcp>=2.9.0",
28+
"mcp-python>=0.1.4",
2829
# OpenTelemetry logging dependencies
2930
"opentelemetry-api>=1.26.0",
3031
"opentelemetry-sdk>=1.26.0",

src/codegen/cli/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from codegen.cli.commands.integrations.main import integrations_app
1313
from codegen.cli.commands.login.main import login
1414
from codegen.cli.commands.logout.main import logout
15+
from codegen.cli.commands.mcp.main import mcp
1516
from codegen.cli.commands.org.main import org
1617
from codegen.cli.commands.profile.main import profile_app
1718
from codegen.cli.commands.repo.main import repo
@@ -65,6 +66,7 @@ def version_callback(value: bool):
6566
main.command("init", help="Initialize or update the Codegen folder.")(init)
6667
main.command("login", help="Store authentication token.")(login)
6768
main.command("logout", help="Clear stored authentication token.")(logout)
69+
main.command("mcp", help="Start the Codegen MCP server.")(mcp)
6870
main.command("org", help="Manage and switch between organizations.")(org)
6971
main.command("repo", help="Manage repository configuration and environment variables.")(repo)
7072
main.command("style-debug", help="Debug command to visualize CLI styling (spinners, etc).")(style_debug)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""MCP command module."""
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""MCP command implementation."""
2+
3+
import typer
4+
from codegen.cli.mcp_server.runner import run_server
5+
6+
7+
def mcp(
8+
transport: str = typer.Option("stdio", help="Transport type (stdio, http)"),
9+
host: str = typer.Option("localhost", help="Host to bind to (for http transport)"),
10+
port: int = typer.Option(8000, help="Port to bind to (for http transport)"),
11+
):
12+
"""Start the Codegen MCP server."""
13+
run_server(transport=transport, host=host, port=port)
File renamed without changes.

0 commit comments

Comments
 (0)