Skip to content

Commit 0c58161

Browse files
support get agent cardin mcp server template (#86)
1 parent f64f113 commit 0c58161

File tree

1 file changed

+12
-3
lines changed
  • veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src

1 file changed

+12
-3
lines changed

veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from agent import agent_run_config
2020
from fastapi import FastAPI
2121
from fastmcp import FastMCP
22-
22+
from google.adk.a2a.utils.agent_card_builder import AgentCardBuilder
2323
from veadk.a2a.ve_a2a_server import init_app
2424
from veadk.runner import Runner
2525
from veadk.tracing.telemetry.exporters.apmplus_exporter import APMPlusExporter
@@ -39,6 +39,8 @@
3939
agent = agent_run_config.agent
4040
short_term_memory = agent_run_config.short_term_memory
4141

42+
agent_card_builder = AgentCardBuilder(agent=agent)
43+
4244

4345
def load_tracer() -> None:
4446
EXPORTER_REGISTRY = {
@@ -104,18 +106,25 @@ async def run_agent(
104106
return run_agent
105107

106108

109+
async def agent_card() -> dict:
110+
agent_card = await agent_card_builder.build()
111+
return agent_card.model_dump()
112+
113+
107114
load_tracer()
108115

116+
# Build a run_agent function for building MCP server
117+
run_agent_func = build_mcp_run_agent_func()
118+
109119
a2a_app = init_app(
110120
server_url="0.0.0.0",
111121
app_name=app_name,
112122
agent=agent,
113123
short_term_memory=short_term_memory,
114124
)
115125

116-
# Build a run_agent function for building MCP server
117-
run_agent_func = build_mcp_run_agent_func()
118126
a2a_app.post("/run_agent", operation_id="run_agent", tags=["mcp"])(run_agent_func)
127+
a2a_app.get("/agent_card", operation_id="agent_card", tags=["mcp"])(agent_card)
119128

120129

121130
# === Build mcp server ===

0 commit comments

Comments
 (0)