Order SMM services from a Python agent: REST client on a mock node

Order SMM services from a Python agent

A ready REST client against a local OpenSMM node in plain Python: only urllib.request and json from the standard library — no pip install, no SDK, no keys, no money. The whole scenario: capabilities → catalog → quote → order → replay by clientReference.

1. Start the node (about 2 minutes)

The node needs Node.js ≥ 22.18; the Python client is fine with any Python 3 and the standard library.

bash
git clone https://github.com/opensmm-protocol/mcp-server.git
cd mcp-server
npm ci
npm run gateway

The node prints a line like gateway listening on http://localhost:8080 (REST /v0, MCP /mcp; provider: mock, mock catalog — not real supply) on stderr. Port taken? PORT=8081 npm run gateway. Other startup fixes: node startup failures.

2. Run the REST client (a second terminal)

bash
python3 examples/rest-client.py http://127.0.0.1:8080 --client-reference my-first-order
text
node:    http://127.0.0.1:8080
protocol: 0.1.0 - 10 commands, payment: mock
catalog: MOCK - every service is marked synthetic: not real supply, no real money
service: osmm_svc_tg_members_std - Telegram Channel Members — Standard
quote:   osmm_quote_... - 0.241200 USDC for 100 (mock rate)
order:   osmm_order_... - REQUIRES_PAYMENT, clientReference "my-first-order"
replay:  osmm_order_... - same orderId, no second order created
done:    Python client OK

Options: [base-url] (default http://127.0.0.1:8080), --client-reference <ref> (default python-demo-<timestamp>), --quote <quote-id> to reuse a quote printed by another run, --help.

3. What HTTP calls the client makes

  1. GET /v0/capabilities — the protocol version, the command list and the node's payment methods.
  2. GET /v0/services — the catalog; the client takes the first service from the node's answer and stops unless it is marked synthetic: true.
  3. POST /v0/quotes — a quote for quantity 100 and the link. A quote is consumed once; every order needs its own.
  4. POST /v0/orders — the order. The node answers HTTP 402 with the order body — expected, not a failure: the order stays REQUIRES_PAYMENT, nothing is paid or executed.
  5. POST /v0/orders again with the same clientReference — the replay returns the stored order instead of creating a second one.

The MCP equivalents of the same operations: POST /mcp with the search_services, get_quote, create_order tools — the Node.js MCP client.

4. Guard against a live provider

  • The client takes the first service from the node's answer — it invents no IDs — and stops at once unless it is marked synthetic: true.
  • The error message: refusing to place a demo order: ... is not marked synthetic. This example orders only on the mock catalog — see examples/README.md.
  • This guards against a node with a live provider attached: the demo order never reaches real supply.

5. If something looks wrong

  • is not marked synthetic — the node is not on the mock catalog; stop and do not order. Restart the node without a configured provider.
  • error: ... with the hint start a node first — npm run gateway — the node from step 1 is not running or listens on another port.
  • IDEMPOTENCY_CONFLICT — this clientReference already belongs to an order made from another quote: pass the original one via --quote or take a new reference.
  • HTTP 402 on POST /v0/orders — an expected answer: the client reads the order body right from it.

Honest limits

  1. This page retells examples/README.md in the mcp-server repo; the exact script output and options are there.
  2. The catalog is a mock (synthetic: true): no real services, prices or orders here; the rate in the example is a test one, nothing is paid.
  3. Other stacks: agent quickstart, the Node.js MCP client, a LangChain-style agent.

Next: your own node

The example runs on a local node. To be counted in the census, run a node and report its address.

Run your own node

The step-by-step guide, verification and reporting your node are on the “Run a node” page.