@posara/horizon-mcp
v1.3.0
Published
POSARA Horizon MCP Server — connect any AI assistant to your business data
Readme
POSARA Horizon MCP Server
Connects any MCP-capable AI assistant (Claude Desktop, Claude Code, …) to a POSARA Horizon business: read reports, manage the catalog, control inventory, and raise purchase orders.
Quick Start
- In Horizon, open Apps → Horizon MCP → Tokens and generate a token, ticking only the privileges the assistant should have.
- Run the server with
npx, pointing it at your instance:
HORIZON_API_URL=https://posara-horizon-t1.dcn01.ctdn.dev \
HORIZON_API_KEY=your-mcp-token \
npx @posara/horizon-mcpThis starts the HTTP transport on :3001/mcp by default. For Claude Desktop
or other local stdio clients, set MCP_TRANSPORT=stdio instead:
{
"mcpServers": {
"posara-horizon": {
"command": "npx",
"args": ["-y", "@posara/horizon-mcp"],
"env": {
"MCP_TRANSPORT": "stdio",
"HORIZON_API_URL": "https://posara-horizon-t1.dcn01.ctdn.dev",
"HORIZON_API_KEY": "your-mcp-token"
}
}
}
}Pass --verbose (or set MCP_LOG_LEVEL=verbose) to log each request and tool
call to stderr:
npx @posara/horizon-mcp --verboseAlready on Horizon? You may not need to run anything
Every Horizon deployment already exposes MCP over HTTP at /api/v1/mcp —
remote clients (Claude custom connectors, any other remote MCP client) can
talk to it directly instead of running this package at all:
POST https://posara-horizon-t1.dcn01.ctdn.dev/api/v1/mcp
Authorization: Bearer <mcp-token>Run this package yourself only for local stdio access (Claude Desktop) or to front a self-hosted instance. One deployment serves many businesses — the token identifies both the business and the granted privileges.
Claude custom connector (OAuth)
Instead of pasting a token, register an OAuth client in Apps → Horizon MCP →
Connectors, then in Claude: Settings → Connectors → Add custom connector,
paste https://<your-host>/api/v1/mcp, and put the Client ID and Client Secret
under Advanced settings. Claude opens the Horizon consent screen; each user
approves individually, and access tokens refresh automatically.
Discovery is served by the app, not this package:
| Endpoint | Purpose |
|---|---|
| /.well-known/oauth-protected-resource[/api/v1/mcp] | RFC 9728 — points clients at the authorization server |
| /.well-known/oauth-authorization-server[/api/v1/mcp] | RFC 8414 — authorize/token endpoints, scopes, PKCE methods |
| /oauth/authorize | consent screen |
| /api/v1/oauth/token | token exchange (client_secret_post or client_secret_basic) |
Unauthenticated or expired requests get 401 with a
WWW-Authenticate: Bearer … resource_metadata="…" challenge, which is what
triggers the client to (re-)run the flow. Set HORIZON_PUBLIC_URL when
HORIZON_API_URL is an internal address, so that challenge points somewhere
clients can actually reach.
There is deliberately no Dynamic Client Registration — registration_endpoint
is absent from the metadata, so clients fall back to asking for a Client ID and
Secret. A business registers a connector once, on purpose.
Tools
| Group | Tools |
|---|---|
| sales | get_dashboard_overview · get_sales_summary · get_top_products · get_invoices · get_invoice · get_invoice_payments · get_invoice_refunds · void_invoice* · refund_invoice* · get_orders · get_order · create_order* · get_customers · get_branches |
| products | search_products · get_product · get_product_units · create_product* · update_product* · get_product_bundle · set_product_bundle* · get_product_activity · get_catalog_metadata · get_product_images · import_product_image* |
| catalog | add_product_unit* · update_product_unit* · get_product_variants · add_product_variant* · create_category* · create_brand* · create_warehouse* · get_batch_lots · get_inventory_identifiers · get_trash · restore_from_trash* |
| inventory | get_inventory_status · get_inventory_movements · adjust_inventory* · import_stock* · get_inventory_summary · get_inventory_analytics · get_expiring_inventory · get_warehouses |
| transfers | get_transfers · get_transfer · create_transfer* · update_transfer* · approve_transfer* · reject_transfer* · dispatch_transfer* · receive_transfer* · get_transfer_receipts · cancel_transfer* |
| purchasing | get_suppliers · get_reorder_suggestions · get_purchase_orders · get_purchase_order · create_purchase_order* · update_purchase_order* · receive_purchase_order* · get_purchase_order_receipts |
| customers | get_customer · create_customer* · update_customer* · get_customer_credit · record_customer_credit* · get_customer_loyalty · adjust_customer_loyalty* · get_customer_groups · get_loyalty_programs · get_promotions · create_promotion* · update_promotion* · get_customer_credit_summary |
| finance | get_payments · create_payment* · get_payment_methods · record_supplier_payment* · get_supplier_balance · create_supplier* · update_supplier* · get_chart_of_accounts · create_account* · get_account_balances · get_journal_entries · create_journal_entry* · get_exchange_rates · set_exchange_rate* |
| admin | get_employees · create_employee* · update_employee* · get_users · get_roles · update_user* · get_settings · update_settings* · get_audit_logs |
| bulk | bulk_import_products* · bulk_manage_categories* · bulk_update_prices* |
| reports | get_report · get_tax_report · get_branch_performance_report · get_supplier_payments_report · get_customer_credit_report · get_customer_sales_report · get_category_sales_report · get_promotions_report · get_loyalty_report · get_cash_flow_report |
| docs | search_documentation |
| profile | get_profile |
* Write tool — needs the matching *.write privilege on the token and is
annotated readOnlyHint: false so clients can prompt before running it.
Quantities always carry a unit
A product sold in packs has more than one unit, and "order 10" is ambiguous
between 10 boxes and 10 pieces. Every tool that moves stock or money takes a
unit field alongside quantity:
{ "productId": 42, "unit": "Box", "quantity": 10, "unitCost": 90 }If the product has several units and none is named, the call is rejected
rather than falling back to the base unit — the error lists the real units and
their conversion rates so the assistant can retry. unitId: null selects the
base unit deliberately. Write tools return a unitPlan alongside the result
showing the base-unit maths (10 × Box (×12) = 120), so the figure reported
back to the user is the figure that was written.
Use get_product_units to look up a product's units cheaply — it returns just
the ids, conversion rates and tracking flags rather than the whole product.
Loading fewer tools
Every tool's schema is loaded into the assistant's context before the first
question, so an assistant that only reads reports still pays for the purchasing
and bulk schemas. HORIZON_MCP_TOOLS restricts the server to the groups you
list:
HORIZON_MCP_TOOLS=reports,sales,products npx @posara/horizon-mcpGroups: sales, products, catalog, bulk, inventory, transfers,
purchasing, customers, finance, admin, reports, docs, profile.
Unset (the default) loads all of them. Skills are prompts, not tools, so they
are always available regardless of this setting.
Skills
The server ships 12 Horizon Skills — expert playbooks for running a
business, exposed over MCP as prompts (prompts/list / prompts/get). They
tell an assistant which tools to use in what order and which mistakes are
expensive, so a request like "restock the main depot" follows a procedure
instead of being improvised.
| Skill | What it does |
|---|---|
| stock-replenishment | Reorder point scan → purchase orders per supplier, priced in the right pack size |
| goods-receipt | Receive a delivery with batch lots, expiry dates and IMEI/serial capture |
| stock-count | Physical count → variance report → adjustments |
| expiry-watch | Expiring and dead stock, with markdown/transfer/write-off recommendations |
| branch-transfer | Rebalance stock between warehouses through the full transfer lifecycle |
| catalog-onboarding | Bring a new catalog in: categories, products, pack sizes, opening stock |
| daily-close | End-of-day review and tomorrow's action list |
| debt-collection | Age the receivables and decide what to do about each debtor |
| margin-review | Find products losing money and apply agreed price changes |
| month-end-books | Reconcile, post adjusting journals, produce the tax position |
| business-health | Broad review ending in a ranked list of what to fix first |
| access-review | Who has access to what, and who changed a given record |
Every skill refuses to guess a packaging unit and asks before any call that moves stock or money. They are also browsable in the Horizon dashboard under Apps → Horizon MCP → Skills, where each one can be copied as plain text for assistants that do not support MCP prompts.
Skills are defined in src/skills.ts and versioned with the server that
implements the tools they name. The dashboard copy is generated from that file
by bun run mcp:skills in the Horizon repo; bun run mcp:skills:check fails if
the two have drifted.
Large imports: use the skill, not the bulk tools
bulk_import_products caps at 500 rows, and every row still has to be written
out as tool-call arguments — a 1,000-row spreadsheet costs six figures of tokens
and usually exhausts the context window first. For anything bigger than a
handful of rows, use the horizon-data skill in the Horizon repo
(.claude/skills/horizon-data/). Its scripts/horizon.mjs reads the
.xlsx/.csv locally, maps the columns, POSTs in batches, and returns only
imported / updated / skipped counts — the rows never enter the conversation.
It takes the same HORIZON_API_URL / HORIZON_API_KEY values as this server.
Restocking flow
get_reorder_suggestions scans stock against each product's reorder point and
proposes quantities. Feed the result to create_purchase_order, then
receive_purchase_order when the goods arrive — that last step is what actually
raises stock levels and updates product cost. For stock that never had a PO
(opening balances, a walk-in supplier drop-off), use import_stock instead —
it optionally links a supplier and records a payment against it.
Both receive_purchase_order and import_stock (and adjust_inventory for
inbound/outbound corrections) enforce the product's tracking settings: check
get_product's identifierTrackingMode ("imei" / "serial") and
expiryTracking first. If tracking is on, the matching identifiers /
expiryDate fields are mandatory and the identifier count must equal the
quantity converted to base units (via the line's unit conversion rate) — the
call is rejected otherwise.
Audit trail
Every tool call is posted back to Horizon and stored with its arguments, outcome, and latency. Browse it in Apps → Horizon MCP → Call History. Logging is fire-and-forget: if the endpoint is unreachable, the tool still returns normally.
Privileges
Tokens carry Horizon API scopes. Typical sets:
- Read-only analyst — every
*.readscope; can look at everything, change nothing - Inventory manager — plus
inventory.write,products.write,units.write,transfers.write(inventory.writeis also what editing a device's condition or warranty needs; the device warranty reports needreports.read) - Purchasing — plus
suppliers.write,purchase_orders.write - Operations manager — catalog, stock, transfers, purchasing, customers and promotions
- Finance & bookkeeping —
payments.write,accounting.write,audit.read; no catalog or stock writes
Presets for each are one click away in Apps → Horizon MCP → Tokens. Grant a token only what the skills you actually use require.
A tool called without the required scope fails with a clear 403 naming the
missing scope, rather than silently returning nothing.
Contributing
Building from source — not needed just to use the published package:
bun install
cp .env.example .env # set HORIZON_API_URL
bun run dev # HTTP transport on :3001/mcp
bun run smoke # asserts all tools register (no network calls)Local stdio config, running from source instead of the published package:
{
"mcpServers": {
"posara-horizon": {
"command": "bun",
"args": ["run", "/path/to/packages/horizon-mcp/src/index.ts"],
"env": {
"MCP_TRANSPORT": "stdio",
"HORIZON_API_URL": "https://posara-horizon-t1.dcn01.ctdn.dev",
"HORIZON_API_KEY": "your-mcp-token"
}
}
}
}Docker: docker-compose.yml at the repo root defines the horizon-mcp
service, talking to the app over the compose network
(HORIZON_API_URL=http://posara-horizon-app:3000).
docker compose up -d horizon-mcp