ohneben's Wafeq MCP
ohneben's Wafeq MCP
License & Checks
MCP Registries
Run your Wafeq books in plain language from AI assistants like Claude, Cursor, and any other MCP client.
This Model Context Protocol server exposes the Wafeq Public API β all 251 endpoints, generated straight from the OpenAPI spec into MCP tools, plus two hand-written ones. Every tool carries a safety category (π’ read-only / π‘ write / π state change / π΄ irreversible or destructive) so your assistant knows what an action does before it calls it β including the difference between saving an invoice and filing it with a tax authority, which no CRUD-shaped wrapper can tell you. It runs over stdio (Claude Desktop and other local launchers) or Streamable HTTP (hosted in Docker), and ships with retries, client-side rate limiting, request timeouts, idempotency keys, multipart upload and binary PDF handling so it holds up against a live book.
Why you'll want this
Some MCP servers just forward an API. This one is built to be safe to hand to an LLM and easy to run against real accounting data:
What you get | Why it matters |
All 251 endpoints, spec-driven | Full coverage of invoices, bills, quotes, credit and debit notes, payments, banking, journals, payroll, projects, inventory and reports β nothing hand-picked or left behind. |
Nine safety categories, not four π’ / π‘ / π / π΄ | A dozen of Wafeq's POSTs are not creates. Previews write nothing; ending an amortization early posts to the ledger with no undo; reporting an invoice to a tax authority leaves your organization permanently. Each gets its own banner instead of being lumped in with "create". |
Server instructions sent on connect | The client is told how to read the safety banners and the handful of Wafeq conventions β date format, decimal separator, whole-period report ranges β up front, instead of discovering them by getting a call wrong first. |
Machine-readable MCP annotations ( | Hosts that honor annotations (Claude included) can auto-trust the 98 read-only tools and demand confirmation before any of the 44 that delete or cannot be undone. |
Correct report parameters, per report | Each of the four reports gets its own schema: balance sheet takes |
Whole-period validation before sending | Profit-and-loss and cash flow reject ranges that don't align to whole months or years. The server checks locally and replies with the nearest valid range instead of spending a round trip on an HTTP 400. |
Automatic idempotency keys | Every one of the 146 write endpoints that supports |
File uploads that actually work |
|
Binary PDFs handled as bytes | The nine PDF endpoints are base64-encoded into a small envelope with size and content type, instead of being read as text and corrupted. |
Automatic retries with backoff | Transient |
Built-in rate limiting | Self-throttles so a burst of tool calls doesn't trip a |
Tenant verified at startup | A Wafeq API key is organization-scoped. The server calls |
Two transports: stdio and Streamable HTTP | Use it locally in Claude Desktop, or run one always-on server that any number of MCP clients reach over HTTP. |
Docker + docker-compose, health check, auto-restart |
|
Optional bearer-token auth on the HTTP endpoint | Put the server behind a shared secret the moment it's reachable beyond localhost. |
Your secrets never reach the model | Credentials live in the server's environment and are injected on every request. The passthrough tool cannot override |
Drop-in spec updates | Wafeq ships a newer spec? Replace one file and rebuild β new endpoints become new tools automatically, no code changes. |
How it compares
Capability | This project | Generic OpenAPIβMCP wrapper* |
All 251 Wafeq endpoints as tools | β | β |
Per-tool safety category + banner | β | β |
Tax-authority filing flagged as irreversible, not "create" | β | β |
| β | β |
Read-only fields stripped from create/update bodies | β | β |
Duplicated enum prose compacted out of schemas | β | β |
Correct, per-report date parameters | β | β |
Whole-period range validated before sending | β | β |
Automatic | β | β |
Multipart + raw-binary file upload | β | β |
Binary PDF responses base64-encoded, not mangled | β | β |
Transaction dates recovered for journal line items | β | β |
Automatic retries on | β | β |
Client-side rate limiting | β | β |
Organization identity verified at startup | β | β |
| β | β |
Streamable-HTTP transport | β | β |
Docker + docker-compose, health check, auto-restart | β | β |
Optional bearer-token auth on the endpoint | β | β |
License | MIT | varies |
*Generic OpenAPIβMCP wrappers turn any spec into MCP tools. They can reach the same endpoints, but treat every operation identically β and against Wafeq's spec specifically they inherit the read-only-required-field problem described in MIGRATION.md. "β" = varies by tool / not guaranteed.
What you can do
Once it's connected, ask your assistant things like:
"What was our profit and loss for the first half of this year?"
"Show me every unpaid invoice older than 30 days, with the customer name."
"Create a draft invoice for Acme Ltd for 3 days of consulting at β¬800/day."
"Download invoice INV-2026-014 as a PDF."
"Which account did the β¬7,000 transfer in January post to?"
"Attach this receipt to expense EXP-118."
"Reconcile the bank statement lines for March against the ledger."
"Convert quote QUO-31 to an invoice and record the payment."
How it works
Claude / Cursor / any MCP client ββMCPβββΊ this server ββHTTPSβββΊ Wafeq API (your organization)At startup the server parses the bundled OpenAPI spec into MCP tools β resolving
$refs, guarding against recursive schemas, and stripping server-assigned
(readOnly) fields out of request bodies β tags each tool with its safety category,
verifies which Wafeq organization the credentials belong to, and then injects your
credential on every outgoing request. Your key stays in the server's environment; the
model never sees or handles it.
Requirements
A Wafeq organization with API access β either a private API key (Wafeq β Settings β Developer β API keys) or an OAuth2 access token. See Get your API credentials.
Docker (Docker Desktop on macOS/Windows) for the quick start below β or Node.js β₯ 20 to run from source.
Quick start (Docker)
1. Add your credentials. Copy the example config and fill it in:
cp .env.example .envThen edit .env and set WAFEQ_API_KEY. If the server will be reachable beyond
localhost, set MCP_SHARED_TOKEN to a long random string as well.
2. Start the server:
docker compose up -d --builddocker-compose.yml binds to 127.0.0.1:8765 only, so the server is reachable from
your machine but not from the network.
3. Confirm it's running β and that it's pointed at the right books:
curl -s http://localhost:8765/health{
"status": "ok",
"server": "wafeq-mcp",
"version": "2.0.0",
"tools": 253,
"organization": {
"status": "ok",
"id": "org_...",
"name": "Your Company FZCO",
"base_currency": "EUR",
"country": "AE"
},
"auth_required": false
}Check the name field. That is the organization your key writes to. If it isn't
the company you expected, stop and fix the key before doing anything else. /health
answers 503 and "status": "degraded" when the credentials can't be verified.
4. Point your MCP client at it: http://localhost:8765/mcp (Streamable HTTP).
Remote endpoints are added to Claude as a custom connector (Settings β
Connectors), or bridged locally with
mcp-remote. For the bridge, add this
under mcpServers in your client config and restart the app completely:
{
"mcpServers": {
"wafeq": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:8765/mcp",
"--header", "Authorization: Bearer YOUR_MCP_SHARED_TOKEN"
]
}
}
}(Drop the --header line if you left MCP_SHARED_TOKEN empty.)
Prefer a ready-made image?
Every release publishes a ready-to-run image to the GitHub Container Registry, so you can skip the local build entirely:
docker run -d --name wafeq-mcp -p 127.0.0.1:8765:8765 --env-file .env \
ghcr.io/ohneben/wafeq-mcp:latestPin a version (:2.0.0) rather than latest if you want releases to be something
you opt into.
Install from the MCP Registry
The server is published to the MCP Registry
as io.github.ohneben/wafeq-mcp, so registry-aware clients can install it by name.
The registry entry launches the image over stdio β see
Run the container over stdio for the equivalent
hand-written config.
curl -s "https://registry.modelcontextprotocol.io/v0.1/servers/io.github.ohneben%2Fwafeq-mcp/versions/latest"Get your API credentials
Private API key (most people): in Wafeq, go to Settings β Developer β API
keys and create a key. It is scoped to one organization. Put it in .env as
WAFEQ_API_KEY; the server sends it as Authorization: Api-Key <key>.
OAuth2 app: if you have an access token from a Wafeq OAuth2 app, put it in
.env as WAFEQ_ACCESS_TOKEN instead. The server switches to
Authorization: Bearer <token> automatically. Set WAFEQ_AUTH_SCHEME only if you
need to force one scheme while both variables are present.
Configuration
All configuration is environment variables. Everything except the credential has a working default.
Variable | Default | What it does |
| β | Private organization API key. Sent as |
| β | OAuth2 access token. Sent as |
| auto | Force |
|
| Wafeq API base URL. |
| bundled spec | Use a different OpenAPI document (JSON or YAML). |
|
|
|
|
| HTTP listen port. |
|
| HTTP bind address. |
|
| Path the MCP endpoint is served on. |
| β | Bearer token required on |
| β | Comma-separated resource groups to expose, e.g. |
|
| Client-side rate limit: requests per window. |
|
| Rate-limit window in milliseconds. |
|
| Retries on |
|
| Per-attempt request timeout. |
|
| Allow upload tools to read this machine's filesystem via |
|
| Maximum decoded upload size (25 MiB). |
Too many tools?
251 tools is a lot. The full catalogue is about 0.5 MB of JSON (~133k tokens) on
tools/list, and some hosts get slower or less accurate with that many. Two things
help.
The schemas are already compacted. Wafeq's spec renders every enum's values into
its description as well as into enum β the currency list alone is ~4 KB, inlined
at 203 places. The generator collapses those single-member allOf wrappers and drops
the duplicated bullet lists, which takes ~29% off the payload without removing a
single allowed value.
Narrow the catalogue if you still want it smaller β no code changes needed:
WAFEQ_TOOL_GROUPS=invoices,bills,contacts,payments,reports,accounts,items,tax-ratesThe two hand-written tools are always available, so nothing becomes unreachable β
anything you filter out can still be called through wafeq_request.
Tool safety categories
Every tool's description opens with a banner, and every tool carries the matching MCP annotations. Counts are for the bundled spec (251 generated + 2 hand-written = 253).
Banner | Tools |
|
| What it covers |
π’ | 85 | β | β | Every |
π’ | 9 | β | β | The PDF downloads: invoice, simplified invoice, credit note, debit note, bill, quote, purchase order, payment, payslip. Returned base64-encoded. |
π’ | 4 | β | β | Amortization and revenue-recognition previews. |
π‘ | 39 | β | β | Collection creates, both file uploads, and the two conversions (quoteβinvoice, purchase orderβbill). Not idempotent by nature β hence the automatic idempotency key. |
π‘ | 70 | β | β | Every |
π | 2 | β | β | Mark expense posted / draft. Reversible β each undoes the other. |
π΄ | 3 | β | β | Report invoice / credit note / simplified invoice to the tax authority. Leaves your organization and cannot be recalled. |
π΄ | 2 | β | β | End amortization / revenue recognition early. No API undo β run the matching preview first. |
π΄ | 39 | β | β | Every |
253 | 98 | 44 |
The three π΄ groups all set destructiveHint: true, so a host that honors annotations
stops and asks before any of them β not just before deletions. Filing an invoice with
a tax authority is at least as consequential as deleting one, and unlike a deletion
it reaches outside your organization.
Print the live catalogue any time, without credentials:
npm run list-toolsTool | Endpoint |
| hand-written |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tool | Endpoint |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tool | Endpoint |
|
|
|
|
|
|
|
|
Tool | Endpoint |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tool | Endpoint |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tool | Endpoint |
|
|
|
|
Tool | Endpoint |
|
|
|
|
|
|
Tool | Endpoint |
|
|
|
|
Tool | Endpoint |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| hand-written |
|
|
|
|
|
|
|
|
|
|
Coverage
Area | Tools | π’ Read | π‘ Write | π΄ Irreversible | π΄ Delete |
Sales & receivables | 69 | 25 | 31 | 3 | 10 |
Purchasing & payables | 54 | 19 | 27 | 0 | 8 |
Banking | 18 | 6 | 9 | 0 | 3 |
Ledger & reporting | 31 | 19 | 6 | 2 | 4 |
Payroll | 19 | 7 | 9 | 0 | 3 |
Master data & dimensions | 54 | 18 | 27 | 0 | 9 |
Files & organization | 6 | 3 | 2 | 0 | 1 |
Escape hatch & convenience | 2 | 1 | 0 | 0 | 1 |
Total | 253 | 98 | 111 | 5 | 39 |
"Write" includes the two π state-change tools. Areas map to Wafeq resources as follows β Sales: invoices, simplified invoices, quotes, credit notes, payments, payment requests Β· Purchasing: bills, purchase orders, debit notes, expenses, beneficiaries Β· Banking: bank accounts with their ledger and statement transactions Β· Ledger & reporting: accounts, manual journals, journal line items, the four reports, tax rates, amortizations, revenue recognitions Β· Payroll: payslips, employees Β· Master data: contacts, items, units of measure, warehouses, projects, cost centers, branches, custom fields.
Two hand-written tools
Everything above is generated. Two tools are written by hand:
wafeq_account_ledger(π’) β journal line items with their real transaction date. Wafeq's/journal-line-items/rows carrycreated_ts(when the row reached Wafeq), which is regularly a different month from the transaction, and no date field at all. This tool recovers the date using the endpoint's owndate_after/date_beforefilters, which do operate on the transaction date. It probes a month at a time and only splits into day queries where rows exist, so quiet periods cost one request each; the result reportsrequests_made.wafeq_request(π΄) β the escape hatch: any method, any path, plus query, body and headers. It is the fallback for anything the bundled spec misses, not the primary interface. Categorized destructive because its effect can't be known in advance.
Run from source (stdio, no Docker)
npm ci
npm run buildThen register it with your MCP client. For Claude Desktop, add to
claude_desktop_config.json:
{
"mcpServers": {
"wafeq": {
"command": "node",
"args": ["/absolute/path/to/Wafeq MCP/dist/index.js"],
"env": {
"MCP_TRANSPORT": "stdio",
"WAFEQ_API_KEY": "your-key-here"
}
}
}
}For Claude Code:
claude mcp add wafeq --env WAFEQ_API_KEY=your-key-here -- node /absolute/path/to/dist/index.jsRun the container over stdio
You can also let your client launch the published image directly, with no HTTP server and no local build:
{
"mcpServers": {
"wafeq": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT=stdio",
"-e", "WAFEQ_API_KEY",
"ghcr.io/ohneben/wafeq-mcp:latest"
],
"env": {
"WAFEQ_API_KEY": "your-key-here"
}
}
}
}MCP_TRANSPORT=stdio is required here: the image defaults to the HTTP transport.
Useful scripts:
Command | What it does |
| Compile TypeScript to |
| Run the Vitest suite. |
| Print the categorized catalogue. Needs no credentials. |
| Run over stdio. |
| Run the Streamable HTTP server. |
Keeping the spec current
Tools are generated from spec/wafeq-public-api.json at startup β there is no code
generation step and no hand-written tool list. Drop in a newer OpenAPI document
(JSON or YAML), rebuild, and new endpoints become new tools. See
spec/README.md for where the bundled copy came from and what to
re-check after an update.
Observed-behaviour corrections live in src/overrides.ts, keyed by operationId and
dated, so an entry whose operation disappears simply stops applying.
Notes & conventions
Dates are
YYYY-MM-DD. Amounts use a dot as the decimal separator.Paging: list tools take
limitandoffset, and report the total count.Reports take report-specific date parameters β balance sheet
date+period_count; profit-and-loss and cash flowdate_after+date_before; trial balancefrom_date+to_date. Wafeq silently ignores a misspelled query parameter, so a wrong name looks like a working call; the per-report schemas exist to make that impossible.Whole periods: profit-and-loss and cash-flow ranges must cover whole months or years. The server checks locally and replies with the nearest valid range rather than spending a round trip on an HTTP 400.
File uploads (
wafeq_files_*): pass base64 content plus a filename.POST /files/is multipart-only andPOST /files/raw/needs aContent-Dispositionheader β both are handled for you.PDF downloads come back base64-encoded in a small envelope carrying the size and content type, not as mangled text.
Idempotency: every write endpoint that supports
X-Wafeq-Idempotency-Keygets a UUID v4 automatically, reused across retries. Pass your own to make a deliberate re-run safe.Retries: transient
429/5xxresponses are retried with jittered exponential backoff, honoringRetry-After, under the same idempotency key.Rate limiting: Wafeq publishes no numeric limit, so the client-side default (
WAFEQ_MAX_REQUESTS=20perWAFEQ_RATE_WINDOW_MS=10000) is deliberately conservative. Raise it if you know your allowance.One organization per credential. A Wafeq API key is organization-scoped; every tool call acts on that organization, and
/healthnames it.
CI & releases
Every push and pull request is built and tested on Node 20 and 22, and the tool
catalogue is generated with no credentials present β which is what catches a
duplicate or schema-illegal tool name before it ships. CI also fails if .env ever
becomes tracked.
A release is a vX.Y.Z tag and nothing else. No version number is maintained by
hand. Pushing the tag runs the whole chain:
The version is derived once, from the tag.
The image is built and pushed to
ghcr.io/ohneben/wafeq-mcpβ tagged with the version,MAJOR.MINOR, the short SHA, andlatestonmain.The entry is published to the MCP Registry with
server.jsonpinned to that exact image tag. Ownership is proved by theio.modelcontextprotocol.server.namelabel on the image, which must matchserver.json'snameβ a test enforces that it does.The released number is written back into
package.jsonandserver.jsononmain, and the tag is moved onto that commit. So the repository always states the last published version, and the server reports it over MCP and on/healthwithout a code edit.
npm version 2.0.1 --no-git-tag-version # optional; CI stamps it either way
git tag v2.0.1 && git push origin v2.0.1workflow_dispatch re-publishes a given version without cutting a new tag. Pushes to
main build a -dev.g<sha> image and stop there β they never touch the registry.
Security
Credentials stay server-side. They are read from the environment and injected per request. The model sees tool inputs and API responses, never the key. The passthrough tool cannot override the
Authorizationheader, and refuses to send the credential to any host other than the configured API base.Never commit
.env. It is git-ignored, and CI fails if it ever becomes tracked..env.exampleholds placeholders only.Bind to localhost, or set a token.
docker-compose.ymlpublishes on127.0.0.1only. If you expose the port any further, setMCP_SHARED_TOKENfirst; it is compared in constant time.Local file uploads are off by default.
WAFEQ_ALLOW_LOCAL_FILE_UPLOAD=falsemeans the server will not read files from its own filesystem. Turning it on lets anything that can call the server ask it to read a local path β leave it off unless you need it and trust every client. Base64 uploads work either way.Check the organization on
/healthbefore the first write. An API key is scoped to one organization, and a wrong key fails by writing to the wrong company rather than by erroring.The π΄ tools mean it. Deletions are permanent, ending a schedule early has no API undo, and a tax-authority filing cannot be recalled. Keep host confirmations on for anything carrying
destructiveHint.
See SECURITY.md to report a vulnerability.
Credits & license
MIT β see LICENSE.md. Built on the Model Context Protocol TypeScript SDK, following the same architecture as ohneben's LearnWorlds MCP. Not affiliated with or endorsed by Wafeq.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ohneben/Wafeq-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server