Skip to content

Agent Mesh

docs: mcp-client reads the token from the environment or a file

Tomas Tormo2b5b8b6c1356
diff --git a/development/examples/chat-a2a/README.md b/development/examples/chat-a2a/README.md
index 0088e9fe..cca126b6 100644
--- a/development/examples/chat-a2a/README.md
+++ b/development/examples/chat-a2a/README.md
@@ -33,7 +33,7 @@ Sidecar API lands on `127.0.0.1:9099` with token `devtoken`.
## 4. Find the provider peer
```sh
-./bin/mcp-client -url http://127.0.0.1:9099/mcp -token devtoken \
+AGENTMESH_API_TOKEN=devtoken ./bin/mcp-client -url http://127.0.0.1:9099/mcp \
-tool discover_remote_services -args '{"type":"a2a","name":"chat"}'
```
diff --git a/development/kind/run.sh b/development/kind/run.sh
index 8225f359..fdd7deb9 100755
--- a/development/kind/run.sh
+++ b/development/kind/run.sh
@@ -286,8 +286,8 @@ echo
echo "To drive the mesh, enroll a local node in another shell (it stays in the foreground):"
echo " make build && make kind-local-node"
echo "then call its MCP API on 127.0.0.1:9099:"
-echo " ./bin/mcp-client -url http://127.0.0.1:9099/mcp -token devtoken -tool get_mesh_info -args '{}'"
-echo " ./bin/mcp-client -url http://127.0.0.1:9099/mcp -token devtoken -tool find_remote_tools -args '{}'"
+echo " AGENTMESH_API_TOKEN=devtoken ./bin/mcp-client -url http://127.0.0.1:9099/mcp -tool get_mesh_info -args '{}'"
+echo " AGENTMESH_API_TOKEN=devtoken ./bin/mcp-client -url http://127.0.0.1:9099/mcp -tool find_remote_tools -args '{}'"
if [[ "${1:-}" != "-s" ]]; then
show_cluster_logs
diff --git a/site/content/docs/contributing/_index.md b/site/content/docs/contributing/_index.md
index 302727ef..26ffdee1 100644
--- a/site/content/docs/contributing/_index.md
+++ b/site/content/docs/contributing/_index.md
@@ -123,7 +123,7 @@ To use the mesh from a node built from your working tree:
make kind-local-node # mints a bootstrap token, runs ./bin/agentmesh-node, API on 127.0.0.1:9099 with token "devtoken"
make kind-local-node ARGS="--config my-node.yaml"
-./bin/mcp-client -url http://127.0.0.1:9099/mcp -token devtoken -tool find_remote_tools -args '{}'
+AGENTMESH_API_TOKEN=devtoken ./bin/mcp-client -url http://127.0.0.1:9099/mcp -tool find_remote_tools -args '{}'
```
`make kind-e2e-mesh` runs the whole loop without interaction. It deploys
diff --git a/site/content/docs/getting-started/quickstart.md b/site/content/docs/getting-started/quickstart.md
index aca26777..c4d40274 100644
--- a/site/content/docs/getting-started/quickstart.md
+++ b/site/content/docs/getting-started/quickstart.md
@@ -87,29 +87,31 @@ address of the running node and exits.
## 4. Call a tool on the mesh
The node's local API is an MCP server. `mcp-client` is installed together
-with `agentmesh-node` and is the quickest way to talk to it. Export the token once:
+with `agentmesh-node` and is the quickest way to talk to it. `mcp-client`
+reads the token from `AGENTMESH_API_TOKEN` or from the file named by
+`-token-path`. Export the token once:
```bash
-export TOKEN=$(cat ~/.config/agentmesh/api-token)
+export AGENTMESH_API_TOKEN=$(cat ~/.config/agentmesh/api-token)
```
List the tools the node itself offers:
```bash
-mcp-client -url http://127.0.0.1:8080/mcp -token "$TOKEN" -list
+mcp-client -url http://127.0.0.1:8080/mcp -list
```
Find MCP services other nodes are publishing:
```bash
-mcp-client -url http://127.0.0.1:8080/mcp -token "$TOKEN" \
+mcp-client -url http://127.0.0.1:8080/mcp \
-tool discover_remote_services -args '{"type":"mcp"}'
```
Each result carries a `peer_id`. Ask one of them which tools it hosts:
```bash
-mcp-client -url http://127.0.0.1:8080/mcp -token "$TOKEN" \
+mcp-client -url http://127.0.0.1:8080/mcp \
-tool find_remote_tools -args '{"peer_id":"<peer-id>"}'
```
@@ -117,7 +119,7 @@ Then call one. The testnet runs the MCP reference `everything` server as a
demo. Its `add` tool adds two numbers:
```bash
-mcp-client -url http://127.0.0.1:8080/mcp -token "$TOKEN" \
+mcp-client -url http://127.0.0.1:8080/mcp \
-tool call_remote_tool \
-args '{"peer_id":"<peer-id>","tool_name":"mcp://everything/add","arguments":{"a":2,"b":3}}'
```
diff --git a/site/content/docs/guides/egress-destinations.md b/site/content/docs/guides/egress-destinations.md
index 9ec83c75..00c14026 100644
--- a/site/content/docs/guides/egress-destinations.md
+++ b/site/content/docs/guides/egress-destinations.md
@@ -157,7 +157,7 @@ A member whose role grants `egress://api.github.com` reaches the same
destination through its own node, which finds the serving node by name:
```bash
-curl -sS -H "X-Mesh-Authentication: Bearer $TOKEN" \
+curl -sS -H "X-Mesh-Authentication: Bearer $AGENTMESH_API_TOKEN" \
"http://127.0.0.1:8080/mesh/$PEP_PEER_ID/egress/api.github.com/repos/acme/dubbing/pulls"
```
diff --git a/site/content/docs/guides/exposing-services.md b/site/content/docs/guides/exposing-services.md
index c225d00c..6425bceb 100644
--- a/site/content/docs/guides/exposing-services.md
+++ b/site/content/docs/guides/exposing-services.md
@@ -235,10 +235,11 @@ and the `granted_*` facts), plus `service($type, $name)` for the request and
## Checking that it worked
-From another enrolled node:
+From another enrolled node, with `AGENTMESH_API_TOKEN` set to that node's API
+token as in the [quick start](../../getting-started/quickstart/#4-call-a-tool-on-the-mesh):
```bash
-mcp-client -url http://127.0.0.1:8080/mcp -token "$TOKEN" \
+mcp-client -url http://127.0.0.1:8080/mcp \
-tool discover_remote_services -args '{"type":"mcp","name":"calculator"}'
```
diff --git a/site/content/docs/guides/kubernetes.md b/site/content/docs/guides/kubernetes.md
index c98b4d8c..c5f630c6 100644
--- a/site/content/docs/guides/kubernetes.md
+++ b/site/content/docs/guides/kubernetes.md
@@ -180,10 +180,11 @@ kind cluster. See [Contributing](../../contributing/#a-local-mesh-in-kind).
kubectl -n agentmesh-nodes logs deploy/calc-mcp -c agentmesh-node | grep -E "Online|PeerID"
```
-From a node enrolled anywhere in the mesh:
+From a node enrolled anywhere in the mesh, with `AGENTMESH_API_TOKEN` set to
+that node's API token as in the [quick start](../../getting-started/quickstart/#4-call-a-tool-on-the-mesh):
```bash
-mcp-client -url http://127.0.0.1:8080/mcp -token "$TOKEN" \
+mcp-client -url http://127.0.0.1:8080/mcp \
-tool discover_remote_services -args '{"type":"mcp","name":"calculator"}'
```
diff --git a/site/content/docs/preview/mobile.md b/site/content/docs/preview/mobile.md
index 95cbd5c3..dddd6c7a 100644
--- a/site/content/docs/preview/mobile.md
+++ b/site/content/docs/preview/mobile.md
@@ -368,11 +368,14 @@ app in the foreground.
## Calling the phone from elsewhere
-From any enrolled node, the phone is a peer with an MCP service:
+From any enrolled node, the phone is a peer with an MCP service. Set
+`AGENTMESH_API_TOKEN` to the calling node's API token as in
+the [quick start](../../getting-started/quickstart/#4-call-a-tool-on-the-mesh),
+then run:
```bash
-mcp-client -url "http://127.0.0.1:8080/mesh/<phone-peer-id>/mcp/phone-sensors" -token "$TOKEN" -list
-mcp-client -url "http://127.0.0.1:8080/mesh/<phone-peer-id>/mcp/phone-sensors" -token "$TOKEN" -tool get_battery_status
+mcp-client -url "http://127.0.0.1:8080/mesh/<phone-peer-id>/mcp/phone-sensors" -list
+mcp-client -url "http://127.0.0.1:8080/mesh/<phone-peer-id>/mcp/phone-sensors" -tool get_battery_status
```
```json
diff --git a/site/content/docs/reference/node-api.md b/site/content/docs/reference/node-api.md
index e6fffc48..11433b44 100644
--- a/site/content/docs/reference/node-api.md
+++ b/site/content/docs/reference/node-api.md
@@ -270,7 +270,7 @@ curl -s --unix-socket $SOCK $URL \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
```
-Over TCP, add `-H "X-Mesh-Authentication: Bearer $TOKEN"` and use
+Over TCP, add `-H "X-Mesh-Authentication: Bearer $AGENTMESH_API_TOKEN"` and use
`http://127.0.0.1:8080` as the base URL.
### Talking A2A through the proxy
@@ -291,7 +291,7 @@ line; `X-Mesh-Required-Labels` goes in the same variable, comma-separated:
```bash
CARD=http://127.0.0.1:8080/mesh/<peer-id>/a2a/triage/.well-known/agent-card.json
-export A2ACLI_SVC_PARAM="X-Mesh-Authentication=Bearer $TOKEN"
+export A2ACLI_SVC_PARAM="X-Mesh-Authentication=Bearer $AGENTMESH_API_TOKEN"
a2a card get $CARD
a2a send -a $CARD "hello"
```
diff --git a/site/content/docs/use-cases/chat-a2a.md b/site/content/docs/use-cases/chat-a2a.md
index 3fd8be45..0719c637 100644
--- a/site/content/docs/use-cases/chat-a2a.md
+++ b/site/content/docs/use-cases/chat-a2a.md
@@ -104,7 +104,7 @@ The local node is your entry point. Its API listens on
### 4. Find the provider peer
```bash
-./bin/mcp-client -url http://127.0.0.1:9099/mcp -token devtoken \
+AGENTMESH_API_TOKEN=devtoken ./bin/mcp-client -url http://127.0.0.1:9099/mcp \
-tool discover_remote_services -args '{"type":"a2a","name":"chat"}'
```