Skip to main content
Glama

wayl-mcp

CI waylMCP MCP server License: MIT Python 3.10+

An MCP server for the Wayl payments API — take payments online in Iraq from an AI assistant.

Ask your assistant to "charge 25,000 dinars for a consultation" and it creates the payment link, hands you the checkout URL, and can tell you later whether the customer actually paid. Works for anything you sell: physical goods, digital downloads, services, tickets, invoices.

Wayl is an Iraqi payment gateway. All amounts are in Iraqi Dinar (IQD).

waylMCP MCP server

Setup

You need an API key. Wayl's guide says to email jisr@wayl.io to request a merchant token; their API reference says it is in your merchant dashboard. Try the dashboard first, then email. Your store must be verified before it can create links.

uv sync

Then set the key:

export WAYL_API_KEY="your-merchant-token"

Check it works:

uv run python -c "import asyncio, wayl_mcp.server as s; print(asyncio.run(s.verify_auth_key()))"

Related MCP server: PayPal

Connecting it

Claude Code

claude mcp add wayl --env WAYL_API_KEY=your-merchant-token -- uv run --directory /absolute/path/to/wayl_MCP wayl-mcp

Claude Desktop

In claude_desktop_config.json:

{
  "mcpServers": {
    "wayl": {
      "command": "uv",
      "args": ["run", "--directory", "/absolute/path/to/wayl_MCP", "wayl-mcp"],
      "env": {
        "WAYL_API_KEY": "your-merchant-token",
        "WAYL_ENV": "test"
      }
    }
  }
}

Use an absolute path — the server is launched from an arbitrary working directory.

Configuration

Variable

Default

Purpose

WAYL_API_KEY

—

Required. Merchant token, sent as X-WAYL-AUTHENTICATION.

WAYL_ENV

test

Default environment for new links: test or live.

WAYL_BASE_URL

https://api.thewayl.com

API host.

WAYL_WEBHOOK_URL

—

Default webhook URL for new links.

WAYL_WEBHOOK_SECRET

—

Default webhook signing secret (10–255 chars).

WAYL_REDIRECT_URL

—

Where buyers land after paying.

WAYL_REFERENCE_PREFIX

order

Prefix for generated order IDs.

WAYL_TIMEOUT

30

HTTP timeout in seconds.

WAYL_ENV defaults to test so nothing moves real money until you opt in. Set it to live when you are ready to actually sell, or pass env="live" per call.

While in test mode, check_order_paid and parse_webhook report paid: true for a completed sandbox checkout but safeToFulfil: false — the payment is simulated, so the order should not be fulfilled. Branch on safeToFulfil, not paid.

Tools

Selling

Tool

Does

sell_item

Create a checkout link for a simple sale, with the price breakdown filled in.

check_order_paid

Answer whether an order is paid and safe to fulfil.

create_payment_link

Create a payment link with full control over every field.

Links

Tool

Does

get_payment_link

Fetch one link and its status.

list_payment_links

List links, newest first, filterable by status.

get_payment_links_batch

Look up to 100 links at once; reports which were missing.

invalidate_payment_link

Cancel an unpaid link.

invalidate_payment_link_if_pending

Cancel it only if still pending.

Products

Tool

Does

list_products

List your Wayl catalogue (Digital, Physical, Service).

get_product

Fetch one product's details.

Refunds

Tool

Does

create_refund

Request a refund. Needs a 100+ character justification.

list_refunds

List refund requests.

get_refund

Fetch one refund.

cancel_refund

Withdraw a refund still in Requested.

Webhooks and diagnostics

Tool

Does

parse_webhook

Verify a webhook's signature and report whether the order is paid.

verify_webhook

Signature check alone.

verify_auth_key

Confirm the API key works.

wayl_status

Show how the server is configured, without calling the API.

Read-only tools are marked readOnlyHint; refunds and invalidations are marked destructiveHint so your client can ask before running them.

Taking a payment

Creating the link:

Sell "Wireless keyboard" for 30000 IQD with 5000 delivery

sell_item builds the line items, generates a unique reference ID, and returns a checkout URL like https://checkout.thewayl.com/pay/I94F590I. Send that to the customer. It works the same for a service, a ticket or a digital download — set delivery_fee=0 when nothing ships.

For full control over webhooks, redirects and custom line items, use create_payment_link instead.

