Skip to content

Commit 8c40922

Browse files
committed
fix(vefaas): VeA2AServer add post run_agent to mcp server
1 parent 86eeee7 commit 8c40922

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

veadk/a2a/ve_a2a_server.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from veadk.a2a.agent_card import get_agent_card
2222
from veadk.a2a.ve_agent_executor import VeAgentExecutor
2323
from veadk.memory.short_term_memory import ShortTermMemory
24+
from veadk.runner import Runner
2425

2526

2627
class VeA2AServer:
@@ -48,8 +49,39 @@ def build(self) -> FastAPI:
4849
)
4950
app = app_application.build() # build routes
5051

51-
# import uvicorn
52-
# uvicorn.run(app, host="127.0.0.1", port=8000)
52+
runner = Runner(
53+
agent=self.agent_executor.agent,
54+
short_term_memory=self.agent_executor.short_term_memory,
55+
app_name=self.agent_executor.app_name,
56+
user_id="",
57+
)
58+
59+
@app.post("/run_agent", operation_id="run_agent", tags=["mcp"])
60+
async def run_agent(
61+
user_input: str,
62+
user_id: str = "unknown_user",
63+
session_id: str = "unknown_session",
64+
) -> str:
65+
"""
66+
Execute agent with user input and return final output
67+
Args:
68+
user_input: User's input message
69+
user_id: User identifier
70+
session_id: Session identifier
71+
Returns:
72+
Final agent response
73+
"""
74+
# Set user_id for runner
75+
runner.user_id = user_id
76+
77+
# Running agent and get final output
78+
final_output = await runner.run(
79+
messages=user_input,
80+
session_id=session_id,
81+
)
82+
83+
return final_output
84+
5385
return app
5486

5587

veadk/cli/services/vefaas/template/src/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
short_term_memory=short_term_memory,
7373
)
7474

75-
mcp = FastMCP.from_fastapi(app=a2a_app, name=app_name)
75+
mcp = FastMCP.from_fastapi(app=a2a_app, name=app_name, include_tags={"mcp"})
7676

7777
# Create MCP ASGI app
7878
mcp_app = mcp.http_app(path="/")

0 commit comments

Comments
 (0)