Integrating SAM with OpenClaw
You can seamlessly integrate your sam-node as a remote MCP server in OpenClaw, allowing your agents to dynamically discover and invoke tools across the mesh.
Overview
By configuring your sam-node as an MCP server, you enable your OpenClaw agents to access the P2P mesh, discovering tools from remote nodes and executing services as if they were local.
Configuration
To bridge your local sam-node into your OpenClaw agent runtime, use the openclaw mcp CLI. Ensure your node is running and identify the API token configured in your sam-node launch arguments.
# Add your local sam-node as an MCP server
# Replace <YOUR_TOKEN> with the token used in --api-token
openclaw mcp set p2p-mesh-node '{
"url": "http://localhost:8080/mcp",
"transport": "sse",
"headers": {
"Authorization": "Bearer <YOUR_TOKEN>"
}
}'
Verification
Once configured, restart your OpenClaw gateway to initialize the bridge. You can verify the configuration and connectivity with the following commands:
List configured servers: Ensure
p2p-mesh-nodeappears in the registry.openclaw mcp listInspect the bridged tools: Confirm the server entry and its connection details.
openclaw mcp show p2p-mesh-node
Discovering and Invoking Remote Tools
OpenClaw is a generic MCP client and exposes no SAM-specific CLI flags. Once the bridge is active, the tools that sam-node provides — discover_remote_services, find_remote_tools, describe_remote_tool, and call_remote_tool — are surfaced directly to your agent, which calls them like any other tool. The flow mirrors the local MCP API:
Discover services: the agent calls
discover_remote_services(e.g. with{"type": "mcp"}) to list active MCP services on the mesh and obtain theirpeer_ids.Find remote tools: the agent calls
find_remote_tools, passing the targetpeer_id, to list the tools that peer hosts.Describe a remote tool: the agent calls
describe_remote_tool, passing the targetpeer_idand the namespacedtool_name, to fetch the tool’sinput_schema. This is required to learn the expected argument structure before invoking it.Invoke a remote tool: the agent calls
call_remote_tool, passing the targetpeer_id, the namespacedtool_name(e.g.everything.get-sum), and the tool’sarguments(matching the schema from the previous step). Your localsam-nodeproxies the call across the P2P mesh and returns the result.
Because these tools are surfaced automatically, no remote tool needs to be registered individually in OpenClaw.
Troubleshooting
- Connection Issues: Ensure
sam-nodeis reachable at the configured URL (defaulthttp://localhost:8080/mcp). - Authentication: Double-check that the
Authorizationheader matches the--api-tokenprovided to yoursam-node. - Gateway Status: Use
openclaw statusto confirm the gateway is running and the MCP bridge is active.