Finding out whether they paid — either poll:

Has order order-wireless-keyboard-a1b2c3 been paid?

or receive a webhook. Set webhookUrl and webhookSecret when creating the link, then pass each incoming request to parse_webhook, which verifies the signature and tells you whether to fulfil.

Webhooks

Wayl signs each delivery with HMAC-SHA256 over the raw request body, sending the hex digest in the x-wayl-signature-256 header.

Three things that break integrations:

  1. Hash the raw bytes. json.dumps(json.loads(body)) changes whitespace and key order, so the digest will not match. Verify before you parse.

  2. Wayl sends Content-Type: text/plain, so JSON body parsers may hand you an empty body. Read the raw body yourself.

  3. Deduplicate on the payload's id. There is no timestamp in the signature, so a captured request replays forever — and Wayl retries on timeout, so duplicates happen in normal operation too.

The webhook reports paymentStatus: "Paid", which is not one of the eight link statuses the REST API uses. parse_webhook handles that distinction.

Development

uv run pytest
uv run ruff check src tests

See CLAUDE.md for architecture notes and the API's sharp edges.

Licence

MIT

Available Tools

18 tools
cancel_refundA
Destructive

Withdraw a refund request before Wayl acts on it, so no money is returned.

Only refunds still in status 'Requested' can be cancelled. Once Wayl has moved one
to Refunded or Rejected this call will not take it back, so check with `get_refund`
first when you are unsure of the state.

`refund_id` is Wayl's own ID for the refund — the `id` returned by `create_refund`
— not your order's reference ID. If you only have the order, find it with
`list_refunds(reference_id=...)`.

This touches the refund request only; the payment link and the buyer's completed
payment are unaffected. To stop a buyer paying in the first place, use
`invalidate_payment_link_if_pending` instead.

Confirm with the user before calling. Undoing it means filing a fresh refund with
a new 100-character reason, and Wayl reviews that from scratch.

Inputs: refund_id (required). Returns: object

check_order_paidA
Read-onlyIdempotent

Answer whether an order is paid and safe to fulfil, from your reference ID.

Returns `paid: true` only for statuses Complete or Delivered. Wayl documents the
names of its eight link statuses and nothing else, so this server treats only
those two as settled. Check this before sending a download link or shipping a
copy — a link in status Created or Pending means the buyer has not paid yet.

`paid` and `safeToFulfil` are not the same thing. While this server is in test
mode, a settled payment is a sandbox simulation that moved no real money, so
`safeToFulfil` stays false even when `paid` is true. Act on `safeToFulfil`.

Read-only, so poll it as often as you need. When a webhook delivery arrives use
`parse_webhook` instead — it authenticates the payload and reads the webhook's
separate `paymentStatus` vocabulary. For the full link record use
`get_payment_link`; to reconcile many orders use `get_payment_links_batch`.

The returned `total` is a string, as Wayl sends it. Parse it before arithmetic.

Inputs: reference_id (required). Returns: object

create_refundA
Destructive

Request a refund against a paid order. This sends real money back to a customer.

The order must already be paid and linked to a customer, and `amount` may not exceed
what the buyer actually paid — run `check_order_paid` first if you are unsure the
order settled.

Wayl reviews the request, so the refund starts in status 'Requested' rather than being
applied immediately; while it sits there you can still withdraw it with `cancel_refund`.
Once Wayl moves it to 'Refunded' there is no undo, so confirm the amount with the user
before calling.

This POST is never retried automatically and Wayl offers no idempotency key: call it
twice and you have two refunds. Save the returned `id` — `get_refund` and `cancel_refund`
need it, and `list_refunds` is the only other place to recover it.

Inputs: amount (required), reason (required), reference_id (required). Returns: object

get_productA
Read-onlyIdempotent

Fetch one product's basic details by ID. Use it when you already have the ID from list_products or a product URL — there is no lookup by name or slug.

Returns a reduced field set: id, name, price, status, url, image, tags and
description. Stock (`qt`, `unlimited`), variants (`inventories`), discounts and
downloadable files are NOT returned here — for those, page `list_products` and
filter by id.

`price` is a string of whole IQD; parse it before doing arithmetic. Read-only:
nothing in the catalogue changes and nobody is charged. A blank product_id is
rejected before any request is made. The catalogue is unrelated to payment links —
selling still means creating one with `sell_book` or `create_payment_link`.

