File size: 1,136 Bytes
ea8c770
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""CMBAgent MCP Server - Exposes backend endpoints as MCP tools"""
import argparse
import sys
from pathlib import Path

# Add parent directory to path if running as script
if __name__ == "__main__":
    parent_dir = Path(__file__).parent.parent
    if str(parent_dir) not in sys.path:
        sys.path.insert(0, str(parent_dir))

from mcp.server.fastmcp import FastMCP

# Use absolute import to support both -m and direct script execution
try:
    from cmbagent_mcp.tools.one_shot import run_one_shot
except ImportError:
    from tools.one_shot import run_one_shot

# Initialize MCP server
mcp = FastMCP("CMBAgentServer")

# Register the one_shot tool
mcp.tool()(run_one_shot)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="CMBAgent MCP Server")
    parser.add_argument(
        "transport",
        choices=["stdio", "sse", "streamable-http"],
        help="Transport mode (stdio, sse, or streamable-http)"
    )
    args = parser.parse_args()

    print(f"🚀 Starting CMBAgent MCP Server with {args.transport} transport...")
    mcp.run(transport=args.transport)