Skip to content

Tools

Generated tools

Each documented API operation becomes a tool named after its operationId: getClients, storeClient, showInvoice, updateQuote, deleteExpense, getARSummaryReport, and so on. Only login and logout are excluded — they manage session tokens, and an MCP client already authenticates via the header (logout would invalidate its own credential).

Invoice Ninja's published spec is inaccurate in places, so it is treated as a hint: request bodies require nothing up front and responses aren't validated. Invoice Ninja's own validation errors come back instead. See ADR 0002.

apiRequest

The escape hatch for fields or endpoints a generated tool can't express. Undeclared arguments are silently dropped by generated tools, so use this when a field is missing from the spec.

Argument Description
method HTTP method (GET, POST, PUT, DELETE, …).
path Must start with /api/v1/ (e.g. /api/v1/quotes/{id}).
query Optional query-string object.
body Optional JSON object or array.

It returns {"status", "body"}; a 4xx with Invoice Ninja's validation message is returned, not raised, so the call can be corrected. Binary responses such as /api/v1/quotes/{id}/download PDFs come back as an embedded file. It is limited to /api/v1/ on the configured instance with the caller's own token — no more access than the generated tools.

uploadClient

The spec documents POST /clients/{id}/upload with binary multipart parts, which JSON-in/JSON-out tools can't express — and its method is wrong (Invoice Ninja registers it as PUT, and PHP only parses multipart on POST). The replacement tool takes base64 content and sends a POST with a _method: "PUT" field.

Argument Description
id Client id.
filename Name to store the file under; the type is inferred from the extension.
content_base64 Base64-encoded file contents.

attachDocumentFromUrl

The server downloads a file and attaches it to any entity with a /{id}/upload route, so the bytes never pass through the model. Meant for clients that can't reach the upload route below, such as a claude.ai connector: pass a Paperless-ngx share link and the expense id. Only registered when MCP_FETCH_ALLOWED_HOSTS is set.

Argument Description
entity Collection name: expenses, invoices, vendors, …
id Entity id.
url https URL on an allowed host. Redirects are not followed.
filename Optional; defaults to the download's Content-Disposition name or the URL's last segment.

Files over 25 MB are refused. Returns {"status", "filename", "size", "body"} with Invoice Ninja's response.

File upload route: POST /upload/{entity}/{id}

A plain HTTP endpoint (not an MCP tool) for attaching files to any entity that has a /{id}/upload route in the spec: expenses, invoices, quotes, payments, vendors, … Base64 inside a tool call is impractical for a receipt photo or PDF, so send the bytes directly. It needs the same Authorization header as the MCP endpoint, is served next to it (same host and port), and forwards the files to Invoice Ninja the way uploadClient does.

curl -X POST "http://localhost:8081/upload/expenses/EXPENSE_ID" \
  -H "Authorization: YOUR_INVOICENINJA_API_TOKEN" \
  -F "documents=@receipt.pdf"

Several documents parts attach several files. It returns Invoice Ninja's response; an unknown entity answers 404, no file 400, a missing header 401.