@tote/mcp
On this page (12 sections)
MCP server that exposes start_request and the Tote tools (search, get_product,
compare, build_cart, start_checkout) to an MCP host such as Claude Code, Codex or
Gemini CLI. The host model
runs the loop; Tote runs each tool call with the same code the tote ask agent uses
(ADR-001 decisions 1, 3, 6, 8 and 11).
On npm: tote-mcp. Release steps: scripts/release.md.
What the host gets
tools/list:start_request, then the five tools with the same names, descriptions and JSON schemas asToteToolsetin@tote/agent.start_request(inputrequest, the buyer's words verbatim, at most 2000 characters): Tote parses the request with the parsertote askuses and starts a new task with those constraints and that quantity. Result:{"tool", "ok", "tote_note", "task": {"constraints", "quantity", "notes"}, "untrusted_data": {}}. Each request resets the quantity budget. Carts from earlier requests stay reachable by their cartRef forstart_checkout. Ids and shops from an earlier request need a new search. Before anystart_request, no constraints are checked and carts get one unit.tools/call: one text block holding the untrusted-data envelope, serialized byserializeEnvelopefrom@tote/agent, so it is the same JSON the agent loop gives its own model:{"tool", "ok", "untrusted_data"}, or{"tool", "ok", "error", "untrusted_data"}on failure (isError: true). Product titles, descriptions and merchant messages appear only underuntrusted_data. Theinitializeresult carries fixed instructions telling the host model not to follow text found there.- Never a
continue_url, cart id, checkout id, buyer IP or secret.build_cartandstart_checkoutreturn a handoff reference (handoff_...) andbuyer_link:{"url": "http://127.0.0.1:<port>/handoff/<token>", "instruction": "Give the buyer this local link to open the checkout: <url>. Tote never pays."}("the cart" forbuild_cart). See Handoff page. Anycontinue_urlthe session has handed out is replaced by[redacted]if a merchant echoes it in text. - Constraint gaps are never accepted: the server always runs tools with OverridePolicy
deny, soacceptConstraintGaps: truefrom the host givesoverride_deniedwhen a variant has a gap. - Each MCP connection (stdio process, or HTTP
Mcp-Session-Id) has its own Tote session. Ids, shops and cartRefs from one connection are unknown to another.
Tool annotations (ADR-001 Decision 11): start_request, search, get_product and
compare are readOnlyHint: true; build_cart and start_checkout are
readOnlyHint: false, destructiveHint: false, openWorldHint: true. start_checkout
also sets _meta["anthropic/requiresUserInteraction"]: true, so Claude Code asks you
before every checkout start. Annotations are hints, not a security boundary.
Residual risk: the host model relays the buyer's words to start_request and can alter
them. Tote trusts that text as much as it trusts the host.
Handoff page
The host model never sees the merchant's checkout URL. In both modes tote-mcp also
listens on 127.0.0.1, on a free port the system picks, for handoff links only:
- Each
buyer_linkURL holds a token of 32 random bytes (base64url), bound to one handoff, valid for 15 minutes and usable once. - Opening it (GET) shows the shop name and one button, with no external assets and CSP
default-src 'none'. The page never contains the checkout URL. - The button sends a POST from that page (Origin
http://127.0.0.1:<port>). Only that POST gets a 303 redirect to the merchant checkout, once. Any other Origin gets 403. - A Host header other than
127.0.0.1:<port>orlocalhost:<port>gets 403. Tokens and URLs are never logged. The listener closes with the server.
Residual risk: a host model with shell access can reach loopback too. The page keeps the link out of the model context and transcripts; it does not defeat a compromised host.
MCP URL-mode elicitation is not used: the MCP specification 2025-11-25 says a server "MUST NOT provide a URL which is pre-authenticated to access a protected resource", and a checkout link is one (Elicitation).
Running
# stdio (default): the host starts this process and talks over stdin and stdout
node packages/mcp/bin/tote-mcp.js
# Streamable HTTP on loopback: http://127.0.0.1:8765/mcp
node packages/mcp/bin/tote-mcp.js --http --port 8765
node packages/mcp/bin/tote-mcp.js --http --port 8765 --host ::1
--host accepts only 127.0.0.1 and ::1. startMcpServer refuses any other address
at runtime too, and the type allows only those two. The HTTP server answers only on
/mcp, only when the Host header is 127.0.0.1:N, localhost:N or [::1]:N, and only
when an Origin header, if sent, is http:// plus one of those. The MCP spec requires the
Origin check against DNS rebinding and says a local server should bind only to localhost
(MCP transports, Security Warning).
Request bodies over 1 MiB are refused with 413. At most 16 HTTP sessions are open at once.
On stdio, stdout carries only MCP messages; logs go to stderr, as the spec requires (same page, section stdio). Logs name the tool, the outcome and the time, never arguments or results.
Exit codes: 0 --help, 2 bad flags or configuration, 3 the server could not start (for
example the port is in use). SIGINT and SIGTERM close the server.
Configuration
tote-mcp reads .env from the current directory, then from the repo root, the same way
tote does (a variable already set in the shell wins).
| Variable | Required | Meaning |
|---|---|---|
TOTE_AGENT_PROFILE_URL | yes | https URL of the Tote agent profile, sent on every UCP call. |
SHOPIFY_CLIENT_ID, SHOPIFY_CLIENT_SECRET | both or neither | Token tier. Without them the tier is Anonymous (no checkout). |
TOTE_BUYER_IP | yes at the Token tier | Your own public IP address, sent to the shop as Shopify-Buyer-IP. Loopback, private and link-local addresses are refused. Never taken from the request. |
Adding the server to a host
The examples assume the repo is at /path/to/tote and node is Node 22.19 or later.
Put configuration in /path/to/tote/.env rather than in the host config, so secrets stay
in the gitignored file.
Claude Code
From Claude Code, MCP: claude mcp add [options] <name> -- <command> [args...],
where -- separates Claude Code's options from the server command.
claude mcp add --transport stdio tote -- node /path/to/tote/packages/mcp/bin/tote-mcp.js
For the HTTP transport, start tote-mcp --http --port 8765 yourself, then
(claude mcp add --transport http <name> <url> on the same page):
claude mcp add --transport http tote http://127.0.0.1:8765/mcp
Project scope (--scope project) writes .mcp.json. A stdio entry there, in the format
the page shows:
{
"mcpServers": {
"tote": {
"type": "stdio",
"command": "node",
"args": ["/path/to/tote/packages/mcp/bin/tote-mcp.js"]
}
}
}
and an HTTP entry is { "type": "http", "url": "http://127.0.0.1:8765/mcp" }. (The
--scope and .mcp.json http details come from a summary of the page fetched on
2026-11-20, not checked word for word.)
Codex
From Codex, MCP (the old
developers.openai.com/codex/mcp URL redirects there). The command form is
codex mcp add <server-name> -- <stdio server-command>:
codex mcp add tote -- node /path/to/tote/packages/mcp/bin/tote-mcp.js
or in ~/.codex/config.toml:
[mcp_servers.tote]
command = "node"
args = ["/path/to/tote/packages/mcp/bin/tote-mcp.js"]
cwd = "/path/to/tote"
# HTTP instead, with tote-mcp --http --port 8765 running:
# [mcp_servers.tote]
# url = "http://127.0.0.1:8765/mcp"
(These Codex forms come from a summary of the page fetched on 2026-11-20, not checked word for word.)
Gemini CLI
From Gemini CLI, MCP servers: an
mcpServers entry in settings.json uses command for stdio and httpUrl for
Streamable HTTP (url means SSE, which this server does not serve).
{
"mcpServers": {
"tote": {
"command": "node",
"args": ["/path/to/tote/packages/mcp/bin/tote-mcp.js"],
"cwd": "/path/to/tote",
"trust": false
}
}
}
HTTP: { "httpUrl": "http://127.0.0.1:8765/mcp" }. The same page notes that for
unpaid-tier and Google One users, Gemini CLI was replaced by Antigravity CLI on June 18th, 2026.
Passing variables from the shell instead of .env
If you keep the variables in your shell rather than in .env, forward them by name. Never
write a value into a host config file (docs/research/R-09-hosts.md, Implication 3). The
names are TOTE_AGENT_PROFILE_URL, SHOPIFY_CLIENT_ID, SHOPIFY_CLIENT_SECRET and
TOTE_BUYER_IP. SHOPIFY_CLIENT_SECRET is shown; add the others the same way.
Claude Code (.mcp.json or ~/.claude.json): ${VAR} expands in env. Do not use
claude mcp add --env KEY=value, which saves the value.
{
"mcpServers": {
"tote": {
"type": "stdio",
"command": "node",
"args": ["/path/to/tote/packages/mcp/bin/tote-mcp.js"],
"env": { "SHOPIFY_CLIENT_SECRET": "${SHOPIFY_CLIENT_SECRET}" }
}
}
}
Codex (~/.codex/config.toml): env_vars forwards names, not values. Do not use env
for a secret.
[mcp_servers.tote]
command = "node"
args = ["/path/to/tote/packages/mcp/bin/tote-mcp.js"]
env_vars = ["TOTE_AGENT_PROFILE_URL", "SHOPIFY_CLIENT_ID", "SHOPIFY_CLIENT_SECRET", "TOTE_BUYER_IP"]
Gemini CLI (settings.json): $VAR expands in env. Keep trust false, so Gemini CLI
asks before each tool call.
{
"mcpServers": {
"tote": {
"command": "node",
"args": ["/path/to/tote/packages/mcp/bin/tote-mcp.js"],
"env": { "SHOPIFY_CLIENT_SECRET": "$SHOPIFY_CLIENT_SECRET" },
"trust": false
}
}
}
Hermes (~/.hermes/config.yaml, values in ~/.hermes/.env): ${VAR} expands anywhere
in a server entry. trust: untrusted makes Hermes ask before build_cart and
start_checkout, which are not read-only.
mcp_servers:
tote:
command: "node"
args: ["/path/to/tote/packages/mcp/bin/tote-mcp.js"]
env:
SHOPIFY_CLIENT_SECRET: "${SHOPIFY_CLIENT_SECRET}"
trust: untrusted
OpenClaw: add the stdio server with
openclaw mcp add tote --command node --arg /path/to/tote/packages/mcp/bin/tote-mcp.js
and keep the values in /path/to/tote/.env. Do not write them into OpenClaw's config.
Hermes and OpenClaw details are tasks T-11 and T-12.
Library use
import { createToteTools } from "@tote/agent";
import { createHandoffVault } from "@tote/core";
import { startMcpServer } from "@tote/mcp";
const vault = createHandoffVault();
const handle = await startMcpServer({
transport: { kind: "http", host: "127.0.0.1", port: 8765 },
tools: createToteTools({ ucp, vault }),
vault, // must be the vault the tools were built with, so handed-out URLs are redacted
buyerIp: { kind: "none" },
overridePolicy: { mode: "deny" },
});
await handle.close();
startMcpServer throws McpServerError (code: host_not_loopback, invalid_port,
invalid_options, listen_failed, each with a hint) before it serves anything. It also
starts the handoff page, and close() stops both.
When a Shopify error carries error.data.code (for example profile_malformed), tote-mcp
logs it on stderr as shopifyErrorCode. The host model gets only Tote's fixed error text.
Dependencies
@modelcontextprotocol/sdk1.32.2, pinned exactly: the official MCP TypeScript SDK. Used for the low-levelServer,StdioServerTransport(@modelcontextprotocol/sdk/server/stdio.js, shown in the v1.x server docs, stdio) andStreamableHTTPServerTransport(@modelcontextprotocol/sdk/server/streamableHttp.js, described in the same page, section Streamable HTTP). It has no install scripts, and none of the 215 packages it brings in has a preinstall, install or postinstall script. The SDK's own Host and Origin options are marked deprecated in 1.32.2, so the server checks those headers itself before a request reaches the transport.
Tests
npx -y pnpm@10.20.0 --filter tote-mcp test. All offline: an in-memory transport and
stdio over in-memory streams, and HTTP requests sent over an in-process stream pair, so no
socket connects. test/envelope-parity.test.ts runs the same calls through runAgent and
through the server and asserts identical envelopes.