Skip to main content

shack-payment-gateway

An MCP server that gates tool calls behind cryptographic micropayment authorization using Ethereum EIP-191 personal message signing.

Speaks JSON-RPC 2.0 over stdio. STDOUT carries only protocol messages; all diagnostic logs go to STDERR.

What it does

  1. A client that wants to call a paid tool first calls request_authorization, which returns a unique challenge string (timestamp + random nonce).
  2. The client signs that challenge with their Ethereum private key using the EIP-191 personal_sign scheme and obtains a 65-byte signature.
  3. The client calls verify_payment, passing the original challenge and the signature. The server recovers the signer's Ethereum address via ECDSA key recovery and compares it against the configured authorized wallet.
  4. If the addresses match, verified: true is returned. Otherwise verified: false is returned.

In permissive mode (no --authorized-wallet flag), any valid signature is accepted and the recovered address is returned as authorized. This mode is useful for development and testing.

MCP tools

Tool Arguments Description
request_authorization tool_name (string), cost (string) Returns a unique EIP-191 challenge string the client must sign before calling a paid tool. cost must be a parseable decimal number (e.g. "1.5").
verify_payment challenge (string), signature (string) Verifies the EIP-191 signature against the challenge. Returns verified, recovered_address, and authorized_address.

Configuration / CLI flags

Flag Env var Default Description
--authorized-wallet <addr> SHACK_AUTHORIZED_WALLET (none) Ethereum address that verify_payment accepts. Omit to run in permissive mode.

Install

pip install .

Or in a virtual environment:

python -m venv .venv
source .venv/bin/activate
pip install .

Run

# Permissive mode (any valid signature is authorized):
shack-payment-gateway

# With a specific authorized wallet:
shack-payment-gateway --authorized-wallet 0xYourWalletAddress

# Via environment variable:
SHACK_AUTHORIZED_WALLET=0xYourWalletAddress shack-payment-gateway

Tests

# With the bundled virtual environment:
.venv/bin/python -m pytest -q

# Or with a system/global pytest:
pip install pytest
pytest

Usage example

The following shows a complete JSON-RPC 2.0 exchange. Each JSON object is sent as a single newline-terminated line on STDIN; responses arrive on STDOUT.

Step 1 — request a challenge:

{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"request_authorization","arguments":{"tool_name":"my_paid_tool","cost":"1.5"}}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [{
      "type": "text",
      "text": "{\"challenge\":\"Authorize execution of tool: my_paid_tool costing 1.5 Shack-Credits. Timestamp: 1716307200. Nonce: 4f3a2b1c...\",\"tool_name\":\"my_paid_tool\",\"cost\":\"1.5\"}"
    }]
  }
}

Step 2 — sign the challenge with your Ethereum private key (client-side, not handled by this server) and call verify_payment:

{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"verify_payment","arguments":{"challenge":"Authorize execution of tool: my_paid_tool costing 1.5 Shack-Credits. Timestamp: 1716307200. Nonce: 4f3a2b1c...","signature":"0xe9d4cfdd...1b"}}}

Response (permissive mode):

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "content": [{
      "type": "text",
      "text": "{\"verified\":true,\"recovered_address\":\"0x1a642f0e3c3af545e7acbd38b07251b3990914f1\",\"authorized_address\":null}"
    }]
  }
}

License

Apache-2.0

Metadata

Release files for shack-payment-gateway 0.1.0

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

Source distribution (sdist)

Source distribution for shack-payment-gateway 0.1.0
File Size Uploaded Provenance
shack_payment_gateway-0.1.0.tar.gz 16.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for shack-payment-gateway 0.1.0
File Interpreter ABI Platform
shack_payment_gateway-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.5 kB

Release files / shack_payment_gateway-0.1.0.tar.gz

Download URL shack_payment_gateway-0.1.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d98e90792b13664b44ed35d9929a75c14e970b7b919ec3e4c968ec72663c027f
BLAKE2b-256 checksum
How to use checksums
f3970a00e2d3c46643e99d6b339f378fa4cf9c59645fca1d851d28c47f6f5e9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / shack_payment_gateway-0.1.0-py3-none-any.whl

Download URL shack_payment_gateway-0.1.0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ee78ac83e0af2915c0dad3797bb75adb87b1362b5798dcf74b5c42582624dbd
BLAKE2b-256 checksum
How to use checksums
0c04e9396653835d58bbcf02694ec83f5e8425feca5f8b7d02ccaa08b3cbd870
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Security for shack-payment-gateway 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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