Skip to content

Agent Mesh

chore: Rename tools to servers in tests and github actions

Antonio Ojeae5e0f9ad8bb1
diff --git a/.github/k8s/sam-hub-template.yaml b/.github/k8s/sam-hub-template.yaml
index e107c723..744b805a 100644
--- a/.github/k8s/sam-hub-template.yaml
+++ b/.github/k8s/sam-hub-template.yaml
@@ -116,7 +116,7 @@ data:
roles:
sam-canary:
mcp:
- allowed_tools:
+ allowed_servers:
- "/sam/mcp/1.0.0"
- "/sam/catalog"
diff --git a/.github/workflows/kind-mesh-e2e.yml b/.github/workflows/kind-mesh-e2e.yml
index 0e787c65..80135398 100644
--- a/.github/workflows/kind-mesh-e2e.yml
+++ b/.github/workflows/kind-mesh-e2e.yml
@@ -83,8 +83,8 @@ jobs:
echo "== discover services / find calculator (poll) =="
peer=""
for _ in $(seq 1 30); do
- tools=$(mcp -tool find_remote_tools -args '{}' || true)
- peer=$(printf '%s' "$tools" | jq -r '.[]? | select(.tool_name=="calculator.add") | .peer_id' 2>/dev/null | head -n1)
+ tools=$(mcp -tool find_remote_servers -args '{}' || true)
+ peer=$(printf '%s' "$tools" | jq -r '.[]? | select(.server_name=="calculator.add") | .peer_id' 2>/dev/null | head -n1)
[ -n "$peer" ] && break
sleep 1
done
@@ -92,8 +92,8 @@ jobs:
echo "calculator host: $peer"
echo "== call calculator.add(2,3) =="
- result=$(mcp -tool call_remote_tool \
- -args "{\"peer_id\":\"$peer\",\"tool_name\":\"calculator.add\",\"arguments\":{\"a\":2,\"b\":3}}")
+ result=$(mcp -tool call_remote_server \
+ -args "{\"peer_id\":\"$peer\",\"server_name\":\"calculator.add\",\"arguments\":{\"a\":2,\"b\":3}}")
echo "result: $result"
printf '%s' "$result" | grep -q 5 || { echo "calculator.add did not return 5"; exit 1; }
echo "OK: calculator.add(2,3) == 5"
diff --git a/cmd/sam-node/mcp_handlers.go b/cmd/sam-node/mcp_handlers.go
index 5abb4e40..a9704fdc 100644
--- a/cmd/sam-node/mcp_handlers.go
+++ b/cmd/sam-node/mcp_handlers.go
@@ -190,23 +190,23 @@ func (n *SamNode) handleGetMeshInfo(ctx context.Context, req *mcp.CallToolReques
// CallRemoteServerParams defines the parameters for the call_remote_server tool.
//
-// Arguments is a JSON object whose shape matches the target tool's
+// Arguments is a JSON object whose shape matches the target server's
// input_schema (use describe_remote_server to fetch it). Earlier revisions
// took a stringified JSON blob here; that footgun is gone.
type CallRemoteServerParams struct {
PeerID string `json:"peer_id" jsonschema:"The Peer ID of the target agent"`
- ToolName string `json:"tool_name" jsonschema:"The name of the tool to call"`
- Arguments map[string]any `json:"arguments,omitempty" jsonschema:"Tool arguments as a JSON object whose keys match the target tool's input_schema. Call describe_remote_server first to learn the schema."`
+ ServerName string `json:"server_name" jsonschema:"The name of the server to call"`
+ Arguments map[string]any `json:"arguments,omitempty" jsonschema:"Server arguments as a JSON object whose keys match the target server's input_schema. Call describe_remote_server first to learn the schema."`
}
// handleCallRemoteServer implements the call_remote_server tool.
func (n *SamNode) handleCallRemoteServer(ctx context.Context, req *mcp.CallToolRequest, params CallRemoteServerParams) (*mcp.CallToolResult, any, error) {
- logger.Infof("[MCP] call_remote_server called for peer %s, tool %s", params.PeerID, params.ToolName)
+ logger.Infof("[MCP] call_remote_server called for peer %s, tool %s", params.PeerID, params.ServerName)
targetPeer, err := peer.Decode(params.PeerID)
if err != nil {
return nil, nil, err
}
- res, err := n.CallMCPTool(ctx, targetPeer, params.ToolName, params.Arguments)
+ res, err := n.CallMCPTool(ctx, targetPeer, params.ServerName, params.Arguments)
if err != nil {
return nil, nil, err
}
@@ -249,7 +249,7 @@ type FindRemoteServersParams struct {
// remoteServerRow is one entry in the find_remote_servers response.
type remoteServerRow struct {
PeerID string `json:"peer_id"`
- ToolName string `json:"tool_name"`
+ ServerName string `json:"server_name"`
Description string `json:"description"`
}
@@ -406,7 +406,7 @@ func appendFilteredRows(rows []remoteServerRow, peerID string, tools []*mcp.Tool
}
rows = append(rows, remoteServerRow{
PeerID: peerID,
- ToolName: tool.Name,
+ ServerName: tool.Name,
Description: tool.Description,
})
}
@@ -462,7 +462,7 @@ func (n *SamNode) fanOutFetch(ctx context.Context, peers []peer.ID, serviceName
// them verbatim without imposing a typed-schema constraint.
type remoteToolDescription struct {
PeerID string `json:"peer_id,omitempty"`
- ToolName string `json:"tool_name"`
+ ServerName string `json:"server_name"`
Description string `json:"description"`
InputSchema any `json:"input_schema,omitempty"`
OutputSchema any `json:"output_schema,omitempty"`
@@ -471,8 +471,8 @@ type remoteToolDescription struct {
// DescribeRemoteToolParams defines parameters for the describe_remote_server
// sidecar tool.
type DescribeRemoteToolParams struct {
- PeerID string `json:"peer_id" jsonschema:"Peer ID of the node hosting the tool. Required."`
- ToolName string `json:"tool_name" jsonschema:"Namespaced tool name as returned by find_remote_servers (e.g. 'code-reviewer.review_pr'). Required."`
+ PeerID string `json:"peer_id" jsonschema:"Peer ID of the node hosting the server. Required."`
+ ServerName string `json:"server_name" jsonschema:"Namespaced server name as returned by find_remote_servers (e.g. 'code-reviewer.review_pr'). Required."`
}
// handleDescribeRemoteServer implements the describe_remote_server client-facing tool.
@@ -480,8 +480,8 @@ func (n *SamNode) handleDescribeRemoteServer(ctx context.Context, req *mcp.CallT
if params.PeerID == "" {
return nil, nil, fmt.Errorf("peer_id is required")
}
- if params.ToolName == "" {
- return nil, nil, fmt.Errorf("tool_name is required")
+ if params.ServerName == "" {
+ return nil, nil, fmt.Errorf("server_name is required")
}
pid, err := peer.Decode(params.PeerID)
@@ -489,12 +489,12 @@ func (n *SamNode) handleDescribeRemoteServer(ctx context.Context, req *mcp.CallT
return nil, nil, fmt.Errorf("invalid peer_id: %w", err)
}
- parts := strings.SplitN(params.ToolName, ".", 2)
+ parts := strings.SplitN(params.ServerName, ".", 2)
if len(parts) != 2 {
- return nil, nil, fmt.Errorf("invalid tool_name format, expected 'service.tool'")
+ return nil, nil, fmt.Errorf("invalid server_name format, expected 'service.tool'")
}
serviceName := parts[0]
- actualToolName := parts[1]
+ actualServerName := parts[1]
biscuitBytes, err := n.Store.LoadIdentity()
if err != nil {
@@ -541,10 +541,10 @@ func (n *SamNode) handleDescribeRemoteServer(ctx context.Context, req *mcp.CallT
}
for _, t := range listRes.Tools {
- if t.Name == actualToolName {
+ if t.Name == actualServerName {
payload := remoteToolDescription{
PeerID: pid.String(),
- ToolName: params.ToolName,
+ ServerName: params.ServerName,
Description: t.Description,
InputSchema: t.InputSchema,
OutputSchema: t.OutputSchema,
diff --git a/cmd/sam-node/mcp_handlers_additional_test.go b/cmd/sam-node/mcp_handlers_additional_test.go
new file mode 100644
index 00000000..278ef986
--- /dev/null
+++ b/cmd/sam-node/mcp_handlers_additional_test.go
@@ -0,0 +1,156 @@
+package main
+
+import (
+ "context"
+ "encoding/json"
+ "testing"
+
+ "github.com/google/sam/api"
+ "github.com/modelcontextprotocol/go-sdk/mcp"
+)
+
+func TestHandleSendMessage(t *testing.T) {
+ ctx := context.Background()
+ node, cleanup := startBareNode(t, ctx)
+ defer cleanup()
+
+ res, _, err := node.handleSendMessage(context.Background(), &mcp.CallToolRequest{}, SendMessageParams{
+ PeerID: "123",
+ Message: "Hello",
+ })
+ if err != nil {
+ t.Fatalf("handleSendMessage failed: %v", err)
+ }
+ if len(res.Content) == 0 {
+ t.Fatalf("expected content")
+ }
+ text := res.Content[0].(*mcp.TextContent).Text
+ if text != "Simulated sending message to 123: Hello" {
+ t.Errorf("unexpected response: %q", text)
+ }
+}
+
+func TestHandleDiscoverRemoteServices(t *testing.T) {
+ ctx := context.Background()
+ node, cleanup := startBareNode(t, ctx)
+ defer cleanup()
+
+ res, _, err := node.handleDiscoverRemoteServices(context.Background(), &mcp.CallToolRequest{}, DiscoverRemoteServicesParams{
+ Type: "mcp",
+ Name: "test-service",
+ })
+ if err != nil {
+ t.Fatalf("handleDiscoverRemoteServices failed: %v", err)
+ }
+
+ var providers []*api.DiscoveredProvider
+ text := res.Content[0].(*mcp.TextContent).Text
+ if err := json.Unmarshal([]byte(text), &providers); err != nil {
+ t.Fatalf("failed to unmarshal providers: %v", err)
+ }
+ if len(providers) != 0 {
+ t.Errorf("expected 0 providers, got %d", len(providers))
+ }
+
+ // Test invalid type
+ _, _, err = node.handleDiscoverRemoteServices(context.Background(), &mcp.CallToolRequest{}, DiscoverRemoteServicesParams{
+ Type: "invalid",
+ })
+ if err == nil {
+ t.Errorf("expected error for invalid service type")
+ }
+}
+
+func TestHandleMeshPubsub(t *testing.T) {
+ ctx := context.Background()
+ node, cleanup := startBareNode(t, ctx)
+ defer cleanup()
+
+ // Subscribe
+ res, _, err := node.handleSubscribeTopic(context.Background(), &mcp.CallToolRequest{}, SubscribeTopicParams{
+ Topic: "test-topic",
+ })
+ if err != nil {
+ t.Fatalf("handleSubscribeTopic failed: %v", err)
+ }
+ if res.Content[0].(*mcp.TextContent).Text != "Subscribed" {
+ t.Errorf("expected Subscribed")
+ }
+
+ // Publish
+ res, _, err = node.handleMeshPubsubBroadcast(context.Background(), &mcp.CallToolRequest{}, MeshPubsubBroadcastParams{
+ Topic: "test-topic",
+ Payload: "test-message",
+ })
+ if err != nil {
+ t.Fatalf("handleMeshPubsubBroadcast failed: %v", err)
+ }
+
+ // Poll
+ res, _, err = node.handlePollMessages(context.Background(), &mcp.CallToolRequest{}, PollMessagesParams{
+ Topic: "test-topic",
+ })
+ if err != nil {
+ t.Fatalf("handlePollMessages failed: %v", err)
+ }
+ if len(res.Content) == 0 {
+ t.Fatalf("expected content in poll messages")
+ }
+}
+
+func TestHandleGetMeshInfo(t *testing.T) {
+ ctx := context.Background()
+ node, cleanup := startBareNode(t, ctx)
+ defer cleanup()
+
+ res, _, err := node.handleGetMeshInfo(context.Background(), &mcp.CallToolRequest{}, GetMeshInfoParams{})
+ if err != nil {
+ t.Fatalf("handleGetMeshInfo failed: %v", err)
+ }
+
+ text := res.Content[0].(*mcp.TextContent).Text
+ var info map[string]any
+ if err := json.Unmarshal([]byte(text), &info); err != nil {
+ t.Fatalf("failed to parse mesh info: %v", err)
+ }
+
+ if _, ok := info["connected_peers"]; !ok {
+ t.Errorf("missing connected_peers in mesh info")
+ }
+ if _, ok := info["dht_size"]; !ok {
+ t.Errorf("missing dht_size in mesh info")
+ }
+}
+
+func TestHandleConnectPeer(t *testing.T) {
+ ctx := context.Background()
+ node, cleanup := startBareNode(t, ctx)
+ defer cleanup()
+
+ nodeB, cleanupB := startBareNode(t, ctx)
+ defer cleanupB()
+
+ res, _, err := node.handleConnectPeer(context.Background(), &mcp.CallToolRequest{}, ConnectPeerParams{
+ PeerAddr: nodeB.Host.Addrs()[0].String() + "/p2p/" + nodeB.Host.ID().String(),
+ })
+ if err != nil {
+ t.Fatalf("handleConnectPeer failed: %v", err)
+ }
+ if res.Content[0].(*mcp.TextContent).Text != "Connected" {
+ t.Errorf("expected Connected")
+ }
+}
+
+func TestHandleCallRemoteServer(t *testing.T) {
+ ctx := context.Background()
+ node, cleanup := startBareNode(t, ctx)
+ defer cleanup()
+
+ _, _, err := node.handleCallRemoteServer(context.Background(), &mcp.CallToolRequest{}, CallRemoteServerParams{
+ PeerID: "invalid_peer_id",
+ ServerName: "test",
+ })
+ if err == nil {
+ t.Errorf("expected error for invalid peer id")
+ }
+}
diff --git a/cmd/sam-node/mcp_handlers_test.go b/cmd/sam-node/mcp_handlers_test.go
index 45d5dd53..653fb385 100644
--- a/cmd/sam-node/mcp_handlers_test.go
+++ b/cmd/sam-node/mcp_handlers_test.go
@@ -167,8 +167,8 @@ func TestHandleFindRemoteTools_SinglePeer(t *testing.T) {
if row.PeerID != nodeB.Host.ID().String() {
t.Errorf("row has peer_id %q, want %q", row.PeerID, nodeB.Host.ID().String())
}
- if _, ok := wantNames[row.ToolName]; ok {
- wantNames[row.ToolName] = true
+ if _, ok := wantNames[row.ServerName]; ok {
+ wantNames[row.ServerName] = true
}
}
for name, found := range wantNames {
@@ -307,7 +307,7 @@ func TestHandleFindRemoteTools_MeshWideViaHandler(t *testing.T) {
found := false
for _, r := range rows {
- if r.ToolName == "code-reviewer.review_pr" && r.PeerID == nodeB.Host.ID().String() {
+ if r.ServerName == "code-reviewer.review_pr" && r.PeerID == nodeB.Host.ID().String() {
found = true
}
}
@@ -329,7 +329,7 @@ func TestAppendFilteredRows_ServiceNameFilter(t *testing.T) {
t.Errorf("service filter: got %d rows, want 2; rows=%+v", len(rows), rows)
}
for _, r := range rows {
- if !strings.HasPrefix(r.ToolName, "code-reviewer.") {
+ if !strings.HasPrefix(r.ServerName, "code-reviewer.") {
t.Errorf("row %+v doesn't match service prefix", r)
}
}
@@ -347,8 +347,8 @@ func TestAppendFilteredRows_AggregatedOnly(t *testing.T) {
if len(rows) != 1 {
t.Errorf("aggregated-only filter: got %d rows, want 1; rows=%+v", len(rows), rows)
}
- if rows[0].ToolName != "code-reviewer.review_pr" {
- t.Errorf("unexpected name %q", rows[0].ToolName)
+ if rows[0].ServerName != "code-reviewer.review_pr" {
+ t.Errorf("unexpected name %q", rows[0].ServerName)
}
}
@@ -360,7 +360,7 @@ func TestAppendFilteredRows_PartialPrefixMatch(t *testing.T) {
{Name: "code.something"},
}
rows := appendFilteredRows(nil, "peerB", tools, "code")
- if len(rows) != 1 || rows[0].ToolName != "code.something" {
+ if len(rows) != 1 || rows[0].ServerName != "code.something" {
t.Errorf("expected exactly one row 'code.something'; got %+v", rows)
}
}
@@ -419,7 +419,7 @@ func TestHandleFindRemoteTools_PartialFailure(t *testing.T) {
gotSummarizer := false
for _, r := range rows {
- if r.ToolName == "summarizer.summarize" {
+ if r.ServerName == "summarizer.summarize" {
gotSummarizer = true
}
}
@@ -473,14 +473,14 @@ func TestHandleDescribeRemoteTool_EmptyPeerID(t *testing.T) {
defer cleanup()
_, _, err := node.handleDescribeRemoteServer(ctx, &mcp.CallToolRequest{}, DescribeRemoteToolParams{
- ToolName: "code-reviewer.review_pr",
+ ServerName: "code-reviewer.review_pr",
})
if err == nil {
t.Fatal("expected error for empty peer_id")
}
}
-func TestHandleDescribeRemoteTool_EmptyToolName(t *testing.T) {
+func TestHandleDescribeRemoteTool_EmptyServerName(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
@@ -491,7 +491,7 @@ func TestHandleDescribeRemoteTool_EmptyToolName(t *testing.T) {
PeerID: "12D3KooWFakePeerID",
})
if err == nil {
- t.Fatal("expected error for empty tool_name")
+ t.Fatal("expected error for empty server_name")
}
}
@@ -504,10 +504,10 @@ func TestHandleDescribeRemoteTool_NonNamespacedRejected(t *testing.T) {
_, _, err := node.handleDescribeRemoteServer(ctx, &mcp.CallToolRequest{}, DescribeRemoteToolParams{
PeerID: node.Host.ID().String(),
- ToolName: "send_message", // no dot
+ ServerName: "send_message", // no dot
})
if err == nil {
- t.Fatal("expected error for tool_name without '.'")
+ t.Fatal("expected error for server_name without '.'")
}
if !strings.Contains(err.Error(), "service.tool") {
t.Errorf("error %q does not explain the namespacing requirement", err.Error())
@@ -523,7 +523,7 @@ func TestHandleDescribeRemoteTool_SelfPeerRejected(t *testing.T) {
_, _, err := node.handleDescribeRemoteServer(ctx, &mcp.CallToolRequest{}, DescribeRemoteToolParams{
PeerID: node.Host.ID().String(),
- ToolName: "code-reviewer.review_pr",
+ ServerName: "code-reviewer.review_pr",
})
if err == nil {
t.Fatal("expected error when peer_id equals self peer ID")
@@ -539,7 +539,7 @@ func TestHandleDescribeRemoteTool_InvalidPeerID(t *testing.T) {
_, _, err := node.handleDescribeRemoteServer(ctx, &mcp.CallToolRequest{}, DescribeRemoteToolParams{
PeerID: "not-a-valid-peer-id",
- ToolName: "code-reviewer.review_pr",
+ ServerName: "code-reviewer.review_pr",
})
if err == nil {
t.Fatal("expected error for malformed peer_id")
@@ -603,7 +603,7 @@ func TestHandleDescribeRemoteTool_RoundTrip(t *testing.T) {
res, _, err := nodeA.handleDescribeRemoteServer(ctx, &mcp.CallToolRequest{}, DescribeRemoteToolParams{
PeerID: nodeB.Host.ID().String(),
- ToolName: "code-reviewer.review_pr",
+ ServerName: "code-reviewer.review_pr",
})
if err != nil {
t.Fatalf("handleDescribeRemoteServer: %v", err)
@@ -620,8 +620,8 @@ func TestHandleDescribeRemoteTool_RoundTrip(t *testing.T) {
if desc.PeerID != nodeB.Host.ID().String() {
t.Errorf("PeerID = %q, want %q", desc.PeerID, nodeB.Host.ID().String())
}
- if desc.ToolName != "code-reviewer.review_pr" {
- t.Errorf("ToolName = %q, want %q", desc.ToolName, "code-reviewer.review_pr")
+ if desc.ServerName != "code-reviewer.review_pr" {
+ t.Errorf("ServerName = %q, want %q", desc.ServerName, "code-reviewer.review_pr")
}
if desc.Description != "Run a code review" {
t.Errorf("Description = %q, want %q", desc.Description, "Run a code review")
@@ -681,7 +681,7 @@ func TestHandleDescribeRemoteTool_RoundTrip_UnknownTool(t *testing.T) {
_, _, err = nodeA.handleDescribeRemoteServer(ctx, &mcp.CallToolRequest{}, DescribeRemoteToolParams{
PeerID: nodeB.Host.ID().String(),
- ToolName: "code-reviewer.does-not-exist",
+ ServerName: "code-reviewer.does-not-exist",
})
if err == nil {
t.Fatal("expected error from peer when tool is not registered")
diff --git a/tests/e2e/find_remote_tools.bats b/tests/e2e/find_remote_servers.bats
similarity index 84%
rename from tests/e2e/find_remote_tools.bats
rename to tests/e2e/find_remote_servers.bats
index 01387d51..ac6bdb50 100644
--- a/tests/e2e/find_remote_tools.bats
+++ b/tests/e2e/find_remote_servers.bats
@@ -32,7 +32,7 @@ teardown() {
mesh_cleanup_env
}
-@test "find_remote_tools surfaces aggregated tools from a remote peer" {
+@test "find_remote_servers surfaces aggregated tools from a remote peer" {
run mesh_start_mock_oidc
[[ "$status" -eq 0 ]]
@@ -64,13 +64,13 @@ teardown() {
[[ "$status" -eq 0 ]]
mesh_wait_for_peer_connection 1 "${node2_peer_id}" 20
- echo "[$(date +%T)] Calling find_remote_tools from Node 1, targeting Node 2"
+ echo "[$(date +%T)] Calling find_remote_servers from Node 1, targeting Node 2"
run docker run --rm --network "${MESH_NETWORK}" \
"${MESH_RUNTIME_IMAGE}" mcp-client \
-url "http://sam-node-1:8080/mcp/events" \
- -tool "find_remote_tools" \
+ -tool "find_remote_servers" \
-args "{\"peer_id\":\"${node2_peer_id}\"}"
- echo "find_remote_tools output: $output"
+ echo "find_remote_servers output: $output"
[[ "$status" -eq 0 ]]
# mcp-client prints each text-content line; the catalog JSON is the last non-empty line.
@@ -80,13 +80,13 @@ teardown() {
local match_count
match_count=$(echo "$catalog" | jq --arg pid "${node2_peer_id}" '
[.[] | select(.peer_id == $pid
- and (.tool_name | startswith("calculator.")))] | length
+ and (.server_name | startswith("calculator.")))] | length
')
echo "Matching calculator tool entries: ${match_count}"
[[ "${match_count}" -ge 1 ]]
}
-@test "call_remote_tool invokes an aggregated hosted-service tool end to end" {
+@test "call_remote_server invokes an aggregated hosted-service tool end to end" {
run mesh_start_mock_oidc
[[ "$status" -eq 0 ]]
@@ -122,22 +122,22 @@ teardown() {
[[ "$status" -eq 0 ]]
mesh_wait_for_peer_connection 1 "${node2_peer_id}" 20
- echo "[$(date +%T)] Calling call_remote_tool for calculator.add"
+ echo "[$(date +%T)] Calling call_remote_server for calculator.add"
local call_args
- call_args="{\"peer_id\":\"${node2_peer_id}\",\"tool_name\":\"calculator.add\",\"arguments\":{\"a\":2,\"b\":3}}"
+ call_args="{\"peer_id\":\"${node2_peer_id}\",\"server_name\":\"calculator.add\",\"arguments\":{\"a\":2,\"b\":3}}"
run docker run --rm --network "${MESH_NETWORK}" \
"${MESH_RUNTIME_IMAGE}" mcp-client \
-url "http://sam-node-1:8080/mcp/events" \
- -tool "call_remote_tool" \
+ -tool "call_remote_server" \
-args "${call_args}"
- echo "call_remote_tool output: $output"
+ echo "call_remote_server output: $output"
[[ "$status" -eq 0 ]]
# calc-mcp returns add(2,3)=5 as a TextContent string; "5" must appear in the response.
[[ "$output" == *"5"* ]]
}
-@test "describe_remote_tool returns input schema for an aggregated tool" {
+@test "describe_remote_server returns input schema for an aggregated tool" {
run mesh_start_mock_oidc
[[ "$status" -eq 0 ]]
@@ -173,28 +173,28 @@ teardown() {
[[ "$status" -eq 0 ]]
mesh_wait_for_peer_connection 1 "${node2_peer_id}" 20
- echo "[$(date +%T)] Calling describe_remote_tool for calculator.add"
+ echo "[$(date +%T)] Calling describe_remote_server for calculator.add"
local describe_args
- describe_args="{\"peer_id\":\"${node2_peer_id}\",\"tool_name\":\"calculator.add\"}"
+ describe_args="{\"peer_id\":\"${node2_peer_id}\",\"server_name\":\"calculator.add\"}"
run docker run --rm --network "${MESH_NETWORK}" \
"${MESH_RUNTIME_IMAGE}" mcp-client \
-url "http://sam-node-1:8080/mcp/events" \
- -tool "describe_remote_tool" \
+ -tool "describe_remote_server" \
-args "${describe_args}"
- echo "describe_remote_tool output: $output"
+ echo "describe_remote_server output: $output"
[[ "$status" -eq 0 ]]
# mcp-client prints each TextContent line; the JSON payload is the last non-empty line.
local payload
payload=$(echo "$output" | tail -n 1)
- # Assert peer_id, namespaced tool_name, and an input_schema with an object type.
+ # Assert peer_id, namespaced server_name, and an input_schema with an object type.
local got_peer
got_peer=$(echo "$payload" | jq -r '.peer_id')
[[ "${got_peer}" == "${node2_peer_id}" ]]
local got_name
- got_name=$(echo "$payload" | jq -r '.tool_name')
+ got_name=$(echo "$payload" | jq -r '.server_name')
[[ "${got_name}" == "calculator.add" ]]
local got_input_type
@@ -202,7 +202,7 @@ teardown() {
[[ "${got_input_type}" == "object" ]]
}
-@test "describe_remote_tool surfaces an error for an unknown tool" {
+@test "describe_remote_server surfaces an error for an unknown tool" {
run mesh_start_mock_oidc
[[ "$status" -eq 0 ]]
@@ -238,15 +238,15 @@ teardown() {
[[ "$status" -eq 0 ]]
mesh_wait_for_peer_connection 1 "${node2_peer_id}" 20
- echo "[$(date +%T)] Calling describe_remote_tool for an unknown tool"
+ echo "[$(date +%T)] Calling describe_remote_server for an unknown tool"
local describe_args
- describe_args="{\"peer_id\":\"${node2_peer_id}\",\"tool_name\":\"calculator.does-not-exist\"}"
+ describe_args="{\"peer_id\":\"${node2_peer_id}\",\"server_name\":\"calculator.does-not-exist\"}"
run docker run --rm --network "${MESH_NETWORK}" \
"${MESH_RUNTIME_IMAGE}" mcp-client \
-url "http://sam-node-1:8080/mcp/events" \
- -tool "describe_remote_tool" \
+ -tool "describe_remote_server" \
-args "${describe_args}"
- echo "describe_remote_tool output: $output"
+ echo "describe_remote_server output: $output"
# The peer's describe_local_tool handler returns "tool not found: <name>";
# handleDescribeRemoteTool wraps it as "describe_local_tool on <peer>: tool
diff --git a/tests/e2e/policy.bats b/tests/e2e/policy.bats
index a29c2523..24ed1d06 100644
--- a/tests/e2e/policy.bats
+++ b/tests/e2e/policy.bats
@@ -124,14 +124,14 @@ EOF
mesh_wait_for_log "${name}" "Mock OIDC server ready" 30
}
-mesh_call_remote_tool() {
+mesh_call_remote_server() {
local caller_idx="$1"
local target_peer_id="$2"
- local tool_name="$3"
+ local server_name="$3"
- local args="{\"peer_id\":\"${target_peer_id}\",\"tool_name\":\"${tool_name}\",\"arguments\":{}}"
+ local args="{\"peer_id\":\"${target_peer_id}\",\"server_name\":\"${server_name}\",\"arguments\":{}}"
- docker run --rm --network "${MESH_NETWORK}" "${MESH_RUNTIME_IMAGE}" mcp-client -url "http://sam-node-${caller_idx}:8080/mcp/events" -tool "call_remote_tool" -args "${args}"
+ docker run --rm --network "${MESH_NETWORK}" "${MESH_RUNTIME_IMAGE}" mcp-client -url "http://sam-node-${caller_idx}:8080/mcp/events" -tool "call_remote_server" -args "${args}"
}
setup() {
@@ -272,19 +272,19 @@ teardown() {
}
@test "Policy E2E: Positive Path (Allowed by Hub, Not blocked by Node)" {
- run mesh_call_remote_tool 2 "${TARGET_PEER_ID}" "query_database"
+ run mesh_call_remote_server 2 "${TARGET_PEER_ID}" "query_database"
echo "Output: $output"
[ "$status" -eq 0 ]
}
@test "Policy E2E: Negative Path (Denied by Hub)" {
- run mesh_call_remote_tool 2 "${TARGET_PEER_ID}" "reboot_server"
+ run mesh_call_remote_server 2 "${TARGET_PEER_ID}" "reboot_server"
echo "Output: $output"
[[ "$output" == *"denied"* ]]
}
@test "Policy E2E: Attenuation Path (Allowed by Hub, Blocked by Node)" {
- run mesh_call_remote_tool 2 "${TARGET_PEER_ID}" "delete_tables"
+ run mesh_call_remote_server 2 "${TARGET_PEER_ID}" "delete_tables"
echo "Output: $output"
[[ "$output" == *"denied"* ]]
}