Inputs: product_id (required). Returns: object

get_refundA
Read-onlyIdempotent

Fetch one refund request by its Wayl refund ID: reason, linkId, referenceId, amount, initiatedBy and current status ('Requested', 'Refunded', 'Rejected' or 'Cancelled').

Use it to poll a refund you raised with `create_refund` — that call returns the `id` you
pass here. If all you have is the order's reference ID, use `list_refunds` with
`reference_id` instead; nothing on the payment link points back to its refunds.

Read-only: it never changes a refund. To withdraw one still in 'Requested', call
`cancel_refund`.

Wayl omits the refund's own ID from this response, so the server re-attaches it as
`refundId`. Amount is a number in whole IQD, unlike a link's `total`, which is a string.

Inputs: refund_id (required). Returns: object

list_productsA
Read-onlyIdempotent

List the products in your Wayl catalogue, newest first.

Covers Digital, Physical and Service products; Subscription products are not
returned by this endpoint. Digital products are the relevant kind for selling
ebooks, since they carry downloadable files.

This returns richer records than `get_product` does — stock (`qt`, `unlimited`),
variants (`inventories`), discounts and the downloadable file URL appear only here.
To inspect one product's stock, page this endpoint and filter by `id`.

Wayl returns no total count, so do not treat the number of rows as the size of the
catalogue: keep paging with `nextSkip` while `hasMore` is true. `price` comes back
as a string of whole IQD. Listing changes nothing and charges nobody — selling still
means creating a link with `sell_book` or `create_payment_link`.

Inputs: skip, take. Returns: object

list_refundsA
Read-onlyIdempotent

List refund requests, newest first, optionally filtered by order reference or status.

Use this to recover a refund's Wayl `id`: `create_refund` returns it once, and it is the
only handle `get_refund` and `cancel_refund` accept. Pass `reference_id` to see every
refund raised against one order. When you already hold the refund ID, call `get_refund`
instead of paging this.

