MCPcopy Create free account
hub / github.com/astercloud/aster / GetAgentCard

Method GetAgentCard

pkg/a2a/handler.go:26–59  ·  view source on GitHub ↗

GetAgentCard 处理 Agent Card 请求 GET /.well-known/{agentId}/agent-card.json

(c *gin.Context)

Source from the content-addressed store, hash-verified

24// GetAgentCard 处理 Agent Card 请求
25// GET /.well-known/{agentId}/agent-card.json
26func (h *Handler) GetAgentCard(c *gin.Context) {
27 ctx := c.Request.Context()
28 agentID := c.Param("agentId")
29
30 if agentID == "" {
31 c.JSON(http.StatusBadRequest, gin.H{
32 "success": false,
33 "error": gin.H{
34 "code": "bad_request",
35 "message": "Missing agentId parameter",
36 },
37 })
38 return
39 }
40
41 logging.Info(ctx, "a2a.get_agent_card", map[string]any{
42 "agent_id": agentID,
43 })
44
45 card, err := h.server.GetAgentCard(agentID)
46 if err != nil {
47 c.JSON(http.StatusNotFound, gin.H{
48 "success": false,
49 "error": gin.H{
50 "code": "not_found",
51 "message": "Agent not found: " + err.Error(),
52 },
53 })
54 return
55 }
56
57 // A2A 规范要求直接返回 Agent Card JSON,不包装在 success/data 中
58 c.JSON(http.StatusOK, card)
59}
60
61// HandleJSONRPC 处理 JSON-RPC 2.0 请求
62// POST /a2a/{agentId}

Callers

nothing calls this directly

Calls 4

InfoFunction · 0.92
JSONMethod · 0.80
ContextMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected