Skip to main content

mcp-simplr

Python client library for MCP Simplr — payments, emailing, and auth for MCP services.

Installation

pip install mcp-simplr

Payments

Customers register once on the platform and receive a customer_token. MCP owners accept this token from their users and pass it to charge() — no customer registration code needed on your end.

Token billing — charge per output token

Best for AI tools where cost scales with usage.

from mcp_simplr import MCPPayments, PaymentConfig, PaymentModel

payments = MCPPayments(PaymentConfig(
    api_key="simplr_owner_...",
    payment_model=PaymentModel.TOKEN,
    price_per_token=0.000_5,   # AUD per output token
    currency="aud",
    environment="production",
))

# Charge explicitly
await payments.charge(customer_token, tokens=500)

# Or use the decorator — counts tokens and charges automatically
@payments.track_usage(customer_token="<customer-token>")
async def my_tool(query: str) -> str:
    return await run_model(query)

# Dynamic customer token from request payload
@payments.track_usage(customer_token_key="customer_token")
async def my_tool(query: str, customer_token: str) -> str:
    return await run_model(query)

With token billing, the cost is only known after the model call finishes — so charge() necessarily runs after you've already paid for the LLM call yourself. Use check_ready() first to fail fast on a customer who can't be charged, before spending anything:

if not await payments.check_ready(customer_token):
    return "Payment isn't set up for this customer right now."

result = await run_model(query)
await payments.charge(customer_token, tokens=result.usage.output_tokens)

Fixed billing — charge a set amount per call

Best for tools with a predictable cost per request.

from mcp_simplr import MCPPayments, PaymentConfig, PaymentModel

payments = MCPPayments(PaymentConfig(
    api_key="simplr_owner_...",
    payment_model=PaymentModel.FIXED,
    currency="aud",
    environment="production",
))

await payments.charge(
    customer_token,
    amount_cents=500,           # AUD $5.00
    description="Property report",
)

Recurring billing — subscription plans

Best for services with ongoing access (monthly/yearly).

from mcp_simplr import MCPPayments, PaymentConfig, PaymentModel, PlanConfig, BillingInterval

payments = MCPPayments(PaymentConfig(
    api_key="simplr_owner_...",
    payment_model=PaymentModel.RECURRING,
    currency="aud",
    environment="production",
    plans=[
        PlanConfig(id="basic", name="Basic", amount=999, interval=BillingInterval.MONTH),
        PlanConfig(id="pro",   name="Pro",   amount=2999, interval=BillingInterval.MONTH),
    ],
))

# Subscribe a customer to a plan
await payments.charge(customer_token, plan_id="pro")

# Cancel a subscription
payments.cancel_subscription(customer_token, plan_id="pro")

# List available plans
plans = payments.list_plans()

Charge history

history = await payments.get_charges(customer_token)
history = await payments.get_charges(customer_token, from_date="2026-06-01", to_date="2026-06-30")

Testing

Use MCPPayments.TEST_CUSTOMER_TOKEN in sandbox mode to test the full charge flow without a real customer:

await payments.charge(MCPPayments.TEST_CUSTOMER_TOKEN, tokens=500)

TEST_CUSTOMER_TOKEN only works when environment=Environment.SANDBOX — its payment method exists only in Stripe's sandbox, so check_ready() returns False and charge() raises PaymentFailedError for it under environment=Environment.PRODUCTION, even if the token is passed in some other way (e.g. via oauth.verify()).


Emailing

Send emails to your users from your branded slug@mcp-simplr.au address. Subscribe to the email service on the platform website first — your project API key encodes the service slug automatically.

Customer replies are forwarded to the personal inbox you registered during subscription.

from mcp_simplr import MCPEmail, EmailServiceConfig

email = MCPEmail(EmailServiceConfig(
    api_key="simplr_owner_...",   # project key — encodes your service slug
))

await email.send(
    to="customer@example.com",
    subject="Your property report is ready",
    body="Hi Sarah, your report for 123 Main St is attached.",
)

Auth

Gate your MCP tools so only registered customers can call them. Customers authorise via OAuth — they log in with their email and approve your tool, no tokens for them to copy around. Subscribe to the Auth service on the platform website first.

Setup

from mcp_simplr import AuthConfig, Environment
from mcp_simplr.oauth import MCPOAuth

oauth = MCPOAuth(
    auth_config=AuthConfig(
        api_key="simplr_owner_...",        # project key — encodes your service slug
        environment=Environment.PRODUCTION, # ← set once you're live, see Testing below
    ),
    oauth_client_id="...",                 # from POST /oauth/register — omit for MCP-discovery only
    frontend_url="https://yourapp.com",    # required together with oauth_client_id
)
app.include_router(oauth.router)
# Serves /.well-known/oauth-authorization-server (always), plus /auth/login,
# /auth/callback, /auth/refresh when oauth_client_id + frontend_url are set.