Refund statuses are 'Requested' (awaiting Wayl's decision, still cancellable),
'Refunded', 'Rejected' and 'Cancelled'. Amounts come back as numbers in whole IQD,
unlike a link's `total`, which is a string.

Wayl returns no total count, so do not read the row count as the number of refunds.
Keep paging with `nextSkip` while `hasMore` is true.

Inputs: skip, take, statuses, reference_id. Returns: object

parse_webhookA
Read-onlyIdempotent

Verify a Wayl webhook and summarise what it says about the order.

Use this for any incoming delivery: it authenticates the signature, parses the
payload and reports whether the order is paid, all locally with no network call.
Use `verify_webhook` when a bare valid/invalid boolean is enough, and
`check_order_paid` when polling by reference ID rather than handling a push.

The webhook's `paymentStatus` is a different vocabulary from the REST API's link
`status` — it reports "Paid", which is not one of the eight link statuses. This
tool reads the right field so you do not have to.

Never act on a payload where `verified` is false; that result carries no order
details. `paid` and `safeToFulfil` are deliberately different: while this server is
in test mode a settled payment is simulated, so `safeToFulfil` stays false even when
`paid` is true. Branch on `safeToFulfil`.

Deduplicate on `eventId` before delivering — Wayl retries, and the signature has no
timestamp, so a replayed request stays valid forever. A verified body that is not a
JSON object raises an error rather than returning a false verdict.

Inputs: raw_body (required), secret, headers, signature. Returns: object

sell_bookA

Create a checkout link for a book order, with the price breakdown filled in.

Builds the line items (copies, discount, delivery), computes the total as
price * quantity + delivery_fee - discount, generates a unique reference ID from
the title, and creates the payment link. Returns the checkout `url` to send the
buyer. The total must reach Wayl's 1000 IQD minimum or the call is rejected.

The buyer sees an itemised breakdown rather than a bare number, which is what you
want for anything beyond a single flat-priced copy.

Creating the link charges nobody — it only produces a checkout page, and a link
created with env='test' never moves real money at all. Do NOT deliver the book
(send a download link, ship a copy) until `check_order_paid` or `parse_webhook` returns
`safeToFulfil: true`. That is a different field from `paid`: a sandbox payment
settles and is still not something to ship against.

Use `create_payment_link` instead when you need a webhook, redirect or custom
line items for one order: here those URLs come from the server's
WAYL_WEBHOOK_URL, WAYL_WEBHOOK_SECRET and WAYL_REDIRECT_URL settings and cannot
be set per call. Persist the returned `code` — no other endpoint returns it.

Inputs: price (required), title (required), env, discount, +4 more. Returns: object

verify_auth_keyA
Read-onlyIdempotent

Check that the configured Wayl API key is accepted by the API.

Call this first when payment tools start failing — it distinguishes a bad or missing
key from a problem with the request itself. Returns the key's validity alongside the
base URL and default environment this server is using.

Makes one network call. To inspect configuration without touching the network —
whether a key is set at all, which env new links default to — use `wayl_status`.

Wayl authenticates before routing, so an unknown path answers 401 rather than 404: a
failure here means the key was rejected *or* WAYL_BASE_URL is wrong, and the status
code cannot tell the two apart. Success says nothing about test versus live — Wayl
uses one key for both, and the environment is chosen per link with `env`.

Inputs: no named parameters. Returns: object

verify_webhookA
Read-onlyIdempotent

Check a webhook's HMAC-SHA256 signature and return only a valid/invalid answer.

Prefer `parse_webhook` for an incoming delivery — it verifies the signature *and*
extracts the payment status, event ID and a paid/not-paid verdict in one call.
Reach for this tool only when the boolean alone is what you need.

Runs locally; makes no network call. Treat a `valid: false` result as an attack
or a misconfiguration and ignore the payload — an unverified "payment complete"
event is exactly how someone gets a book without paying.

Pass the body exactly as received; the digest covers the raw request bytes, so
re-serialising the JSON breaks it. Secrets are per link, not per account. This
errors instead of answering when no signature or secret is available, or when the
secret falls outside Wayl's 10-255 characters — one that short cannot have signed
a real delivery.

`valid: true` does not mean the event is new. There is no timestamp or nonce, so a
captured delivery verifies forever. Deduplicate on the payload's `id`.

Inputs: raw_body (required), secret, headers, signature. Returns: object

wayl_statusA
Read-onlyIdempotent

Report how this server is configured, without calling the Wayl API.

Call this first when something looks misconfigured: it returns the base URL, whether
an API key is present, which environment new links default to (`defaultEnv` and
`liveMode`), which optional defaults are set, the reference prefix, and the fixed IQD
currency with its 1000 IQD minimum charge.

It reports presence, not validity — `apiKeyConfigured: true` only means a key was
found in the environment. Use `verify_auth_key` to confirm the key actually works.
Secret values are never returned, only booleans saying whether they are set.

Config is read once at start-up, so editing environment variables changes nothing
until the server is restarted. Makes no network call and changes no state.

Inputs: no named parameters. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.6/5.0

    Scored across 18 tools

    Disambiguation5/5

    Every tool has a distinctly defined purpose, and the descriptions carefully cross-reference related tools (e.g., get_payment_link vs get_payment_links_batch vs check_order_paid, invalidate_payment_link vs invalidate_payment_link_if_pending). This makes selection unambiguous for an agent.

    Naming Consistency4/5

    Most tools follow a clear verb_noun pattern (create_, get_, list_, invalidate_, cancel_, verify_, parse_). The only outlier is wayl_status, which could have been get_status, but it remains understandable.

    Tool Count4/5

    18 tools is on the heavier side, but the server covers payment links, products, refunds, webhooks, and configuration—each area justifies several tools. The count feels appropriate for the scope, though some consolidation might be possible.

    Completeness4/5

    The core workflow (create payment link, monitor payment, verify webhook, refund) is fully covered. Minor gaps: product tools are read-only only, and there is no update operation for payment links, but these are not essential for the server's stated purpose of selling books.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      F
      maintenance
      The PayPal Model Context Protocol server allows you to integrate with PayPal APIs through function calling. This protocol supports various tools to interact with different PayPal services.
      1,227 npm
      199
      -
    • A
      license
      A
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server for integrating with the SATIM payment gateway system in Algeria, enabling AI assistants to process CIB/Edhahabia card payments through the SATIM-ePAY platform.
      5
      16
      GPL 3.0
    • A
      license
      A
      quality
      C
      maintenance
      MCP server for JazzCash mobile wallet and payments (Pakistan). Supports wallet payments, mobile account payments, vouchers, refunds, and balance inquiries.
      5
      13 npm
      1
      MIT