Skip to content

Commit 1610ae9

Browse files
committed
feat(mcp): add SSE transport with session-aware cancellation
Add an SSE transport alongside stdio for MCP JSON-RPC messages, including per-session event buffering/replay and cancellation of in-flight tool tasks on client disconnect. Made-with: Cursor
1 parent e119457 commit 1610ae9

File tree

2 files changed

+361
-53
lines changed

2 files changed

+361
-53
lines changed

src/agentos/cli.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ def main():
3030
help="Run in demo mode without API keys")
3131

3232
# agentos mcp
33-
subparsers.add_parser("mcp", help="Start MCP server")
33+
mcp_parser = subparsers.add_parser("mcp", help="Start MCP server")
34+
mcp_parser.add_argument(
35+
"--transport",
36+
choices=["stdio", "sse"],
37+
default="stdio",
38+
help="MCP transport to use",
39+
)
40+
mcp_parser.add_argument("--host", default="127.0.0.1")
41+
mcp_parser.add_argument("--port", type=int, default=8080)
42+
mcp_parser.add_argument("--name", default="agentos")
3443

3544
# agentos version
3645
subparsers.add_parser("version", help="Show version")
@@ -49,11 +58,20 @@ def main():
4958
uvicorn.run(app, host=args.host, port=args.port)
5059

5160
elif args.command == "mcp":
52-
from agentos.mcp.adapter import toolspec_to_input_schema # noqa: F401
5361
from agentos.tools import get_builtin_tools
62+
from agentos.mcp import MCPServer
63+
5464
tools = get_builtin_tools()
55-
print(f"MCP server ready with {len(tools)} tools")
56-
print("Note: full MCP server requires the 'mcp' extra — pip install agentos-platform[mcp]")
65+
print(f"MCP server ready with {len(tools)} tools (transport={args.transport})")
66+
67+
server = MCPServer(
68+
name=args.name,
69+
tools=tools,
70+
transport=args.transport,
71+
sse_host=args.host,
72+
sse_port=args.port,
73+
)
74+
server.run()
5775

5876
elif args.command == "version":
5977
from agentos import __version__

0 commit comments

Comments
 (0)