Developers

Leafr MCP & API Documentation

Leafr is an MCP server purpose-built for cannabis distribution — your AI can draft a METRC transfer, not just read a sales report. Connect your own AI — Claude, ChatGPT, or Cursor — to your live Leafr operation with one connection. Your AI reads your data and prepares work; a human approves everything.

1. Overview

Leafr exposes a Model Context Protocol (MCP) connection so the AI assistant you already use can work directly with your live operation — orders, inventory, METRC, routes, reorders, and analytics.

The rule that makes this safe: AI proposes, a human approves. Leafr’s connection gives your AI read access and the ability to PREPARE drafts (an order, a METRC transfer template, an optimized route). It never submits to METRC, moves money, or dispatches on its own. Drafts land in Leafr for a person to review and approve. Co-pilot, not autopilot.

The exact connector URL and your API key live in your Leafr account under Settings → API & MCP Docs.

2. Two ways to connect

A) Connect your AI assistant (recommended) — Claude, ChatGPT, or Cursor

In your AI client, add Leafr as an MCP connector using the MCP URL shown in Settings → API & MCP Docs.

You’ll sign in to Leafr and approve (consent to) the scopes the assistant is asking for. That’s it — no key to paste.

Re-run the consent step any time you want to grant additional scopes.

B) API key (for custom/programmatic use)

Generate an API key in Settings → API & MCP Docs.

Send it as a header on requests to the Leafr API (see Section 7). Keep it secret; rotate anytime.

3. The safety model (read this)

  • AI proposes, you approve. Anything that changes the real world (a METRC submission, a payment, a dispatch) requires a human to approve it inside Leafr.
  • Nothing auto-submits. Drafts (orders, METRC transfer templates) are created as drafts only.
  • Scoped access. You grant scopes when you connect; you can review and revoke them.
  • Guardrails. Sensitive/compliance actions are gated (e.g., an OMMA deny-list blocks disallowed actions). Your data stays yours.

4. What your AI can do (the tool surface — ~31 read + draft tools)

  • Read / insights — get_counts (top-line counts across the operation), analytics_summary (revenue, AOV, active accounts, top-line KPIs), top_products (best-selling products), account_detail (a tenant/operation snapshot).
  • Orders & customers — list_orders / get_order (browse and inspect orders), list_customers / get_customer (accounts and their detail).
  • Inventory & products — inventory_summary (on-hand / reserved / available), search_inventory (find inventory by query), list_products (the catalog).
  • METRC / compliance — metrc_actions (the “what needs doing now” queue), metrc_drafts (drafts awaiting approval), metrc_lab_status (lab test states), metrc_packages (package tags), list_metrc_transfer_types (valid transfer types).
  • Routes & dispatch — list_routes / list_routes_detailed (planned and active routes), list_deliveries (the day’s delivery schedule), dispatch_map (live route/driver view), driver_cashout (end-of-day cash-out reconciliation).
  • Reorder intelligence — reorders_due (accounts overdue by their own cadence / at-risk).
  • Draft (prepare, never auto-submit — human approves in Leafr) — draft_transfer_template_for_orders (build a METRC transfer template from orders), draft_transfer_templates_from_route (build transfer templates straight off a route), draft_lab_transfer (prepare a lab transfer).
  • …and related read/draft tools — ~31 total. The full, current list is in Settings → API & MCP Docs.

5. Example things to ask your AI

“Draft a METRC transfer template for today’s OKC route.”

“Which accounts are overdue to reorder and how much is at risk?”

“Turn this spreadsheet into draft orders.” (paste/attach the sheet)

“Show me on-hand vs reserved for our vape carts.”

“Pull a driver cash-out for route Norman Loop.”

“What does METRC need from me right now?”

“What were our top products and AOV last week?”

Your AI prepares the answer or the draft; you review and approve in Leafr.

6. Scopes & permissions

  • Read scopes let the AI see your data. Draft scopes let it prepare drafts that you approve.
  • You approve scopes at connect time; add more later by re-consenting.
  • Compliance/money/dispatch actions always require explicit human approval in the Leafr UI.

7. API (REST) — for custom integrations

  • Base URL and the full endpoint reference are in Settings → API & MCP Docs in your account.
  • Auth: send your API key in the request header (header name shown with your key).
  • Money fields are returned in cents.
  • Be mindful: write/compliance endpoints follow the same approve-in-app model.

8. Rate limits & support

  • Reasonable per-account rate limits apply; contact us if you need more headroom.
  • Questions: hello@leafr.ai.