Documentation
¶
Overview ¶
Package deskmcp is the in-repo fake MCP server the demo recording runs against: a support desk with the two dozen tools a refund flow touches.
It exists because ENG-14 requires the shipped demo recordings to come out of shipped code paths — the real MCP proxy, the real spool, the real CAS, the real log — rather than from hand-authored bytes. That needs something on the far side of the proxy to be a real MCP server, and it must not be a network service: recordings run in CI, offline, and must produce the same bytes every time.
Determinism ¶
Every response is a pure function of the request. No clock, no randomness, no accumulated state between calls: ask the same tool the same arguments and you get the same bytes, in the same key order, forever. The one input that is *not* the request is Variant, and that is deliberate — it is the entire demo.
The variant, and why it lives here ¶
The two demo runs differ in the world, not in the agent. The agent's script is byte-identical across both runs; what differs is that `orders.search` returns the same two refundable orders in a different order, and the agent — like every agent — takes `results[0]`. One run refunds $12.00, the other $1200.00, from identical instructions.
That asymmetry belongs to the server because that is where it belongs in reality: a search index reordered between two Tuesdays. Putting it in the agent would make the demo a lie about what went wrong.
Amounts are integer cents ¶
The search results carry `amount_cents`, never a decimal string. The cover-up demo greps the customer's CAS for the literal `1200.00` and edits it, and that literal must appear in exactly one blob of the whole store — the refund request the agent composed — or the demo would be editing several records while claiming to edit one. The agent formats cents into the decimal string the refund API wants; the refund response converts straight back to cents.
That rule survives the propagation of the selected order through the rest of the script (ENG-30): every later step that mentions money mentions `amount_cents`, and the one decimal string in the whole session is the argument of step 31.
Ids derived from the order ¶
A desk's records hang off the order: the shipment that carried it, the card that paid for it, the SKU it contained, the approval raised against it, the refund issued for it. Those ids are derived here, in one place, so the recorder's script and this server agree on them without either one spelling them out twice — and so a run that selected the wrong order addresses the wrong shipment, the wrong card and the wrong approval, which is what a wrong selection actually looks like.
Index ¶
- Constants
- func ApprovalFor(order string) string
- func FormatAmount(cents int) string
- func PaymentMethodFor(order string) string
- func RefundIDFor(order string) string
- func SKUFor(order string) string
- func Serve(v Variant, in io.Reader, out io.Writer) error
- func ShipmentFor(order string) string
- type Order
- type Variant
Constants ¶
const ( Customer = "c_8831" Ticket = "tk_4437" SmallOrder = "ord_5512" // 1200 cents — the refund that should happen LargeOrder = "ord_5518" // 120000 cents — the refund that should not SmallCents = 1200 LargeCents = 120000 ServerName = "desk-tools" ServerVersion = "0.1.0" )
Customer, ticket and order ids the demo script addresses. They are exported because the recorder's script and this server must agree, and a shared constant is cheaper to keep in step than two string literals.
const EnvVariant = "BEHALF_DESK_VARIANT"
EnvVariant is how the recorder tells a spawned server which world it is.
const ProtocolVersion = "2026-07-28"
ProtocolVersion is the MCP revision this server speaks — the one the proxy is written against, stateless over stdio (D4, Q44).
Variables ¶
This section is empty.
Functions ¶
func ApprovalFor ¶
ApprovalFor is the manager approval raised against the order.
func FormatAmount ¶
FormatAmount is the inverse: cents to the decimal string the refund API wants. It lives here so the agent and the server agree on the format, and so the demo's target literal has exactly one definition.
func PaymentMethodFor ¶
PaymentMethodFor is the card the order was paid with.
func RefundIDFor ¶
RefundIDFor is the refund the desk mints for the order. The server returns it and the agent carries it forward, so both must agree on its shape.
func Serve ¶
Serve reads newline-delimited JSON-RPC from in and writes responses to out until in reaches EOF. Notifications get no reply, matching MCP.
func ShipmentFor ¶
ShipmentFor is the shipment that carried the order.
Types ¶
type Order ¶
Order is one row of an orders.search result.
func Refundable ¶
Refundable returns the two refundable orders in the order this variant's search index reports them. This one function is the whole difference between the two recorded runs.