MCP gateway tools
The tools the MCP gateway offers, what each takes and answers, and how each refuses. Every tool is read-only, and nothing a tool answers is ever spend, a rate, a contract value or an invoice; the only budget it answers is the monthly AI budget. For how a request reaches a tool, see the overview; for full protocol detail, see the gateway README.
Every row that names an engagement, an organisation or an invoice carries urls, its links into the Luna web app of that environment: engagement (/engagements/<engagementId>), organisation (/organisations/details/<organisationId>) and invoice (/engagements/invoicing/<invoiceId>/preview), each present only when the row carries that id. Each tool's description tells the agent to always give the link with whatever it names, not only when asked.
People tools
whoami, list_my_engagements and get_engagement are for people only and take the caller's identity from the delegated identity token, never from an argument. They are not registered in production for now; see the gateway README.
| Tool | Arguments | Answer |
|---|---|---|
whoami | none | andiId, firstName, lastName, knownAs, businessUnit, roles: the identity Luna acts as for this request. No domain service is called. |
list_my_engagements | none | allocations: one row per allocation of the caller's from today through 92 days ahead, internal projects included and archived or deleted allocations left out, each with engagementId, name, organisationId, organisationName, isInternal, claudeEnabled, endDate, urls (engagement, and organisation when it has one), then the allocation's own start, end and roleTitle (the role's type, then its seniority when it has one; null when the role has no type) |
get_engagement | engagementId (string, required) | engagementId, name, description, organisationId, organisationName, deliveryBusinessUnit, agreement, isInternal, claudeEnabled, startDate, endDate, urls (engagement, and organisation when it has one), the caller's own allocations (myAllocations: start, end, roleTitle) and support roles (mySupportRoles) |
claudeEnabledis Luna's Claude eligibility: the engagement uses the AND Claude instance and is not archived.agreementis the engagement's commercial agreement, such asTime & MaterialsorFixed Price(nullwhen Luna holds none); never its amounts or threshold.- Dates are ISO dates (
2026-10-01); Luna's half-day markers (#AM,#PM) are dropped. get_engagementanswers only an engagement the caller holds a support role on, or has an allocation on within 92 days either side of today, so every engagementlist_my_engagementsanswers can be fetched. An archived or deleted allocation does not count.
Both engagement tools read from the engagements querier.
Billing tools
list_engagements_for_billing, list_invoices_for_billing, get_invoice_readiness, get_invoicing_calendar, get_billable_amounts_time_and_materials, get_engagement_billable_amounts and find_organisations are for people and agents; list_engagement_budgets is for agents only. An agent sees and calls each only when its record in the agent registry grants it, within that grant's data scope; see Agent access and grants.
A person calls them within the business units they may read: their own and any additional business units on their delegated identity, or every business unit when they hold the CommercialAdmin role. That is their scope wherever this page says the grant's businessUnits. Every person is listed every one of these tools but list_engagement_budgets and, unless one of their roles has a read Actuals row (whatever its fields or conditions), the billable amounts tools, which they are then answered not_permitted; a person with no business unit is answered not_permitted by each of them. The billable amounts tools, get_billable_amounts_time_and_materials and get_engagement_billable_amounts, read the actuals querier's GET /actuals/billable route, which requires the read Actuals permission on the caller's Luna roles. A person needs the CommercialAdmin, BusinessUnitLead or ClientServices role. An agent needs both the tool grant and the HarnessBillingAgent role (one row, read Actuals), held beside HarnessAgent. A caller without the permission is refused by the querier and answered not_permitted.
get_invoicing_calendar names no engagement, business unit or organisation, so any grant of it may call it, scoped or not: the same business-unit grant an agent holds for the billing tools is enough. A person may call it like the other billing tools, when they have a business unit.
| Tool | Arguments | Answer |
|---|---|---|
list_engagements_for_billing | periodStart and periodEnd (strings, optional: YYYY-MM-DD, the first and last day of the period, given together; today alone when omitted); businessUnits (string, optional: comma-separated business units the caller may read, all of them by default); organisationId (string, optional: a Luna organisation id from find_organisations, to list that client's engagements alone, within those business units, including those still to start in a period reaching today or later); afterEngagementId (string, optional: the last engagementId of a truncated answer, for the next page) | which engagements are pre-ready to bill in the period, before invoices are raised: engagements, one row per engagement of those business units that it keeps (below), each with engagementId, name, organisationId, organisationName, deliveryBusinessUnit, agreement, urls (engagement and organisation, each when the row has it), owner (name, role), documents (msa, sow, po) and preReady; and truncated |
list_invoices_for_billing | from and to (strings, required: YYYY-MM-DD, the first and last day of the range); businessUnits (string, optional: comma-separated business units the caller may read, all of them by default); organisationId (string, optional: a Luna organisation id from find_organisations, to list that client's invoices alone); offset (string, optional: the nextOffset of the previous answer, for the next page) | which invoices being prepared, on Time & Materials or Capped Time & Materials engagements, are ready to bill or finalise, which are not, and why: invoices, each with invoiceId, invoiceNumber, from, to, status, engagementId, engagementName, agreement, organisationId (the Luna organisation id of the invoice's client; null when the invoice records none), organisationName, businessUnit, timeApproval, urls (invoice, and engagement and organisation, each when the invoice names it), documents (msa, sow, po), preReady, readyToBill, readyToFinalise, availableAmount (value, currency), blockers and criteria (as get_invoice_readiness answers them); and nextOffset |
get_invoice_readiness | invoiceId (string), or engagementId (string) with from and to (strings: YYYY-MM-DD, the first and last day of the period) | whether one invoice, by id or by engagement and period, can be billed or finalised: exactly a list_invoices_for_billing row, its criteria each with key, documentType, status, documentIds and documents (each documentId with its reference and level) |
list_engagement_budgets | none | budgets: one row per Claude-enabled engagement the grant's data scope keeps, each with engagementId, budgetUsd (the monthly AI budget in force today), updatedAt (when that budget was set, an ISO 8601 timestamp), period (always month) and enforce (always false: Luna holds no per-budget enforcement switch) and urls with its engagement link. An engagement without a budget is left out. |
get_invoicing_calendar | cycle (string, optional: Normal (3+1), the default, or Monthly), year (string, optional: YYYY, this year by default, when a period of next year's calendar covering today is listed too, so the current period shows across the turn of the year) | the AND invoicing calendar for that billing cycle and year of invoice lock dates: cycle, year, today and updatedAt (when the calendar was written, an ISO 8601 timestamp, null when none is published), and periods, each with periodStart, periodEnd, weeks (given for Normal (3+1) periods, absent for Monthly ones), status (past, current or upcoming) and its deadlines generateInvoices, sendTimeApprovals, timeApprovalsReceived, confirmEngagements and invoiceLockDate |
get_billable_amounts_time_and_materials | periodStart and periodEnd (strings, required: YYYY-MM-DD, at most 92 days counting both); businessUnit (string, optional: one the caller may read, all of them by default); afterEngagementId (string, optional: the afterEngagementId of a truncated answer, for the next page) | the Time & Materials time available to bill in the period, per engagement and per currency, over the engagements of the business units the caller may read on a Time & Materials or Capped Time & Materials agreement and the Normal (3+1) cycle with a role billable in the period: periodStart, periodEnd, totalDays, currencies (each client billing currency's notInvoiced, invoiceRaised and total as days and amount, engagementCount and cappedEngagementCount), missingCurrency (the same total for engagements whose client has no billing currency, in no currency's total), engagements (each engagementId, name, organisationId, organisationName, deliveryBusinessUnit, agreement, urls, currency, currencyDefaulted, notInvoiced, invoiceRaised and total, or error for one that could not be read), truncated and afterEngagementId. Pages of 50 engagements, each totalled on its own. |
get_engagement_billable_amounts | engagementId (string, required), periodStart and periodEnd (as above) | one engagement's Time & Materials time available to bill: engagementId, name, organisationId, organisationName, deliveryBusinessUnit, agreement, urls, periodStart, periodEnd, currency, currencyDefaulted, lines (one per role: roleId, roleType, seniority and dailyRates, each with notInvoiced, invoiceRaised and total), total and provisionalInvoiceIds; another agreement answers error not_time_and_materials with no lines or total |
find_organisations | name (string, required: at least 2 characters once trimmed) | the Luna organisations, clients and prospects, whose name or trading name contains name, ignoring case, owned by the business units the caller may read, by name: organisations (each organisationId, name, tradingName, businessUnit (the club that owns the organisation), status (Active or Inactive) and type (Client or Prospect), the last four null when Luna holds none, and urls with its organisation link) and truncated (true when more than 25 match). An agent uses it to turn a client's name into the organisationId other tools take, and asks which one is meant when more than one matches. Identification only: never billing, bank, contact or company details. |
list_engagements_for_billingidentifies the engagement byengagementIdandname(its title), and its organisation byorganisationIdandorganisationName: bothnullwhen the engagement has no organisation, andorganisationNamealso when its organisation has no name. It also answers its commercialagreement, asget_engagementdoes.list_engagements_for_billinganswers the engagement'sowner: its Client Services Manager, else its Client Services Director, asname(first and last name) androle(that support role).owneris absent when the engagement has neither, or Luna holds no name for them. It never carries an email address. The invoice tools answer no owner.- The invoice tools,
list_invoices_for_billingandget_invoice_readiness, judge an invoice in exactly the same way, only on the documents Luna evidenced on it (itsreadiness), against the invoice's own period. Only documents attached to the engagement count: its own (ENGAGEMENTSlevel), and the client documents applied to it (ORGANISATIONlevel), each counting at either level; a document held only on the organisation never counts. An invoice Luna has not evaluated yet has nodocumentsand nocriteria, is not pre-ready, and is blockednot_evaluated; no document attached to its engagement stands in. Every invoice is judged on the same criteria: anMSA, aSOWand aPO, anMSAorSOWhaving dates overlapping the period, while aPOLuna evidenced on the invoice counts whatever its dates. - Each criterion asks for one document (
MSA,SOWorPO) at either level. Itsstatusismet,missing,not_overlapping_period(no matching document's dates overlap the period: its start is after the period's last day or its end before its first) orperiod_unknown(a matching document's date is not a date, or the invoice has no dates); a document starting or ending mid-period counts, and a missing date leaves that side open, so a document without dates overlaps any period.documentIdslists the matching documents that have a file, anddocumentsevery matching document with itsreference(its PO number or title,nullwhen it has none) and itslevel(ORGANISATIONfor a client document,ENGAGEMENTSfor the engagement's own): a PO evidenced by its number alone has anulldocumentId. - When Luna has checked the invoice against its purchase order's budget, both invoice tools answer a further
po_budgetcriterion:metwhen the invoice is within that budget, elseover_budget, with the PO number as itsreference. It is reported but never decides readiness, and the budget's amounts and currency are never answered. agreementis the invoice's own commercial agreement, recorded on it when it is created (nullwhen the invoice records none).timeApprovalis the invoice's time approval in Luna,Unsent,PendingorApproved(nullwhen Luna records none).preReadyistruewhen any one of the MSA, SOW or PO criteria ismet;readyToBillwhen the invoice is pre-ready and itstimeApprovalisApproved; andreadyToFinalisewhen it is ready to bill and its status isREADY(Luna moves aDRAFTorTIME_APPROVALinvoice toREADYon its issue date).blockersnames what stands between the invoice and finalising it:not_evaluated(Luna has not judged its documents yet) or elseno_document(none of the MSA, SOW or PO is evidenced), thentime_approval_pending(itstimeApprovalis notApproved) andstatus_not_ready(it is notREADY); a ready to finalise invoice has none.availableAmountis the invoice's subtotal before tax, asvaluewith itscurrency, answered on every invoice row whatever its readiness; it is absent only when Luna records no subtotal or currency. It is the one amount the billing tools answer, a deliberate exception to their no-amounts rule, andlist_engagements_for_billinganswers none.list_engagements_for_billingreads the engagements of each business unit itsbusinessUnitsargument names, each of which the grant's scope must name, or else of every business unit the grant's scope names; a grant withoutbusinessUnitsis refused. It keeps only those on aTime & MaterialsorCapped Time & Materialsagreement (Fixed Price and any other agreement are left out, before paging, so pages andtruncatedcount only these), invoiced on theNormal (3+1)cycle with a role billable in the period (the role's own dates overlap it, and on some day of that overlap the rate period spanning the day, or else the role itself, isBillable), neither internal nor archived, and within the scope'sengagementIdsandorganisationIdswhen it names them. AbillableOnlygrant lists the same engagements, as each has a role billable in the period. It reads no invoice.msa,sowandpoareuploadedwhen that criterion (below) ismeton what is attached to the engagement and overlaps the period, elsemissing: its available documents, its own or client documents applied to it (a document held only on the organisation never counts), and its purchase orders. A document overlaps the period when its dates do (a missing date leaves that side open, so an undated document overlaps any period); it need not cover the whole period. A purchase order counts when itsstartandendoverlap the period and it is not markedexpired, and only while it has money left (provisionalAmountRemainingabove zero, or unknown), as Luna's own evidence counts a purchase order no invoice names yet. If the client then names an exhausted purchase order on the invoice, Luna counts it, so the invoice can become pre-ready after the list said the engagement was not.preReadyistruewhen any one ofmsa,sowandpoisuploaded. For whether an engagement's invoice can be billed or finalised, asklist_invoices_for_billingorget_invoice_readiness. A row whose engagement could not be read answers only its identification fields,error: "luna_unavailable"andpreReady: null; ask for that engagement again later. A refusal of the caller's identity still refuses the whole list. It answers at most 50 engagements per call in engagement id order, withtruncatedtruewhen more qualified. To read the next page, call it again with the sameperiodStartandperiodEndandafterEngagementIdset to the lastengagementIdof the truncated answer; it lists the engagements whose id sorts after it, so pages neither skip nor repeat one, and a cursor past the last engagement answers an empty list.list_engagements_for_billing's period runs fromperiodStarttoperiodEnd, both inclusive; without them it is today alone. To list an invoicing period, pass theperiodStartandperiodEndof thecurrentperiod fromget_invoicing_calendar. One without the other, a date that is not a real calendar date, or aperiodEndbeforeperiodStart, is refused as an invalid argument.- The invoice tools answer a document's
referencebut, beyondavailableAmount, no amount (no invoice total, tax or purchase order balance), and never a rate, a file name, a size, an email address or a document's owner id;list_engagements_for_billinganswers no amount at all, and no purchase order number, document title or file name either. list_invoices_for_billinglists the invoices inDRAFT,TIME_APPROVALorREADYwhose period overlapsfromtoto, in the business unitsbusinessUnitsnames, each of which the grant's scope must name, or else in every business unit the grant's scope names; a grant withoutbusinessUnitsis refused. It lists only the invoices ofTime & MaterialsorCapped Time & Materialsengagements: Fixed Price and any other agreement, and an invoice without an engagement, are left out before paging, so they never shorten a page. The invoices of an internal or archived engagement are left out too, as the engagements read leaves those out. It keeps those within the scope'sengagementIdsandorganisationIdswhen it names them. Each row is the invoice's own, with no owner. Each invoice is judged as above, somsa,sowandpoareuploadedwhen that criterion ismeton the invoice, and each row carries itscriteria: a row is exactly whatget_invoice_readinessanswers for that invoice, the full readiness answer. It answers at most 50 invoices per call; whennextOffsetis a number, call again with the same arguments andoffsetset to it. A page can hold fewer than 50 invoices, or none, and still have more after it, as the rows outside the grant or the range are left out of a page; keep calling whilenextOffsetis a number. Invoices come in order of their period start, ties broken by invoice id, the same on every page, so pages neither repeat nor skip an invoice while none changes; one whose status changes while you page (for exampleREADYtoFINAL) can move between pages. An invoice row names no billable flag, so abillableOnlygrant is refused any row.get_invoice_readinessanswers one invoice: the one named byinvoiceId, whatever its period, or else the engagement's newest invoice whose period overlapsfromtoto. Either way it judges only an invoice inDRAFT,TIME_APPROVALorREADY: aFINAL,VOIDorSELF_BILLEDinvoice named by id is refused like one Luna does not have. GiveinvoiceIdalone, orengagementIdwith both dates. It is for one invoice, by id or by engagement and period: it answers exactly the rowlist_invoices_for_billinganswers for that invoice,criteriaincluded. An invoice Luna does not have, or an engagement with no such invoice, isnot_permitted, so the answer never reveals which invoices exist. Its answer names the invoice's engagement, business unit and organisation for the grant's scope and no billable flag, so abillableOnlygrant is refused it.list_engagement_budgetskeeps the engagements within the scope'sengagementIds,businessUnits(the engagement's delivery business unit) andorganisationIdswhen it names them. A budget carries no billable flag, so abillableOnlygrant keeps only the budgets whose engagement has a role billable today, by the same rulelist_engagements_for_billingapplies when given no period. It answers budgets only, never spend, a rate, a contract value or an invoice.get_invoicing_calendarlists only the periods finance has confirmed, in order; a period not listed has no confirmed dates yet, and an emptyperiodsmeans no calendar is published for that cycle and year. A period iscurrentfrom itsperiodStartto itsperiodEndinclusive, so two periods sharing a boundary day are bothcurrenton it.cycletakes an engagement'sbillingCycle;Otherhas no calendar and is refused as an invalid argument, as is ayearthat is not four digits. Dates areYYYY-MM-DDandtodayis UTC. It answers dates only, never an invoice, an amount or an engagement.
list_engagements_for_billing reads each listed engagement, with its purchase orders and attached documents, from the engagements querier, and no invoice. get_invoice_readiness reads invoices only, never an engagement, from the invoices querier. list_invoices_for_billing reads its invoices from the invoices service's search function, which holds the invoice search index, and each business unit's engagements from the engagements querier only to filter the invoices.
The invoices querier answers only an identity that may read invoices: an agent needs an unconditioned read Invoice row on its HarnessAgent role, entered per environment in the Luna admin app, or list_invoices_for_billing and get_invoice_readiness answer not_permitted. The invoice search checks the same permission. A person is answered by their own roles, so a person whose roles may not read invoices is answered not_permitted too.
list_engagement_budgets reads from the ai-scribe querier, which answers only the engagements whose AI budget the delegated identity may read: an agent needs the HarnessBudgetReader role, or the call is not_permitted. For a billableOnly grant it also reads the engagements of each business unit its scope keeps from the engagements querier.
get_invoicing_calendar reads nothing from Luna, which does not hold the invoicing calendar yet: the gateway reads it from its own SSM parameters, one per billing cycle and year (/luna/<env>/mcp-gateway/invoicing-calendar/<normal|monthly>/<year>), written by the luna invoicing-calendar CLI command. Once Luna owns the calendar, only that source changes.
find_organisations reads the organisations service's search (GET /v2/organisations), asking for its index's rows in name order and only their name, trading name, business unit, status and type, so an organisation's billing and bank details are never loaded. The search also matches on industry, so a match on neither name is dropped. It checks no permission, so the gateway keeps only organisations within the grant's organisationIds and businessUnits (an organisation's own business unit). An organisation names no engagement and no billable flag, so grant it without engagementIds or billableOnly, or every call is not_permitted. An organisation's business unit is the club that owns it, which need not be the club delivering its engagements, so a grant left unscoped finds every organisation.
Answer shape
A tool answers its fields as structuredContent, plus a text block holding the same JSON for clients that do not read structured content. Every result, error results included, carries resultType: "complete".
Each tool declares an output allowlist, and the gateway cuts every result down to it. A field Luna adds to an engagement later never reaches and-harness unless the tool's allowlist names it.
tools/list carries each tool's output schema (outputSchema) beside its input schema, and clients may validate structuredContent against it. It admits either the tool's answer, naming exactly its fields with each field's type and whether it may be null, or the error result described under Refusals. Every tool declares one. Error results share one shape whichever tool answers them, so a client validates them the same way for every tool.
Refusals
| Outcome | Answer |
|---|---|
| the tool does not exist, is not listed for the caller's principal kind, or is not granted to the agent | JSON-RPC -32602 Unknown tool: <name> |
the arguments do not match the tool's input schema (including a value outside an argument's allowed values or pattern), a string argument is blank, or list_engagements_for_billing is given only one of periodStart and periodEnd, a date that is not a real calendar date, a periodEnd before periodStart, or a businessUnits naming none, or list_invoices_for_billing is given a from or to that is not a real calendar date, a to before from, or a businessUnits naming none, or get_invoice_readiness is given neither an invoiceId nor an engagementId with both dates, an invoiceId beside them, or the same date errors | JSON-RPC -32602 naming the problem |
the domain service refuses the record, or get_engagement refuses an engagement the caller is not assigned to | isError: true, structuredContent {"error":"not_permitted"} |
get_invoice_readiness is named an invoiceId Luna does not have, or one that is FINAL, VOID or SELF_BILLED, an engagement has no such invoice, or the answer is outside the grant's data scope | isError: true, structuredContent {"error":"not_permitted"} |
list_engagements_for_billing is called under a grant that names no businessUnits, is named a business unit the grant does not, or any row it would answer is outside the grant's data scope | isError: true, structuredContent {"error":"not_permitted"} |
list_invoices_for_billing is called under a grant that names no businessUnits, is named a business unit the grant does not, or any row it would answer is outside the grant's data scope | isError: true, structuredContent {"error":"not_permitted"} |
a person with no business unit calls a billing tool, get_invoicing_calendar included | isError: true, structuredContent {"error":"not_permitted"} |
| an agent holding a list grant calls any other tool | isError: true, structuredContent {"error":"not_permitted"} |
the domain service fails, or get_invoicing_calendar cannot read a valid calendar parameter | isError: true, structuredContent {"error":"luna_unavailable","requestId":"<correlation id>"} |
An engagement that does not exist is refused with not_permitted, the same as one the caller is not assigned to. A tool's error result arrives inside a 200; it is not one of the gateway's HTTP refusals.
A new tool is defined, with its input and output schemas, and registered as the gateway README's code layout describes, and the change that adds a tool also adds its row to this page.
