Skip to content

Commit 21e22a9

Browse files
floritangezakahan
andauthored
fix(vefaas): fix mcp doc and streamable-http (#57)
* test(vefaas): update Unitest of CloudAgentEngine and CloudApp * fix(test): test_cloud typer dependency * test(vefaas): volcenginesdkcore dependency, uv sync --all-extras * test(vefaas): modify chinese annotation * test(vefaas): fix deploy docs * feat(vefaas): add mcp server pre-commit * feat(vefaas): add mcp server pyproject cli * fix(vefaas): fix mcp mount a2a * fix(vefaas): fix run.sh * fix(vefaas): fix app.py pre * fix(vefaas): VeA2AServer add post run_agent to mcp server * fix(vefaas): mcp server in app.py * fix(vefaas): fix mcp doc and streamable-http --------- Co-authored-by: tangou <[email protected]> Co-authored-by: hanzhi <[email protected]>
1 parent 52db23a commit 21e22a9

File tree

1 file changed

+19
-15
lines changed
  • veadk/cli/services/vefaas/template/src

1 file changed

+19
-15
lines changed

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from fastmcp import FastMCP
2323
from fastapi import FastAPI
2424

25-
2625
# ==============================================================================
2726
# Tracer Config ================================================================
2827

@@ -81,23 +80,21 @@
8180
user_id="",
8281
)
8382

83+
# Prepare doc string
84+
run_agent_doc = f"""{agent.description}
85+
Args:
86+
user_input: User's input message (required).
87+
user_id: User identifier. Defaults to "mcp_user".
88+
session_id: Session identifier. Defaults to "mcp_session".
89+
Returns:
90+
Final agent response as a string."""
91+
8492

85-
# mcp server
86-
@a2a_app.post("/run_agent", operation_id="run_agent", tags=["mcp"])
8793
async def run_agent(
8894
user_input: str,
89-
user_id: str = "unknown_user",
90-
session_id: str = "unknown_session",
95+
user_id: str = "mcp_user",
96+
session_id: str = "mcp_session",
9197
) -> str:
92-
"""
93-
Execute agent with user input and return final output
94-
Args:
95-
user_input: User's input message
96-
user_id: User identifier
97-
session_id: Session identifier
98-
Returns:
99-
Final agent response
100-
"""
10198
# Set user_id for runner
10299
runner.user_id = user_id
103100

@@ -109,10 +106,17 @@ async def run_agent(
109106
return final_output
110107

111108

109+
run_agent.__doc__ = run_agent_doc
110+
111+
# Add post route to run_agent
112+
run_agent = a2a_app.post("/run_agent", operation_id="run_agent", tags=["mcp"])(
113+
run_agent
114+
)
115+
112116
mcp = FastMCP.from_fastapi(app=a2a_app, name=app_name, include_tags={"mcp"})
113117

114118
# Create MCP ASGI app
115-
mcp_app = mcp.http_app(path="/")
119+
mcp_app = mcp.http_app(path="/", transport="streamable-http")
116120

117121

118122
# Combined lifespan management

0 commit comments

Comments
 (0)