Skip to content

Agent Mesh

node: tell MCP clients about the local socket

Antonio Ojeadacc7fb1b6cf
diff --git a/internal/node/mcp.go b/internal/node/mcp.go
index 80720b88..eb0270ed 100644
--- a/internal/node/mcp.go
+++ b/internal/node/mcp.go
@@ -47,7 +47,9 @@ Other useful tools: discover_remote_services browses services by type (e.g. 'MCP
Tools on remote services are identified via the format 'scheme://service-name/tool-name' (where 'scheme://service-name' represents the well-known local address of the service, and 'tool-name' is the individual tool to execute on it. Tool names themselves can contain any characters).
-Inference services ('inference://...') are NOT called via call_remote_tool — they are plain OpenAI-compatible HTTP endpoints. Use discover_remote_services with type 'inference' to get each one's local_proxy_url, then send a normal HTTP request (e.g. POST <local_proxy_url>/chat/completions) directly to that URL: add header 'X-Sam-Authentication: Bearer <your local node API token>' to authenticate to this node, and only add 'Authorization: Bearer <upstream-credential>' if the destination service itself requires its own credential — it passes straight through untouched and is never used to authenticate to this node.`
+Inference services ('inference://...') are NOT called via call_remote_tool — they are plain OpenAI-compatible HTTP endpoints. Use discover_remote_services with type 'inference' to get each one's local_proxy_url, then send a normal HTTP request (e.g. POST <local_proxy_url>/chat/completions) directly to that URL: add header 'X-Sam-Authentication: Bearer <your local node API token>' to authenticate to this node, and only add 'Authorization: Bearer <upstream-credential>' if the destination service itself requires its own credential — it passes straight through untouched and is never used to authenticate to this node.
+
+When get_mesh_info reports a local_api_socket, that Unix socket serves this same HTTP API and needs no node token at all, since only the user who owns the socket can connect to it: prefer it for shell commands so no secret lands in a command line, e.g. 'curl --unix-socket <local_api_socket> <local_proxy_url>/chat/completions'.`
// NewMCPServer creates a new MCP server instance with all tools registered.
func NewMCPServer(node *SamNode) *mcp.Server {
diff --git a/internal/node/mcp_handlers.go b/internal/node/mcp_handlers.go
index a4de03f3..7f216543 100644
--- a/internal/node/mcp_handlers.go
+++ b/internal/node/mcp_handlers.go
@@ -208,6 +208,9 @@ func (n *SamNode) handleGetMeshInfo(ctx context.Context, req *mcp.CallToolReques
"dht_size": dhtSize,
"router_peer_id": n.RouterPeerID.String(),
}
+ if n.BoundSocketPath != "" {
+ resData["local_api_socket"] = n.BoundSocketPath
+ }
responseBytes, err := json.Marshal(resData)
if err != nil {
return nil, nil, err