This guide explains how to manually validate the local MCP flow with Codex CLI:
facilitator/basic(payment facilitator)servers/mcp(upstream MCP server)gateway/mcp(gateway MCP server)- Codex CLI registered to
gateway/mcp
- Node.js 20+ and
pnpm - Codex CLI installed and logged in
- A valid
EVM_PRIVATE_KEYingateway/mcp/.env
Check Codex CLI login:
codex loginPrepare env files if not already done:
cp facilitator/basic/.env-local facilitator/basic/.env
cp servers/mcp/.env-local servers/mcp/.env
cp gateway/mcp/.env-local gateway/mcp/.envRequired values to verify:
facilitator/basic/.envEVM_PRIVATE_KEYEVM_NETWORKEVM_CHAIN_IDEVM_RPC_URL
servers/mcp/.envEVM_ADDRESSFACILITATOR_URL(default:http://localhost:4022)EVM_NETWORK
gateway/mcp/.envEVM_PRIVATE_KEYMCP_UPSTREAM_URL(default:http://localhost:4023)EVM_NETWORK,EVM_CHAIN_ID,EVM_RPC_URL
pnpm -C facilitator/basic install
pnpm -C servers/mcp install
pnpm -C gateway/mcp installStart in this order.
Terminal A:
pnpm -C facilitator/basic devTerminal B:
pnpm -C servers/mcp devTerminal C:
pnpm -C gateway/mcp devExpected startup ports:
- Facilitator:
http://localhost:4022 - Upstream MCP:
http://localhost:4023 - Gateway MCP:
http://localhost:4024
From a new terminal:
curl -sS http://127.0.0.1:4023/health
curl -sS http://127.0.0.1:4024/healthExpected:
- Upstream returns status with tool list (
get_weather,ping) - Gateway returns JSON containing
status,upstream, andtools
codex mcp remove x402-gateway || true
codex mcp add x402-gateway --url http://127.0.0.1:4024/mcp
codex mcp list
codex mcp get x402-gatewayExpected:
x402-gatewayis listed as enabled- URL is
http://127.0.0.1:4024/mcp
codex exec --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox "Do not run any shell commands. Use MCP server x402-gateway and call ping tool exactly once. Return only the ping result text."Expected:
- MCP startup shows
x402-gateway ready - tool call
x402-gateway.ping({})succeeds - final output includes
pong
codex exec --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox "Do not run any shell commands. Use MCP server x402-gateway. Call tool x402-gateway.get_weather exactly once with arguments: {\"city\":\"Seoul\"}. If the tool call arguments differ from that JSON, report failure. Then return summarized weather result and whether payment was required."Expected:
- tool call succeeds
- response payload includes payment/policy envelope fields
Failed to fetch supported kinds from facilitator- Facilitator is not running or
FACILITATOR_URLis incorrect.
- Facilitator is not running or
ECONNREFUSEDfrom gateway/upstream- Upstream or gateway is not running, or wrong port in env.
- MCP registered but calls fail
- Re-register server:
codex mcp remove x402-gateway && codex mcp add x402-gateway --url http://127.0.0.1:4024/mcp
- Env validation errors at startup
- Recheck required env variables in each package
.env.
- Recheck required env variables in each package
Stop all services with Ctrl+C in each terminal.
Optional cleanup:
codex mcp remove x402-gateway