Developer integration guide

Python Crypto Trading Bot with MCP Protocol

Most Python trading bots talk directly to exchange REST APIs. An MCP-based architecture separates the AI/tool interface from exchange execution, making it easier to connect agents, dashboards, and strategy code to the same trading primitive layer.

Install / configuration example

import subprocess

server = subprocess.Popen([
    "npx", "@qbtlabs/openmm-mcp"
], env={
    "OPENMM_EXCHANGE": "kraken",
    "OPENMM_API_KEY": "read_only_key",
    "OPENMM_API_SECRET": "secret",
})

# Your Python bot can connect through an MCP client layer,
# request ticker/order-book tools, then apply strategy policy
# before any execution tool is called.

Step-by-step setup

  1. 1. Run OpenMM MCP as a tool server

    Start the MCP server as a subprocess or sidecar service.

  2. 2. Keep strategy code separate

    Let Python own strategy logic while MCP exposes market data and execution tools.

  3. 3. Add policy checks

    Validate max order size, allowed symbols, and exchange permissions before any execution call.

  4. 4. Log every tool call

    Store request IDs, tool names, parameters, and execution results for auditability.

  5. 5. Dry-run before production

    Run the full workflow with simulated orders before enabling live API-key permissions.

Safety checklist

  • • Start with read-only API keys.
  • • Disable withdrawals on every exchange key.
  • • Use test/sandbox accounts or tiny balances for first live runs.
  • • Keep API keys in environment variables, never prompts or chat history.
  • • Log every tool call and execution result.

FAQ

Do I need Python to use OpenMM MCP?

No. OpenMM MCP is TypeScript/Node-based and works with MCP clients directly. Python is useful if your strategy engine is already Python.

What is the safest production pattern?

Use read-only keys for analysis, separate execution credentials, order-size caps, symbol allowlists, and complete audit logs.

Related docs and resources