Skip to content

Agent Mesh

bridge: prefix MCP tool handlers with handle and group each with its types

Tomas Tormo723e515df1f3
diff --git a/cmd/sam-a2a-bridge/a2a.go b/cmd/sam-a2a-bridge/a2a.go
index 62889950..43fa1e65 100644
--- a/cmd/sam-a2a-bridge/a2a.go
+++ b/cmd/sam-a2a-bridge/a2a.go
@@ -31,6 +31,8 @@ import (
"github.com/a2aproject/a2a-go/v2/a2aclient"
)
+const maxAttachmentBytes = 5 << 20
+
type bridgeConfig struct {
sidecarURL string
token string
@@ -42,6 +44,73 @@ func (c bridgeConfig) meshURL(peer, service string) string {
return strings.TrimRight(c.sidecarURL, "/") + "/sam/" + url.PathEscape(peer) + "/a2a/" + url.PathEscape(service)
}
+type getAgentCardParams struct {
+ Peer string `json:"peer" jsonschema:"Peer ID of the node hosting the agent"`
+ Service string `json:"service" jsonschema:"Name of the a2a service registered on that peer"`
+}
+
+// agentCardSummary trims the agent card to what a model can use; full cards
+// carry security schemas and provider blurbs a model never needs.
+type agentCardSummary struct {
+ Name string `json:"name"`
+ Description string `json:"description,omitempty"`
+ Version string `json:"version,omitempty"`
+ DefaultInputModes []string `json:"default_input_modes,omitempty"`
+ DefaultOutputModes []string `json:"default_output_modes,omitempty"`
+ Streaming bool `json:"streaming"`
+ Skills []agentCardSkill `json:"skills,omitempty"`
+}
+
+type agentCardSkill struct {
+ ID string `json:"id"`
+ Name string `json:"name,omitempty"`
+ Description string `json:"description,omitempty"`
+ Tags []string `json:"tags,omitempty"`
+ Examples []string `json:"examples,omitempty"`
+}
+
+func handleGetAgentCard(ctx context.Context, cfg bridgeConfig, p getAgentCardParams) (agentCardSummary, error) {
+ httpClient := &http.Client{
+ Timeout: 30 * time.Second,
+ Transport: &samTransport{base: http.DefaultTransport, token: cfg.token},
+ }
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet,
+ cfg.meshURL(p.Peer, p.Service)+"/.well-known/agent-card.json", nil)
+ if err != nil {
+ return agentCardSummary{}, err
+ }
+ resp, err := httpClient.Do(req)
+ if err != nil {
+ return agentCardSummary{}, err
+ }
+ defer func() { _ = resp.Body.Close() }()
+
+ // Wire keys match a2a-go v2.5.0's a2a.AgentCard/AgentCapabilities/AgentSkill json tags exactly.
+ var wire struct {
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Version string `json:"version"`
+ DefaultInputModes []string `json:"defaultInputModes"`
+ DefaultOutputModes []string `json:"defaultOutputModes"`
+ Capabilities struct {
+ Streaming bool `json:"streaming"`
+ } `json:"capabilities"`
+ Skills []agentCardSkill `json:"skills"`
+ }
+ if err := json.NewDecoder(resp.Body).Decode(&wire); err != nil {
+ return agentCardSummary{}, fmt.Errorf("agent card is not valid JSON: %w", err)
+ }
+ return agentCardSummary{
+ Name: wire.Name,
+ Description: wire.Description,
+ Version: wire.Version,
+ DefaultInputModes: wire.DefaultInputModes,
+ DefaultOutputModes: wire.DefaultOutputModes,
+ Streaming: wire.Capabilities.Streaming,
+ Skills: wire.Skills,
+ }, nil
+}
+
type sendAgentTaskParams struct {
Peer string `json:"peer" jsonschema:"Peer ID of the node hosting the agent"`
Service string `json:"service" jsonschema:"Name of the a2a service registered on that peer"`
@@ -54,7 +123,74 @@ type sendAgentTaskParams struct {
TaskID string `json:"task_id,omitempty" jsonschema:"Reply into an existing task, e.g. one in state input-required"`
}
-const maxAttachmentBytes = 5 << 20
+type taskResult struct {
+ TaskID string `json:"task_id"`
+ ContextID string `json:"context_id"`
+ State string `json:"state"`
+ Text string `json:"text"`
+ Data []any `json:"data,omitempty"`
+ Files []string `json:"files,omitempty"`
+}
+
+func handleSendAgentTask(ctx context.Context, cfg bridgeConfig, p sendAgentTaskParams) (taskResult, error) {
+ client, err := newMeshClient(ctx, cfg, p.Peer, p.Service, p.RequiredLabels)
+ if err != nil {
+ return taskResult{}, err
+ }
+ defer client.Destroy()
+
+ parts, err := buildParts(p)
+ if err != nil {
+ return taskResult{}, err
+ }
+ var msg *a2a.Message
+ if p.TaskID != "" || p.ContextID != "" {
+ msg = a2a.NewMessageForTask(a2a.MessageRoleUser,
+ a2a.TaskInfo{TaskID: a2a.TaskID(p.TaskID), ContextID: p.ContextID}, parts...)
+ } else {
+ msg = a2a.NewMessage(a2a.MessageRoleUser, parts...)
+ }
+ result, err := client.SendMessage(ctx, &a2a.SendMessageRequest{Message: msg})
+ if err != nil {
+ return taskResult{}, err
+ }
+ return toTaskResult(cfg, result)
+}
+
+type getAgentTaskParams struct {
+ Peer string `json:"peer" jsonschema:"Peer ID of the node hosting the agent"`
+ Service string `json:"service" jsonschema:"Name of the a2a service registered on that peer"`
+ TaskID string `json:"task_id" jsonschema:"ID of the task to fetch"`
+}
+
+func handleGetAgentTask(ctx context.Context, cfg bridgeConfig, p getAgentTaskParams) (taskResult, error) {
+ client, err := newMeshClient(ctx, cfg, p.Peer, p.Service, "")
+ if err != nil {
+ return taskResult{}, err
+ }
+ defer client.Destroy()
+
+ task, err := client.GetTask(ctx, &a2a.GetTaskRequest{ID: a2a.TaskID(p.TaskID)})
+ if err != nil {
+ return taskResult{}, err
+ }
+ return toTaskResult(cfg, task)
+}
+
+func newMeshClient(ctx context.Context, cfg bridgeConfig, peer, service, requiredLabels string) (*a2aclient.Client, error) {
+ httpClient := &http.Client{
+ Timeout: 60 * time.Second,
+ Transport: &samTransport{
+ base: http.DefaultTransport,
+ token: cfg.token,
+ requiredLabels: requiredLabels,
+ },
+ }
+ return a2aclient.NewFromEndpoints(ctx,
+ []*a2a.AgentInterface{a2a.NewAgentInterface(cfg.meshURL(peer, service), a2a.TransportProtocolJSONRPC)},
+ a2aclient.WithJSONRPCTransport(httpClient),
+ )
+}
// buildParts builds the message parts in a fixed order (text, data, file) so
// wire output is deterministic across calls with the same params.
@@ -107,75 +243,6 @@ func fileToPart(path, nameOverride string) (*a2a.Part, error) {
return part, nil
}
-type getAgentTaskParams struct {
- Peer string `json:"peer" jsonschema:"Peer ID of the node hosting the agent"`
- Service string `json:"service" jsonschema:"Name of the a2a service registered on that peer"`
- TaskID string `json:"task_id" jsonschema:"ID of the task to fetch"`
-}
-
-type taskResult struct {
- TaskID string `json:"task_id"`
- ContextID string `json:"context_id"`
- State string `json:"state"`
- Text string `json:"text"`
- Data []any `json:"data,omitempty"`
- Files []string `json:"files,omitempty"`
-}
-
-func newMeshClient(ctx context.Context, cfg bridgeConfig, peer, service, requiredLabels string) (*a2aclient.Client, error) {
- httpClient := &http.Client{
- Timeout: 60 * time.Second,
- Transport: &samTransport{
- base: http.DefaultTransport,
- token: cfg.token,
- requiredLabels: requiredLabels,
- },
- }
- return a2aclient.NewFromEndpoints(ctx,
- []*a2a.AgentInterface{a2a.NewAgentInterface(cfg.meshURL(peer, service), a2a.TransportProtocolJSONRPC)},
- a2aclient.WithJSONRPCTransport(httpClient),
- )
-}
-
-func sendAgentTask(ctx context.Context, cfg bridgeConfig, p sendAgentTaskParams) (taskResult, error) {
- client, err := newMeshClient(ctx, cfg, p.Peer, p.Service, p.RequiredLabels)
- if err != nil {
- return taskResult{}, err
- }
- defer client.Destroy()
-
- parts, err := buildParts(p)
- if err != nil {
- return taskResult{}, err
- }
- var msg *a2a.Message
- if p.TaskID != "" || p.ContextID != "" {
- msg = a2a.NewMessageForTask(a2a.MessageRoleUser,
- a2a.TaskInfo{TaskID: a2a.TaskID(p.TaskID), ContextID: p.ContextID}, parts...)
- } else {
- msg = a2a.NewMessage(a2a.MessageRoleUser, parts...)
- }
- result, err := client.SendMessage(ctx, &a2a.SendMessageRequest{Message: msg})
- if err != nil {
- return taskResult{}, err
- }
- return toTaskResult(cfg, result)
-}
-
-func getAgentTask(ctx context.Context, cfg bridgeConfig, p getAgentTaskParams) (taskResult, error) {
- client, err := newMeshClient(ctx, cfg, p.Peer, p.Service, "")
- if err != nil {
- return taskResult{}, err
- }
- defer client.Destroy()
-
- task, err := client.GetTask(ctx, &a2a.GetTaskRequest{ID: a2a.TaskID(p.TaskID)})
- if err != nil {
- return taskResult{}, err
- }
- return toTaskResult(cfg, task)
-}
-
// toTaskResult flattens the SDK's Message|Task union into the fields a
// harness needs, also collecting data/file parts from every location;
// a direct Message reply is final, hence state "completed".
@@ -275,70 +342,3 @@ func saveFilePart(dir, taskID, name string, data []byte) (string, error) {
}
return path, nil
}
-
-type getAgentCardParams struct {
- Peer string `json:"peer" jsonschema:"Peer ID of the node hosting the agent"`
- Service string `json:"service" jsonschema:"Name of the a2a service registered on that peer"`
-}
-
-// agentCardSummary trims the agent card to what a model can use; full cards
-// carry security schemas and provider blurbs a model never needs.
-type agentCardSummary struct {
- Name string `json:"name"`
- Description string `json:"description,omitempty"`
- Version string `json:"version,omitempty"`
- DefaultInputModes []string `json:"default_input_modes,omitempty"`
- DefaultOutputModes []string `json:"default_output_modes,omitempty"`
- Streaming bool `json:"streaming"`
- Skills []agentCardSkill `json:"skills,omitempty"`
-}
-
-type agentCardSkill struct {
- ID string `json:"id"`
- Name string `json:"name,omitempty"`
- Description string `json:"description,omitempty"`
- Tags []string `json:"tags,omitempty"`
- Examples []string `json:"examples,omitempty"`
-}
-
-func getAgentCard(ctx context.Context, cfg bridgeConfig, p getAgentCardParams) (agentCardSummary, error) {
- httpClient := &http.Client{
- Timeout: 30 * time.Second,
- Transport: &samTransport{base: http.DefaultTransport, token: cfg.token},
- }
- req, err := http.NewRequestWithContext(ctx, http.MethodGet,
- cfg.meshURL(p.Peer, p.Service)+"/.well-known/agent-card.json", nil)
- if err != nil {
- return agentCardSummary{}, err
- }
- resp, err := httpClient.Do(req)
- if err != nil {
- return agentCardSummary{}, err
- }
- defer func() { _ = resp.Body.Close() }()
-
- // Wire keys match a2a-go v2.5.0's a2a.AgentCard/AgentCapabilities/AgentSkill json tags exactly.
- var wire struct {
- Name string `json:"name"`
- Description string `json:"description"`
- Version string `json:"version"`
- DefaultInputModes []string `json:"defaultInputModes"`
- DefaultOutputModes []string `json:"defaultOutputModes"`
- Capabilities struct {
- Streaming bool `json:"streaming"`
- } `json:"capabilities"`
- Skills []agentCardSkill `json:"skills"`
- }
- if err := json.NewDecoder(resp.Body).Decode(&wire); err != nil {
- return agentCardSummary{}, fmt.Errorf("agent card is not valid JSON: %w", err)
- }
- return agentCardSummary{
- Name: wire.Name,
- Description: wire.Description,
- Version: wire.Version,
- DefaultInputModes: wire.DefaultInputModes,
- DefaultOutputModes: wire.DefaultOutputModes,
- Streaming: wire.Capabilities.Streaming,
- Skills: wire.Skills,
- }, nil
-}
diff --git a/cmd/sam-a2a-bridge/a2a_test.go b/cmd/sam-a2a-bridge/a2a_test.go
index 1268b298..ddd0a36e 100644
--- a/cmd/sam-a2a-bridge/a2a_test.go
+++ b/cmd/sam-a2a-bridge/a2a_test.go
@@ -58,7 +58,7 @@ func TestSendAgentTaskMapsTaskResult(t *testing.T) {
defer srv.Close()
cfg := bridgeConfig{sidecarURL: srv.URL, token: "tok"}
- got, err := sendAgentTask(context.Background(), cfg, sendAgentTaskParams{
+ got, err := handleSendAgentTask(context.Background(), cfg, sendAgentTaskParams{
Peer: "12D3KooWpeer", Service: "echo", Message: "hi",
})
if err != nil {
@@ -86,7 +86,7 @@ func TestSendAgentTaskMapsMessageResult(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", msg, nil)
defer srv.Close()
- got, err := sendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
+ got, err := handleSendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", Message: "2+2?"})
if err != nil {
t.Fatal(err)
@@ -105,7 +105,7 @@ func TestSendAgentTaskThreadsContinuationIDs(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", task, &rpc)
defer srv.Close()
- _, err := sendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
+ _, err := handleSendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", Message: "more",
ContextID: "c3", TaskID: "t3"})
if err != nil {
@@ -124,7 +124,7 @@ func TestSendAgentTaskSurfacesSidecarRefusal(t *testing.T) {
}))
defer srv.Close()
- _, err := sendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
+ _, err := handleSendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", Message: "hi",
RequiredLabels: "region=us-east-1"})
if err == nil {
@@ -142,7 +142,7 @@ func TestGetAgentTaskMapsResult(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", task, &rpc)
defer srv.Close()
- got, err := getAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
+ got, err := handleGetAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
getAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", TaskID: "t4"})
if err != nil {
t.Fatal(err)
@@ -175,7 +175,7 @@ func TestSendAgentTaskWithDataPart(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", `{"task":`+task+`}`, &rpc)
defer srv.Close()
- _, err := sendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
+ _, err := handleSendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo",
Data: map[string]any{"answer": 42, "unit": "cm"}})
if err != nil {
@@ -198,7 +198,7 @@ func TestSendAgentTaskWithFile(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", `{"task":`+task+`}`, &rpc)
defer srv.Close()
- _, err := sendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
+ _, err := handleSendAgentTask(context.Background(), bridgeConfig{sidecarURL: srv.URL},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", FilePath: path})
if err != nil {
t.Fatal(err)
@@ -219,7 +219,7 @@ func TestSendAgentTaskFileTooLarge(t *testing.T) {
if err := os.WriteFile(path, make([]byte, maxAttachmentBytes+1), 0o644); err != nil {
t.Fatal(err)
}
- _, err := sendAgentTask(context.Background(), bridgeConfig{sidecarURL: "http://127.0.0.1:1"},
+ _, err := handleSendAgentTask(context.Background(), bridgeConfig{sidecarURL: "http://127.0.0.1:1"},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", FilePath: path})
if err == nil || !strings.Contains(err.Error(), "attachment cap") {
t.Fatalf("oversized file must be rejected before any request, got: %v", err)
@@ -227,7 +227,7 @@ func TestSendAgentTaskFileTooLarge(t *testing.T) {
}
func TestSendAgentTaskRequiresContent(t *testing.T) {
- _, err := sendAgentTask(context.Background(), bridgeConfig{sidecarURL: "http://127.0.0.1:1"},
+ _, err := handleSendAgentTask(context.Background(), bridgeConfig{sidecarURL: "http://127.0.0.1:1"},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo"})
if err == nil || !strings.Contains(err.Error(), "nothing to send") {
t.Fatalf("empty send must be rejected, got: %v", err)
@@ -246,7 +246,7 @@ func TestResultCollectsDataAndFiles(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", `{"task":`+task+`}`, nil)
defer srv.Close()
- got, err := sendAgentTask(context.Background(),
+ got, err := handleSendAgentTask(context.Background(),
bridgeConfig{sidecarURL: srv.URL, downloadDir: downloads},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", Message: "go"})
if err != nil {
@@ -303,7 +303,7 @@ func TestResultIncludesFileURIs(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", `{"task":`+task+`}`, nil)
defer srv.Close()
- got, err := sendAgentTask(context.Background(),
+ got, err := handleSendAgentTask(context.Background(),
bridgeConfig{sidecarURL: srv.URL, downloadDir: t.TempDir()},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", Message: "go"})
if err != nil {
@@ -331,7 +331,7 @@ func TestGetAgentCardTrims(t *testing.T) {
}))
defer srv.Close()
- got, err := getAgentCard(context.Background(), bridgeConfig{sidecarURL: srv.URL},
+ got, err := handleGetAgentCard(context.Background(), bridgeConfig{sidecarURL: srv.URL},
getAgentCardParams{Peer: "12D3KooWpeer", Service: "echo"})
if err != nil {
t.Fatal(err)
@@ -362,7 +362,7 @@ func TestResultErrorIncludesTaskID(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", `{"task":`+task+`}`, nil)
defer srv.Close()
- _, err := sendAgentTask(context.Background(),
+ _, err := handleSendAgentTask(context.Background(),
bridgeConfig{sidecarURL: srv.URL, downloadDir: "/nonexistent-dir-xyz"},
sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", Message: "go"})
if err == nil {
diff --git a/cmd/sam-a2a-bridge/main.go b/cmd/sam-a2a-bridge/main.go
index 53254bd4..7cd1f21a 100644
--- a/cmd/sam-a2a-bridge/main.go
+++ b/cmd/sam-a2a-bridge/main.go
@@ -57,6 +57,12 @@ func newBridgeServer(cfg bridgeConfig) *mcp.Server {
Version: "0.1.0",
}, nil)
+ mcp.AddTool(server, &mcp.Tool{
+ Name: "get_agent_card",
+ Description: "Fetch a mesh agent's card, trimmed to essentials: skills with examples, accepted " +
+ "input/output MIME types, and streaming support. Use before composing data/file sends.",
+ }, mcpTool(cfg, handleGetAgentCard))
+
mcp.AddTool(server, &mcp.Tool{
Name: "send_agent_task",
Description: "Send a message to an A2A agent on the SAM mesh: plain text (message), structured JSON " +
@@ -65,40 +71,22 @@ func newBridgeServer(cfg bridgeConfig) *mcp.Server {
"disk and returned as paths. Poll non-terminal states with get_agent_task. Pass context_id to " +
"continue a conversation, task_id to reply into a task waiting for input. required_labels makes " +
"the local node refuse fail-closed unless the provider attested them.",
- }, handleSendAgentTask(cfg))
+ }, mcpTool(cfg, handleSendAgentTask))
mcp.AddTool(server, &mcp.Tool{
Name: "get_agent_task",
Description: "Fetch the current state and output of a task previously created with send_agent_task; " +
"same result shape, including data and files.",
- }, handleGetAgentTask(cfg))
-
- mcp.AddTool(server, &mcp.Tool{
- Name: "get_agent_card",
- Description: "Fetch a mesh agent's card, trimmed to essentials: skills with examples, accepted " +
- "input/output MIME types, and streaming support. Use before composing data/file sends.",
- }, handleGetAgentCard(cfg))
+ }, mcpTool(cfg, handleGetAgentTask))
return server
}
-func handleSendAgentTask(cfg bridgeConfig) func(context.Context, *mcp.CallToolRequest, sendAgentTaskParams) (*mcp.CallToolResult, any, error) {
- return func(ctx context.Context, _ *mcp.CallToolRequest, p sendAgentTaskParams) (*mcp.CallToolResult, any, error) {
- res, err := sendAgentTask(ctx, cfg, p)
- return toolResult(res, err)
- }
-}
-
-func handleGetAgentTask(cfg bridgeConfig) func(context.Context, *mcp.CallToolRequest, getAgentTaskParams) (*mcp.CallToolResult, any, error) {
- return func(ctx context.Context, _ *mcp.CallToolRequest, p getAgentTaskParams) (*mcp.CallToolResult, any, error) {
- res, err := getAgentTask(ctx, cfg, p)
- return toolResult(res, err)
- }
-}
-
-func handleGetAgentCard(cfg bridgeConfig) func(context.Context, *mcp.CallToolRequest, getAgentCardParams) (*mcp.CallToolResult, any, error) {
- return func(ctx context.Context, _ *mcp.CallToolRequest, p getAgentCardParams) (*mcp.CallToolResult, any, error) {
- res, err := getAgentCard(ctx, cfg, p)
+// mcpTool adapts a handler to the go-sdk tool signature, routing errors
+// through toolResult so refusals surface as tool errors.
+func mcpTool[Params, Result any](cfg bridgeConfig, handler func(context.Context, bridgeConfig, Params) (Result, error)) func(context.Context, *mcp.CallToolRequest, Params) (*mcp.CallToolResult, any, error) {
+ return func(ctx context.Context, _ *mcp.CallToolRequest, p Params) (*mcp.CallToolResult, any, error) {
+ res, err := handler(ctx, cfg, p)
return toolResult(res, err)
}
}
diff --git a/cmd/sam-a2a-bridge/main_test.go b/cmd/sam-a2a-bridge/main_test.go
index b7e38c26..91ebd28a 100644
--- a/cmd/sam-a2a-bridge/main_test.go
+++ b/cmd/sam-a2a-bridge/main_test.go
@@ -44,7 +44,7 @@ func TestHandleSendAgentTaskSuccess(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", task, nil)
defer srv.Close()
- res, _, err := handleSendAgentTask(bridgeConfig{sidecarURL: srv.URL})(
+ res, _, err := mcpTool(bridgeConfig{sidecarURL: srv.URL}, handleSendAgentTask)(
context.Background(), nil, sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", Message: "hi"})
if err != nil {
t.Fatal(err)
@@ -67,7 +67,7 @@ func TestHandleSendAgentTaskRefusalIsToolError(t *testing.T) {
}))
defer srv.Close()
- res, _, err := handleSendAgentTask(bridgeConfig{sidecarURL: srv.URL})(
+ res, _, err := mcpTool(bridgeConfig{sidecarURL: srv.URL}, handleSendAgentTask)(
context.Background(), nil, sendAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo",
Message: "hi", RequiredLabels: "region=us-east-1"})
if err != nil {
@@ -88,7 +88,7 @@ func TestHandleGetAgentTask(t *testing.T) {
srv := fakeSidecar(t, "/sam/12D3KooWpeer/a2a/echo", task, nil)
defer srv.Close()
- res, _, err := handleGetAgentTask(bridgeConfig{sidecarURL: srv.URL})(
+ res, _, err := mcpTool(bridgeConfig{sidecarURL: srv.URL}, handleGetAgentTask)(
context.Background(), nil, getAgentTaskParams{Peer: "12D3KooWpeer", Service: "echo", TaskID: "t9"})
if err != nil {
t.Fatal(err)
@@ -115,7 +115,7 @@ func TestHandleGetAgentCard(t *testing.T) {
}))
defer srv.Close()
- res, _, err := handleGetAgentCard(bridgeConfig{sidecarURL: srv.URL})(
+ res, _, err := mcpTool(bridgeConfig{sidecarURL: srv.URL}, handleGetAgentCard)(
context.Background(), nil, getAgentCardParams{Peer: "12D3KooWpeer", Service: "echo"})
if err != nil {
t.Fatal(err)