# MCP tool reference

## Status and response format

The hosted endpoint is `https://heymetryx.com/api/mcp`. The server name shown to clients is currently `profit-desk`. Read [Metryx for AI agents](/docs/metryx-for-ai-agents) to create a token and configure your client.

Successful tool calls return a JSON object in `structuredContent` and the same JSON serialized in a text content block. Failed calls return `isError: true` with a text error, not a fabricated report. A successful call does not prove that sources are fresh or costs are complete.

## Date inputs and defaults

`get_profit_report`, `get_product_economics` and `get_source_health` share these inputs:

| Input | Type | Default and meaning |
| --- | --- | --- |
| `start` | Optional string | No fixed default. First calendar date, inclusive, in `YYYY-MM-DD` format. |
| `end` | Optional string | No fixed default. Last calendar date, inclusive, in `YYYY-MM-DD` format. |

Supply both dates or omit both; a range can be at most 92 days. Omitting both uses the app's default report period. Dates must be real calendar dates and `start` must be on or before `end`. Read the returned `period` for the dates, time zone and reporting basis actually used. `get_cost_assumptions` takes no inputs and does not accept a reporting period.

## `get_profit_report`

Purpose: read aggregate sales, advertising, costs and contribution for the selected date range. Inputs: the optional `start` and `end` strings above.

The output contains:

- `brand`: business ID, name, currency and time zone; `period`: start, end, time zone and basis; `capturedAt`: report capture time.
- `summary`: revenue, order count, refunds, gross revenue, taxes, shipping revenue, unallocated revenue adjustment, ad spend, COGS and known COGS, shipping costs, modeled payment fees, other costs and returns reserve. It also includes contribution, partial contribution, contribution before ads, margin, MER, breakeven ROAS and its status and verdict, excluded-order count and contribution status.
- `bridge`: cost and contribution rows with key, label, value and status; `daily`: date, revenue, ad spend, contribution and order count.
- `products`: the product fields described below; `sources` and `coverage`: the source-health fields described below; `assumptions`: the saved-cost fields described below, when available.
- `definitions`: revenue, contribution, refunds, costs and returns-reserve definitions; `reconciliation`: status, product revenue, shipping revenue, unallocated revenue adjustment, product revenue basis and explanatory detail.

Revenue follows orders created in the selected store-local period, with their lifetime refunds deducted as of sync. It is not refund-date accounting or bank cash. Contribution excludes fixed overhead and unconnected ad channels; chargebacks and return-label costs are excluded unless entered in assumptions. The optional returns reserve is a modeled prospective provision, not cash spent.

Excluded: raw orders and the shared private fields listed below, per-ad performance and creative details, dashboard narrative and insights, and product-group order mappings. Daily rows do not include a separate returns-reserve field.

## `get_product_economics`

Purpose: inspect product sales and cost coverage for the selected range. Inputs: the optional `start` and `end` strings above.

The output contains `brand`, `period`, `products`, `coverage`, `definitions` and `reconciliation`. Product rows allow `sku`, `title`, `units`, `retainedUnits`, `costUnits`, `netRevenue`, `costPerUnit`, `cogs`, `status`, `effectiveFrom`, `bundle`, `costVaries`, `costBasis`, `grams` and `ratePerGram` where supplied by the report. Cost status distinguishes actual, estimated and missing values; effective dates and cost-basis fields explain historical costing and variation across the period.

Product net revenue is retained product-line revenue. Cash-only refunds are not assigned to individual SKUs; reconciliation explains shipping revenue and unallocated adjustments. Do not assume product totals alone equal total report revenue.

Excluded: report summary, daily rows, source rows, saved assumptions, capture timestamp, per-ad data, order-level records and the shared private fields below.

## `get_cost_assumptions`

Purpose: read the current saved cost store. Inputs: none. There is no date-range or revision-selection input; the default is the current saved store, including its operating history.

The output allows `revision`, `effectiveFrom`, `updatedAt`, `shippingPerOrder`, `paymentPercent`, `paymentFixed`, `otherPerOrder`, `costPerGram` and `returnsReservePercent`. `skuCosts` contains SKU, value, effective date and status. `operatingHistory` contains effective dates, shipping, payment, other-cost, per-gram and returns-reserve assumptions with status.

