MCPcopy
hub / github.com/docker/docker-agent / Tools

Method Tools

pkg/tools/a2a/a2a.go:120–163  ·  view source on GitHub ↗

Tools returns the tools available from the remote A2A agent.

(_ context.Context)

Source from the content-addressed store, hash-verified

118
119// Tools returns the tools available from the remote A2A agent.
120func (t *Toolset) Tools(_ context.Context) ([]tools.Tool, error) {
121 t.mu.RLock()
122 card := t.card
123 t.mu.RUnlock()
124
125 if card == nil {
126 return nil, errors.New("A2A toolset not started")
127 }
128
129 // If skills are defined, create a tool for each skill; otherwise create one tool for the agent
130 skills := card.Skills
131 if len(skills) == 0 {
132 skills = []a2a.AgentSkill{{ID: card.Name, Name: card.Name, Description: card.Description}}
133 }
134
135 result := make([]tools.Tool, 0, len(skills))
136 for _, skill := range skills {
137 name := cmp.Or(skill.ID, skill.Name)
138 if t.name != "" {
139 name = fmt.Sprintf("%s_%s", t.name, name)
140 }
141 name = sanitizeToolName(name)
142
143 result = append(result, tools.Tool{
144 Name: name,
145 Category: "a2a",
146 Description: fmt.Sprintf("Calls the '%s' skill of the %s agent. %s", skill.Name, card.Name, skill.Description),
147 Parameters: map[string]any{
148 "type": "object",
149 "properties": map[string]any{
150 "message": map[string]any{
151 "type": "string",
152 "description": "The message or request to send to the agent",
153 },
154 },
155 "required": []string{"message"},
156 },
157 Handler: t.createHandler(),
158 Annotations: tools.ToolAnnotations{Title: name},
159 })
160 }
161
162 return result, nil
163}
164
165// Start connects to the A2A agent and fetches the agent card.
166func (t *Toolset) Start(ctx context.Context) error {

Calls 3

createHandlerMethod · 0.95
sanitizeToolNameFunction · 0.70
NewMethod · 0.45

Tested by 1