The OAuth login flow itself is one flow, no sandbox/production switch for real customers. AuthConfig(environment=...) still matters — see Testing below — and defaults to Environment.SANDBOX if you don't set it.

Auth-only (decorator)

@oauth.require(bearer_token_key="bearer_token")
async def search_properties(query: str, bearer_token: str) -> str:
    return await do_search(query)

Raises AuthenticationError if the bearer token is missing, invalid, or expired.

Auth + charge in the same tool

Pass result_key to inject the full verify result — including simplr_token — into your handler:

from mcp_simplr import AuthConfig, Environment, MCPPayments, PaymentConfig, PaymentModel, Currency
from mcp_simplr.oauth import MCPOAuth

oauth    = MCPOAuth(auth_config=AuthConfig(api_key="simplr_owner_...", environment=Environment.PRODUCTION))
payments = MCPPayments(PaymentConfig(
    api_key="simplr_owner_...",
    payment_model=PaymentModel.TOKEN,
    currency=Currency.AUD,
    environment=Environment.PRODUCTION,
    price_per_token=0.0005,
))

@oauth.require(bearer_token_key="bearer_token", result_key="customer")
async def search_properties(query: str, bearer_token: str, customer: dict = None) -> str:
    result = await run_model(query)
    await payments.charge(customer["simplr_token"], tokens=result.usage.output_tokens)
    return result

Calling verify() directly

Prefer manual control over the decorator? oauth.verify() is the same call, just awaited directly:

customer = await oauth.verify(bearer_token)
# {
#   "customer_id":  "uuid",          # ← stable UUID — safe to use as a DB key
#   "email":        "...",
#   "name":         "...",
#   "simplr_token": "simplr_...",   # ← use this to charge the customer
# }

Testing

To test your own integration, log in on the consent screen as test@simplr.dev with any 6-digit code — that account skips the real OTP check too, so testing never depends on retrieving a code from logs or email.

Under AuthConfig(environment=Environment.SANDBOX) (the default), oauth.verify() always lets that identity through, regardless of your project's Auth service subscription status, and returns customer["simplr_token"] == MCPPayments.TEST_CUSTOMER_TOKEN, a working test card safe to call charge() against:

customer = await oauth.verify(test_bearer_token)
await payments.charge(customer["simplr_token"], tokens=500)  # never touches a real card

Under AuthConfig(environment=Environment.PRODUCTION), test@simplr.dev is rejected outright — oauth.verify() raises AuthenticationError for it, regardless of whether your project's Auth service subscription is active. This is a hard block, not a fallthrough to the normal subscription check: an owner using only the Auth service, with no MCPPayments.charge() call to independently catch it, would otherwise treat this identity as a permanently valid free customer forever. Set environment=Environment.PRODUCTION on both AuthConfig and PaymentConfig once you're live — they're independent settings, and only setting one leaves the other still treating test@simplr.dev as trusted.

Any customer other than test@simplr.dev always needs a real OTP and your project needs an active Auth service subscription, in both environments.


Support

Contact us at contact@mcp-simplr.au

Metadata

Release files for mcp-simplr 0.12.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-simplr 0.12.1
File Size Uploaded Provenance Actions
mcp_simplr-0.12.1.tar.gz 22.2 kB Without provenance Details for mcp_simplr-0.12.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-simplr 0.12.1
File Interpreter ABI Platform Actions
mcp_simplr-0.12.1-py3-none-any.whl Python 3 none any Details for mcp_simplr-0.12.1-py3-none-any.whl

Total release size: 46.9 kB

Release files / mcp_simplr-0.12.1.tar.gz

Download URL mcp_simplr-0.12.1.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9452ef7d53be7d66eea571d6d757c0516cc6054fb758ac94a0f23e2ebbcfc861
BLAKE2b-256 checksum
How to use checksums
7b39383935a6cfe6fad38b58626b0d2a355a514728ceec69cd6c65deafbbb9c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / mcp_simplr-0.12.1-py3-none-any.whl

Download URL mcp_simplr-0.12.1-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8748d55d8f90eaec385af6192f066e70de755b176faa87cc99bf42d6de3f8f8e
BLAKE2b-256 checksum
How to use checksums
c13220b761fca8d0136d9611eb2ca62b22457b84f7e72fa9316e7c16dcebcc5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for mcp-simplr 0.12.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page