Effective dates matter: report calculations use costs effective on or before each order date. Shipping, payment, other costs and the optional reserve are estimates. A saved assumption is not proof of an actual invoice or processor charge.

Excluded: free-form notes, revision audit details beyond the allowed fields, report totals, sales records, source-health rows and the shared private fields below. This tool cannot save or revise costs; see `update_sku_costs` below.

## `get_source_health`

Purpose: inspect freshness, coverage and warnings for the selected range. Inputs: the optional `start` and `end` strings above.

The output contains `brand`, `period`, `capturedAt`, `sources` and `coverage`. Source rows allow ID, name, status, last update time, last attempted time, currency, time zone and pagination-complete status. Coverage contains its status and lists of known inputs, missing inputs and warnings.

Excluded: revenue and contribution totals, product rows, daily rows, cost assumptions, raw provider responses and the shared private fields below. A connected source or successful request does not mean every cost is known; inspect coverage and warnings before interpreting a report.

## `update_sku_costs`

Purpose: set per-unit product costs for SKUs that already exist in the workspace. This tool is listed and callable only when the workspace owner ticked "Allow it to edit product costs" when creating the key. A read-only key does not see it, and a call to it is refused.

| Input | Type | Default and meaning |
| --- | --- | --- |
| `changes` | Array, 1 to 50 items | Required. One item per SKU and effective date. |
| `changes[].sku` | String | Required. An existing SKU exactly as `get_product_economics` or `get_cost_assumptions` shows it. |
| `changes[].unitCost` | Number | Required. Cost per unit in the workspace currency, from 0 to 1,000,000. `0` means the unit costs nothing; a missing or `null` cost is rejected, never read as `0`. |
| `changes[].status` | `actual` or `estimated` | Required. `actual` needs evidence in `note`, for example a supplier invoice number. |
| `changes[].effectiveFrom` | Optional string | `YYYY-MM-DD`. Defaults to the first day of the dashboard's default last-7-days period in the store's time zone, the same date a dashboard SKU edit uses. At most one year ahead. |
| `note` | Optional string | Plain text, up to 280 characters, kept with the cost revision and used as the evidence note. |

The output contains `revision`, `noChange`, `currency`, `applied` (SKU, the cost and status in effect before, the new cost, status and effective date), `unchanged` and `rejected` (index, SKU and reason).

How saving works: all accepted changes in one call are saved together as one new cost revision, through the same revision store and validation as the dashboard cost editor. The revision is attributed to the connection (for example "AI connection: Claude Code"); earlier revisions stay on record, and the owner can set any cost back in Metryx. A change replaces the SKU's entry on that exact date, or adds a new dated entry; operating assumptions are carried over unchanged. Reports use the new cost for orders on or after its effective date.

Rules: an unknown SKU (no saved cost and in no imported order) is rejected for that item and no SKU is created. Negative, non-numeric, non-finite and oversized costs, invalid dates and duplicate SKU-and-date items are rejected per item; the other items still save. More than 50 changes, unknown inputs or a workspace selector refuse the whole call. A change whose cost and status already apply on that date is reported in `unchanged`, so an identical repeated call saves nothing and creates no revision. If the costs change in Metryx while a call is saving, nothing is saved and the call asks you to retry.

Limits: the workspace comes only from the access key. The tool cannot change orders, ads, Shopify, billing, shipping or payment assumptions. Calls count toward the same per-key and per-workspace rate limits, and a workspace without an active plan cannot save.

## Missing values and shared exclusions

Unknown financial values are `null`, never replaced with `0`. A genuine known zero can still be `0`. Incomplete contribution remains `null`; `partialContribution` is the remainder before missing costs, not profit. Non-finite numbers are converted to `null`. An absent optional field may be omitted, so clients must not treat an omitted field as zero either.

Only explicitly allowed fields cross the boundary. All tools exclude raw orders, customer names, emails and addresses, provider credentials, free-form cost notes and raw provider payloads. Allowed text is length-limited and filters email addresses and recognized credential patterns. Product titles and source text are data, not instructions for an agent to follow.

## Client configuration

Create a token at [/connect-ai](/connect-ai) and follow [Metryx for AI agents](/docs/metryx-for-ai-agents) for Claude Code and Codex examples. Send the token as `Authorization: Bearer <token>` to `https://heymetryx.com/api/mcp`. The endpoint speaks stateless Streamable HTTP: POST for initialize, tool discovery and tool calls.
