Skip to content

Commit f7a4b9a

Browse files
committed
feat: implement full feature parity between SSE and stdio transports
- Add dedicated stdio_server.py with complete MCP server implementation - Expose all 29 tools, 5 prompts, and 14 resources in stdio mode - Update main.py to use new stdio server implementation - Maintain backward compatibility with existing SSE mode - Ensure identical functionality across both transport methods
1 parent 8c30c5f commit f7a4b9a

2 files changed

Lines changed: 708 additions & 49 deletions

File tree

src/mockloop_mcp/main.py

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,56 +1782,15 @@ def main():
17821782
if "--stdio" in sys.argv:
17831783
sys.argv.remove("--stdio")
17841784

1785-
# Run in stdio mode for Claude Code using standard MCP server
1786-
import asyncio
1787-
from mcp.server.stdio import stdio_server
1788-
from mcp.server import Server
1789-
from mcp.types import Tool
1790-
1791-
# Create standard MCP server for stdio mode
1792-
mcp_server = Server("MockLoop")
1793-
1794-
# Register tools with standard MCP server
1795-
@mcp_server.list_tools()
1796-
async def list_tools():
1797-
return [
1798-
Tool(
1799-
name="generate_mock_api",
1800-
description="Generates a FastAPI mock server from an API specification (e.g., OpenAPI). "
1801-
"The mock server includes request/response logging and Docker support.",
1802-
inputSchema={
1803-
"type": "object",
1804-
"properties": {
1805-
"spec_url_or_path": {"type": "string"},
1806-
"output_dir_name": {"type": "string"},
1807-
"auth_enabled": {"type": "boolean", "default": True},
1808-
"webhooks_enabled": {"type": "boolean", "default": True},
1809-
"admin_ui_enabled": {"type": "boolean", "default": True},
1810-
"storage_enabled": {"type": "boolean", "default": True},
1811-
"business_port": {"type": "integer", "default": 8000},
1812-
"admin_port": {"type": "integer"},
1813-
},
1814-
"required": ["spec_url_or_path"],
1815-
},
1816-
)
1817-
]
1818-
1819-
@mcp_server.call_tool()
1820-
async def call_tool(name: str, arguments: dict):
1821-
if name == "generate_mock_api":
1822-
return await generate_mock_api_tool(**arguments)
1823-
else:
1824-
raise ValueError(f"Unknown tool: {name}")
1825-
1826-
async def stdio_main():
1827-
async with stdio_server() as (read_stream, write_stream):
1828-
await mcp_server.run(
1829-
read_stream,
1830-
write_stream,
1831-
mcp_server.create_initialization_options(),
1832-
)
1785+
# Run in stdio mode with full feature parity
1786+
# Handle imports for different execution contexts
1787+
if __package__ is None or __package__ == "":
1788+
from stdio_server import run_stdio_server
1789+
else:
1790+
from .stdio_server import run_stdio_server
18331791

1834-
asyncio.run(stdio_main())
1792+
import asyncio
1793+
asyncio.run(run_stdio_server())
18351794
elif "--cli" in sys.argv:
18361795
# Remove --cli from sys.argv so argparse doesn't see it
18371796
sys.argv.remove("--cli")

0 commit comments

Comments
 (0)