Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
tests/integration: SDK members accept A2A, publish nothing
Antonio Ojeab96b3cb721c6
diff --git a/tests/integration/sdk_examples_test.go b/tests/integration/sdk_examples_test.goindex d0b869e5..fbdda17d 100644--- a/tests/integration/sdk_examples_test.go+++ b/tests/integration/sdk_examples_test.go@@ -19,9 +19,6 @@ import ("bytes""context""fmt"- "io"- "net/http"- "net/http/httptest""os""os/exec""path/filepath"@@ -75,45 +72,31 @@ var sdkExampleLaunchers = []sdkExampleLauncher{},}-// sdkExampleServer is a running serve example.-type sdkExampleServer struct {- name string- // service is what it publishes, greeter-<lang>, as the testnet canaries do.- service string- peerID string+// sdkExampleAgent is a running agent example.+type sdkExampleAgent struct {+ name string+ peerID string}-var servingLine = regexp.MustCompile(`^serving (.*) as (\S+)$`)+var acceptingLine = regexp.MustCompile(`^accepting (\S+) as (\S+)$`)// TestNativeSDKExamples runs the programs the SDK READMEs and the Native// SDKs guide embed, unchanged, against a real mesh, configured as the// testnet canaries are (.github/k8s/sam-sdk-canary-template.yaml). Each-// SDK's serve example enrolls with an OIDC token through SAM_JWT_PATH, the-// way a Kubernetes workload does, and publishes mcp://greeter-<lang>,-// a2a://greeter-<lang> and inference://ollama, the last forwarding to a-// stand-in for Ollama this test runs. Each SDK's call example enrolls with-// a bootstrap token, reaches the sam-node's mcp://calc and the other-// language's greeter (its own when the other toolchain is missing), naming-// providers only by what discover returned; the SDK finds the path through-// the router by itself. The first run spends the token, the later runs-// resume from the state directory without one.+// SDK's agent example enrolls with an OIDC token through SAM_JWT_PATH, the+// way a Kubernetes workload does, and accepts A2A requests for a2a://agent,+// publishing nothing. Each SDK's call example enrolls with a bootstrap+// token, reaches the sam-node's mcp://calc by name, and the other language's+// agent (its own when the other toolchain is missing) by peer ID; the SDK+// finds the path through the router by itself. The first run spends the+// token, the later runs resume from the state directory without one.func TestNativeSDKExamples(t *testing.T) {mesh := startSDKMesh(t)- ollama := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {- if r.URL.Path != "/v1/models" {- http.NotFound(w, r)- return- }- w.Header().Set("Content-Type", "application/json")- _, _ = io.WriteString(w, `{"object":"list","data":[{"id":"gemma3","object":"model","owned_by":"`+r.Header.Get("X-Peer-Id")+`"}]}`)- }))- t.Cleanup(ollama.Close)-var launchers []sdkExampleLaunchervar cmds []*exec.Cmdfor _, l := range sdkExampleLaunchers {- cmd, skip := l.cmd(context.Background(), mesh.root, "serve", "greeter-"+l.name)+ cmd, skip := l.cmd(context.Background(), mesh.root, "agent")if skip != "" {t.Logf("%s SDK skipped: %s", l.name, skip)continue@@ -124,7 +107,7 @@ func TestNativeSDKExamples(t *testing.T) {if len(launchers) == 0 {t.Skip("no SDK toolchain available; see sdk/README.md")}- servers := make([]*sdkExampleServer, len(launchers))+ agents := make([]*sdkExampleAgent, len(launchers))errs := make([]error, len(launchers))var wg sync.WaitGroupfor i := range launchers {@@ -137,13 +120,12 @@ func TestNativeSDKExamples(t *testing.T) {"SAM_CONTROL_PLANE_URL="+mesh.baseURL,"SAM_JWT_PATH="+jwtPath,"SAM_STATE_DIR="+filepath.Join(t.TempDir(), "state"),- "OLLAMA_URL="+ollama.URL,)cmds[i].Dir = mesh.rootwg.Add(1)go func(i int) {defer wg.Done()- servers[i], errs[i] = startExampleServer(t, launchers[i].name, "greeter-"+launchers[i].name, cmds[i])+ agents[i], errs[i] = startExampleAgent(t, launchers[i].name, cmds[i])}(i)}wg.Wait()@@ -152,30 +134,24 @@ func TestNativeSDKExamples(t *testing.T) {t.Fatal(err)}}- for _, s := range servers {- waitForPeerOnRouter(t, mesh.cpPort, mesh.adminToken, s.peerID, 5*time.Second)+ for _, a := range agents {+ waitForPeerOnRouter(t, mesh.cpPort, mesh.adminToken, a.peerID, 5*time.Second)}- // The greeter a caller of one language targets: the other language's,- // as the testnet probes do, or its own when it is the only one present.- peerServer := func(name string) *sdkExampleServer {- for _, s := range servers {- if s.name != name {- return s+ // The agent a caller of one language targets: the other language's, as+ // the testnet probes do, or its own when it is the only one present.+ peerAgent := func(name string) *sdkExampleAgent {+ for _, a := range agents {+ if a.name != name {+ return a}}- return servers[0]- }- servedBy := func(t *testing.T, out string, want *sdkExampleServer, serviceType string) {- t.Helper()- if got := expectLine(t, out, serviceType+"://"+want.service+" is served by "); got != want.peerID {- t.Fatalf("%s://%s is served by %s, want the %s serve example %s", serviceType, want.service, got, want.name, want.peerID)- }+ return agents[0]}for _, l := range launchers {l := l- target := peerServer(l.name)+ target := peerAgent(l.name)t.Run(l.name+"-calls", func(t *testing.T) {t.Parallel()stateDir := filepath.Join(t.TempDir(), "state")@@ -186,7 +162,8 @@ func TestNativeSDKExamples(t *testing.T) {withToken := []string{"SAM_CONTROL_PLANE_URL=" + mesh.baseURL, "SAM_STATE_DIR=" + stateDir, "SAM_BOOTSTRAP_TOKEN_PATH=" + tokenPath}withoutToken := withToken[:2]- // The first run spends the token: the sam-node's calc over MCP.+ // The first run spends the token: the sam-node's calc over MCP,+ // found by name.out := runExample(t, mesh, l, withToken, "mcp://calc", "add", `{"a": 1, "b": 2}`)caller := expectLine(t, out, "on the mesh as ")expectLine(t, out, "mcp://calc is served by "+mesh.samNode.peerID.String())@@ -194,18 +171,19 @@ func TestNativeSDKExamples(t *testing.T) {expectLine(t, out, "fake-result:add")// The state directory now holds the identity and credential; the- // token file is gone and not needed. The HTTP path: an in-process- // A2A handler on one side, a forward to the Ollama stand-in on the- // other. The provider sees the verified caller as X-Peer-Id, never- // the biscuit.+ // token file is gone and not needed. The agent, by peer ID: no+ // lookup, the path goes through the router. The agent sees the+ // verified caller, never the biscuit.if err := os.Remove(tokenPath); err != nil {t.Fatal(err)}- out = runExample(t, mesh, l, withoutToken, "a2a://"+target.service, "/card")+ out = runExample(t, mesh, l, withoutToken, target.peerID, "a2a://agent", "/card")if got := expectLine(t, out, "on the mesh as "); got != caller {t.Fatalf("second run joined as %s, want the identity of the first run %s", got, caller)}- servedBy(t, out, target, "a2a")+ if got := expectLine(t, out, "a2a://agent is served by "); got != target.peerID {+ t.Fatalf("a2a://agent is served by %s, want the %s agent example %s", got, target.name, target.peerID)+ }card := expectLine(t, out, "200 ")if !strings.Contains(card, `"path": "/card"`) && !strings.Contains(card, `"path":"/card"`) {t.Fatalf("a2a card %q does not echo the path", card)@@ -213,28 +191,22 @@ func TestNativeSDKExamples(t *testing.T) {if !strings.Contains(card, caller) {t.Fatalf("a2a card %q does not name the verified caller %s", card, caller)}- out = runExample(t, mesh, l, withoutToken, "inference://ollama", "/v1/models")- if got := expectLine(t, out, "inference://ollama is served by "); got != servers[0].peerID && (len(servers) < 2 || got != servers[1].peerID) {- t.Fatalf("inference://ollama is served by %s, which is none of the serve examples", got)- }- models := expectLine(t, out, "200 ")- if !strings.Contains(models, `"gemma3"`) || !strings.Contains(models, caller) {- t.Fatalf("models %q: want gemma3 owned by the caller %s", models, caller)- }// The state directory is the same layout in every implementation:// the other SDK's call example resumes this identity from it, and// so does a sam-node after `state import`. Each proves it by- // reaching a greeter as the same peer.+ // reaching the agent as the same peer.for _, other := range launchers {if other.name == l.name {continue}- out := runExample(t, mesh, other, withoutToken, "mcp://"+target.service, "greet", `{"name": "sam"}`)+ out := runExample(t, mesh, other, withoutToken, target.peerID, "a2a://agent", "/card")if got := expectLine(t, out, "on the mesh as "); got != caller {t.Fatalf("%s resumed %s's state directory as %s, want %s", other.name, l.name, got, caller)}- expectLine(t, out, "hello sam")+ if card := expectLine(t, out, "200 "); !strings.Contains(card, caller) {+ t.Fatalf("a2a card %q through %s does not name the verified caller %s", card, other.name, caller)+ }}importedNode := importStateIntoNode(t, mesh, stateDir)if importedNode.peerID.String() != caller {@@ -242,15 +214,9 @@ func TestNativeSDKExamples(t *testing.T) {}importedAPI := importedNode.waitForAPI(t)waitForPeerOnRouter(t, mesh.cpPort, mesh.adminToken, caller, 10*time.Second)- answer, err := callMCPAllowError(t, importedAPI, "imported-token", "call_remote_tool", map[string]any{- "peer_id": target.peerID, "tool_name": "mcp://" + target.service + "/greet", "arguments": map[string]any{"name": "node"},- })- if err != nil || !strings.Contains(answer, "hello node") {- t.Fatalf("sam-node running %s's identity could not call %s: %v\n%s", l.name, target.service, err, answer)- }- // The node's A2A egress path reaches the SDK's handler too, as the- // testnet's node probe expects.- status, body := egressGet(t, importedAPI, "imported-token", "/sam/"+target.peerID+"/a2a/"+target.service+"/card")+ // The node's A2A egress path reaches the agent by peer ID, as the+ // testnet's node probe does.+ status, body := egressGet(t, importedAPI, "imported-token", "/sam/"+target.peerID+"/a2a/agent/card")if status != 200 || !strings.Contains(body, `"caller"`) || !strings.Contains(body, caller) {t.Fatalf("a2a card through the node: %d %s", status, body)}@@ -283,10 +249,10 @@ func importStateIntoNode(t *testing.T, mesh *sdkMesh, stateDir string) *backgrou)}-// startExampleServer starts a configured serve example and waits for its-// "serving ... as <peer>" line. Safe to call from several goroutines at+// startExampleAgent starts a configured agent example and waits for its+// "accepting ... as <peer>" line. Safe to call from several goroutines at// once, so it reports failures instead of ending the test.-func startExampleServer(t *testing.T, name, service string, cmd *exec.Cmd) (*sdkExampleServer, error) {+func startExampleAgent(t *testing.T, name string, cmd *exec.Cmd) (*sdkExampleAgent, error) {stderr := &bytes.Buffer{}cmd.Stderr = stderrstdout, err := cmd.StdoutPipe()@@ -294,7 +260,7 @@ func startExampleServer(t *testing.T, name, service string, cmd *exec.Cmd) (*sdkreturn nil, err}if err := cmd.Start(); err != nil {- return nil, fmt.Errorf("failed to start %s serve example: %w", name, err)+ return nil, fmt.Errorf("failed to start %s agent example: %w", name, err)}t.Cleanup(func() {_ = cmd.Process.Signal(os.Interrupt)@@ -307,7 +273,7 @@ func startExampleServer(t *testing.T, name, service string, cmd *exec.Cmd) (*sdk<-done}if t.Failed() {- t.Logf("%s serve example stderr:\n%s", name, stderr.String())+ t.Logf("%s agent example stderr:\n%s", name, stderr.String())}})@@ -315,7 +281,7 @@ func startExampleServer(t *testing.T, name, service string, cmd *exec.Cmd) (*sdkgo func() {scanner := bufio.NewScanner(stdout)for scanner.Scan() {- if m := servingLine.FindStringSubmatch(scanner.Text()); m != nil {+ if m := acceptingLine.FindStringSubmatch(scanner.Text()); m != nil {lines <- scanner.Text()return}@@ -325,17 +291,15 @@ func startExampleServer(t *testing.T, name, service string, cmd *exec.Cmd) (*sdkselect {case line, ok := <-lines:if !ok {- return nil, fmt.Errorf("%s serve example exited before serving\nstderr:\n%s", name, stderr.String())+ return nil, fmt.Errorf("%s agent example exited before accepting\nstderr:\n%s", name, stderr.String())}- m := servingLine.FindStringSubmatch(line)- for _, want := range []string{"mcp://" + service, "a2a://" + service, "inference://ollama"} {- if !strings.Contains(m[1], want) {- return nil, fmt.Errorf("%s serve example serves %q, want %s among them", name, m[1], want)- }+ m := acceptingLine.FindStringSubmatch(line)+ if m[1] != "a2a://agent" {+ return nil, fmt.Errorf("%s agent example accepts %q, want a2a://agent", name, m[1])}- return &sdkExampleServer{name: name, service: service, peerID: m[2]}, nil+ return &sdkExampleAgent{name: name, peerID: m[2]}, nilcase <-time.After(30 * time.Second):- return nil, fmt.Errorf("%s serve example did not report serving within 30s\nstderr:\n%s", name, stderr.String())+ return nil, fmt.Errorf("%s agent example did not report accepting within 30s\nstderr:\n%s", name, stderr.String())}}diff --git a/tests/integration/sdk_mesh_test.go b/tests/integration/sdk_mesh_test.goindex fec4eb0a..534f17d5 100644--- a/tests/integration/sdk_mesh_test.go+++ b/tests/integration/sdk_mesh_test.go@@ -260,13 +260,13 @@ var sdkMemberLaunchers = []sdkRunner{// credential gets no answer. Then each SDK member discovers the sam-node's// service in the DHT, lists and calls its tools over /sam/mcp/1.0.0 through// the router, reads the node's own catalog, and is refused a service the-// node does not have. Then each SDK member publishes an MCP service and an-// inference service of its own: the sam-node discovers and calls both-// (call_remote_tool, and the egress proxy for /sam/<peer>/inference/...),-// the other SDK member does the same over the mesh, and a Go peer holding a-// role the policy grants nothing is refused at the AuthResponse. Any SDK-// whose toolchain is missing is skipped, and the matrix shrinks to the-// members present.+// node does not have. Then each SDK member accepts A2A requests for its+// agent: the sam-node reaches it by peer ID through its egress proxy+// (/sam/<peer>/a2a/agent/...), the other SDK member does the same over the+// mesh, the agent is in no discovery table, the member speaks no+// /sam/mcp/1.0.0, and a Go peer holding a role the policy grants nothing is+// refused with 403. Any SDK whose toolchain is missing is skipped, and the+// matrix shrinks to the members present.func TestNativeSDKsMesh(t *testing.T) {mesh := startSDKMesh(t)root, baseURL, adminToken, cpPort := mesh.root, mesh.baseURL, mesh.adminToken, mesh.cpPort@@ -384,97 +384,74 @@ func TestNativeSDKsMesh(t *testing.T) {})}- // Every SDK member becomes a provider: an MCP service with an echo tool- // and an inference service, both served in the runner's process. The- // policy rules it evaluates are the ones the control plane renders.+ // Every SDK member is an agent: it accepts A2A requests for a2a://agent,+ // answered in the runner's process, reachable by peer ID through the+ // router. It publishes nothing; the policy rules it evaluates are the+ // ones the control plane renders.for _, m := range members {- m.serve(t, "mcp", "echo-"+m.name)- m.serve(t, "inference", "llm-"+m.name)+ m.accept(t, "agent")}guest := newGuestGoPeer(t, ctx, cpPriv, routerAddr)for _, m := range members {m := m- t.Run(m.name+"-serves", func(t *testing.T) {- mcpService := "mcp://echo-" + m.name- inferenceService := "inference://llm-" + m.name+ t.Run(m.name+"-accepts", func(t *testing.T) {sdkPeer, _ := peer.Decode(m.report.PeerID)- // sam-node -> SDK tool, through the router, as an agent behind the- // node would with call_remote_tool.- answer, err := callMCPAllowError(t, nodeAPI, "node-token", "call_remote_tool", map[string]any{- "peer_id": m.report.PeerID,- "tool_name": mcpService + "/echo",- "arguments": map[string]any{"text": "from-node"},- })- if err != nil || !strings.Contains(answer, m.name+":from-node") {- t.Fatalf("sam-node calling echo on %s: answer %q, err %v", m.name, answer, err)- }-- // sam-node -> SDK inference, through the egress proxy: the node- // verifies the member's credential, then the member authorizes the- // node's and answers with who called.- status, body := egressGet(t, nodeAPI, "node-token", "/sam/"+m.report.PeerID+"/inference/llm-"+m.name+"/v1/models")+ // sam-node -> SDK agent, through the egress proxy: the node+ // verifies the member's credential, then the member authorizes+ // the node's and answers with who called.+ status, body := egressGet(t, nodeAPI, "node-token", "/sam/"+m.report.PeerID+"/a2a/agent/card")if status != 200 {- t.Fatalf("sam-node egress to %s inference: status %d, body %s", m.name, status, body)+ t.Fatalf("sam-node egress to %s agent: status %d, body %s", m.name, status, body)}var seen struct {SDK string `json:"sdk"`Peer string `json:"peer"`Path string `json:"path"`}- if json.Unmarshal([]byte(body), &seen) != nil || seen.SDK != m.name || seen.Peer != samNode.peerID.String() || seen.Path != "/v1/models" {- t.Fatalf("sam-node egress to %s inference answered %s", m.name, body)+ if json.Unmarshal([]byte(body), &seen) != nil || seen.SDK != m.name || seen.Peer != samNode.peerID.String() || seen.Path != "/card" {+ t.Fatalf("sam-node egress to %s agent answered %s", m.name, body)+ }++ // The agent is not in the discovery table: nothing was announced.+ if providers := m.discoverOnce(t, "a2a", "agent"); len(providers) != 0 {+ t.Fatalf("%s discovered %+v for a2a://agent, want nothing: an agent is not published", m.name, providers)}- // SDK -> SDK: the other member finds the service in the DHT and- // calls both the tool and the inference endpoint through the router.+ // SDK -> SDK: the other member reaches the agent by peer ID+ // through the router, with no lookup.for _, other := range members {if other == m {continue}- other.discoverUntil(t, "mcp", "echo-"+m.name, m.report.PeerID, 20*time.Second)- if tools := other.tools(t, m.report.RelayAddresses[0], mcpService); !contains(tools, "echo") {- t.Fatalf("%s listed %v on %s of %s, want echo", other.name, tools, mcpService, m.name)- }- if res := other.call(t, m.report.RelayAddresses[0], mcpService, "echo", map[string]any{"text": "from-" + other.name}); res.IsError || !contains(res.Text, m.name+":from-"+other.name) {- t.Fatalf("%s calling echo on %s: %+v", other.name, m.name, res)- }- res := other.http(t, m.report.RelayAddresses[0], inferenceService, "/v1/models")+ res := other.http(t, m.report.PeerID, "a2a://agent", "/card")if res.Status != 200 || !strings.Contains(res.Body, other.report.PeerID) {- t.Fatalf("%s calling %s on %s: %+v", other.name, inferenceService, m.name, res)- }- // The member's catalog lists what it publishes.- if r := other.call(t, m.report.RelayAddresses[0], "", "list_local_services", nil); r.IsError || !strings.Contains(strings.Join(r.Text, "\n"), "echo-"+m.name) {- t.Fatalf("%s reading %s's catalog: %+v", other.name, m.name, r)- }- // A service the member does not publish, but the policy grants:- // authorized, then the stream is closed, as sam-node does.- if r := other.callRaw(t, m.report.RelayAddresses[0], "mcp://not-served", "echo", nil); r.OK {- t.Fatalf("%s called a service %s does not serve: %+v", other.name, m.name, r)+ t.Fatalf("%s calling a2a://agent on %s: %+v", other.name, m.name, res)}- if r := other.http(t, m.report.RelayAddresses[0], "inference://not-served", "/"); r.Status != 404 {- t.Fatalf("%s calling an inference service %s does not serve: %+v", other.name, m.name, r)+ // Another agent name the policy grants: authorized, then 404.+ if r := other.http(t, m.report.PeerID, "a2a://other", "/card"); r.Status != 404 {+ t.Fatalf("%s calling an agent name %s does not answer: %+v", other.name, m.name, r)}}+ // An SDK member serves no MCP: the stream is refused at the+ // protocol negotiation, before any frame is read.+ if err := tryMCPStream(ctx, guest, sdkPeer, multiaddr.StringCast(m.report.RelayAddresses[0])); err == nil {+ t.Fatalf("%s accepted a /sam/mcp/1.0.0 stream; an SDK member serves no MCP", m.name)+ }+// A peer the control plane vouches for, but whose role the policy- // grants nothing, is refused at the AuthResponse with a reason, and- // with 403 on the HTTP path.+ // grants nothing, is refused with 403 on the HTTP path.dialCtx, cancel := context.WithTimeout(ctx, 10*time.Second)defer cancel()if err := guest.Connect(dialCtx, peer.AddrInfo{ID: sdkPeer, Addrs: []multiaddr.Multiaddr{multiaddr.StringCast(m.report.RelayAddresses[0])}}); err != nil {t.Fatalf("guest peer could not reach %s: %v", m.name, err)}- guestBiscuit := guestHostBiscuit(t, cpPriv, guest.ID())- resp := mcpHandshake(t, ctx, guest, sdkPeer, guestBiscuit, mcpService)- if resp.Success || !strings.Contains(resp.Error, "not authorized") {- t.Fatalf("%s answered a guest's request for %s with %+v, want a refusal", m.name, mcpService, resp)- }- if status, _ := libp2pHTTPGet(t, ctx, guest, sdkPeer, guestBiscuit, "/inference/llm-"+m.name+"/v1/models"); status != 403 {+ if status, _ := libp2pHTTPGet(t, ctx, guest, sdkPeer, guestHostBiscuit(t, cpPriv, guest.ID()), "/a2a/agent/card"); status != 403 {t.Fatalf("%s answered a guest's HTTP request with %d, want 403", m.name, status)}- // The same peer with a node-role token is served: the refusal was the policy, not the peer.- if status, body := libp2pHTTPGet(t, ctx, guest, sdkPeer, goHostBiscuit(t, cpPriv, guest.ID()), "/inference/llm-"+m.name+"/v1/models"); status != 200 || !strings.Contains(body, guest.ID().String()) {+ // The same peer with a node-role token is answered: the refusal was the policy, not the peer.+ if status, body := libp2pHTTPGet(t, ctx, guest, sdkPeer, goHostBiscuit(t, cpPriv, guest.ID()), "/a2a/agent/card"); status != 200 || !strings.Contains(body, guest.ID().String()) {t.Fatalf("%s answered a node-role HTTP request with %d %s", m.name, status, body)}})@@ -811,6 +788,23 @@ func (m *sdkMember) discoverUntil(t *testing.T, serviceType, name, wantPeer stri}}+// discoverOnce is one DHT lookup, whatever it returns.+func (m *sdkMember) discoverOnce(t *testing.T, serviceType, name string) []sdkProvider {+ t.Helper()+ var res struct {+ OK bool `json:"ok"`+ Error string `json:"error"`+ Providers []sdkProvider `json:"providers"`+ }+ if line := m.send(t, map[string]string{"cmd": "discover", "type": serviceType, "name": name}); json.Unmarshal(line, &res) != nil {+ t.Fatalf("%s member: discover answered %q", m.name, line)+ }+ if !res.OK {+ t.Fatalf("%s member: discover failed: %s", m.name, res.Error)+ }+ return res.Providers+}+func (m *sdkMember) tools(t *testing.T, addr, service string) []string {t.Helper()var res struct {@@ -861,22 +855,23 @@ func (m *sdkMember) call(t *testing.T, addr, service, tool string, args map[strireturn res}-// serve asks the member to publish a service served in its own process.-func (m *sdkMember) serve(t *testing.T, serviceType, name string) {+// accept asks the member to accept A2A requests for its agent, answered in+// its own process.+func (m *sdkMember) accept(t *testing.T, name string) {t.Helper()var res struct {- OK bool `json:"ok"`- Error string `json:"error"`- Services []string `json:"services"`+ OK bool `json:"ok"`+ Error string `json:"error"`+ Service string `json:"service"`}- if line := m.send(t, map[string]string{"cmd": "serve", "type": serviceType, "name": name}); json.Unmarshal(line, &res) != nil {- t.Fatalf("%s member: serve answered %q", m.name, line)+ if line := m.send(t, map[string]string{"cmd": "accept", "name": name}); json.Unmarshal(line, &res) != nil {+ t.Fatalf("%s member: accept answered %q", m.name, line)}if !res.OK {- t.Fatalf("%s member could not serve %s://%s: %s", m.name, serviceType, name, res.Error)+ t.Fatalf("%s member could not accept a2a://%s: %s", m.name, name, res.Error)}- if !contains(res.Services, serviceType+"://"+name) {- t.Fatalf("%s member serves %v after publishing %s://%s", m.name, res.Services, serviceType, name)+ if res.Service != "a2a://"+name {+ t.Fatalf("%s member accepts %q after asking for a2a://%s", m.name, res.Service, name)}}@@ -1007,31 +1002,20 @@ func newGuestGoPeer(t *testing.T, ctx context.Context, cpPriv ed25519.PrivateKeyreturn newAdmittedGoPeer(t, ctx, cpPriv, routerAddr)}-// mcpHandshake opens /sam/mcp/1.0.0 to target for targetService and returns-// the provider's answer, as sam-node's ConnectMCPSession reads it.-func mcpHandshake(t *testing.T, ctx context.Context, h host.Host, target peer.ID, biscuit []byte, targetService string) *api.AuthResponse {- t.Helper()- streamCtx, cancel := context.WithTimeout(network.WithAllowLimitedConn(ctx, "mcp"), 10*time.Second)+// tryMCPStream opens /sam/mcp/1.0.0 to target through addr and reports+// whether the peer speaks it at all.+func tryMCPStream(ctx context.Context, h host.Host, target peer.ID, addr multiaddr.Multiaddr) error {+ ctx, cancel := context.WithTimeout(network.WithAllowLimitedConn(ctx, "mcp"), 10*time.Second)defer cancel()- s, err := h.NewStream(streamCtx, target, api.MCPProtocolID)- if err != nil {- t.Fatalf("open mcp stream to %s: %v", target, err)- }- defer func() { _ = s.Close() }()- _ = s.SetDeadline(time.Now().Add(10 * time.Second))- frame, _ := proto.Marshal(&api.AuthFrame{Biscuit: biscuit, TargetService: targetService})- if err := msgio.NewVarintWriter(s).WriteMsg(frame); err != nil {- t.Fatalf("write mcp auth frame to %s: %v", target, err)+ if err := h.Connect(ctx, peer.AddrInfo{ID: target, Addrs: []multiaddr.Multiaddr{addr}}); err != nil {+ return err}- msg, err := msgio.NewVarintReaderSize(s, 64*1024).ReadMsg()+ s, err := h.NewStream(ctx, target, api.MCPProtocolID)if err != nil {- t.Fatalf("read mcp auth response from %s: %v", target, err)- }- var resp api.AuthResponse- if err := proto.Unmarshal(msg, &resp); err != nil {- t.Fatalf("mcp auth response from %s: %v", target, err)+ return err}- return &resp+ _ = s.Close()+ return nil}// libp2pHTTPGet is one GET over /libp2p-http with the biscuit in