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.
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)
python3 examples/rest-client.py http://127.0.0.1:8080 --client-reference my-first-order
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
GET /v0/capabilities— the protocol version, the command list and the node's payment methods.GET /v0/services— the catalog; the client takes the first service from the node's answer and stops unless it is markedsynthetic: true.POST /v0/quotes— a quote for quantity 100 and the link. A quote is consumed once; every order needs its own.POST /v0/orders— the order. The node answers HTTP 402 with the order body — expected, not a failure: the order staysREQUIRES_PAYMENT, nothing is paid or executed.POST /v0/ordersagain with the sameclientReference— 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 hintstart a node first — npm run gateway— the node from step 1 is not running or listens on another port.IDEMPOTENCY_CONFLICT— thisclientReferencealready belongs to an order made from another quote: pass the original one via--quoteor take a new reference.- HTTP 402 on
POST /v0/orders— an expected answer: the client reads the order body right from it.
Honest limits
- This page retells examples/README.md in the mcp-server repo; the exact script output and options are there.
- 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. - 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.
The step-by-step guide, verification and reporting your node are on the “Run a node” page.