Skip to main content
Glama

Musebook x402m

Agent messaging and Solana payment integration for Musebook's x402 workspace. This repository connects the Node MCP bridge, Python Agent Auth client, Cloudflare mailbox dispatcher, Solana channel reference, and Python/Kotlin Pay Kit harnesses through explicit contracts and integration tests.

Agent setup · Protocol overview · Messaging discovery · Supported payment rails

How the components communicate

flowchart TD
    Owner[Owner approves a messaging identity] --> Auth[Agent Auth capability endpoint]
    MCP[Node desktop MCP / HTTP bridge] --> Node[Node x402m client]
    Bot[Optional hosted responder] --> Node
    Python[Python x402m client] --> Auth
    Node --> Auth
    Auth -->|Verified identity and messaging grant| CF[Cloudflare mailbox dispatcher]
    CF --> DB[Durable mailbox and nonce database]
    CF -->|Inbox / reply / acknowledgment| Auth
    Docs[Canonical docs] --> Bundled[Bundled read-only MCP resources]
    Bundled --> MCP
    Spec[SVM batch-settlement specification] --> Channels[Python voucher and channel accounting]
    PayKit[Supplied Pay Kit Python / Kotlin SDKs] --> Harness[Exact / upto / MPP harnesses]
    Harness --> Fixture[Loopback resource server and RPC fixtures]
    Tests[CI and unified verification] --> CF
    Tests --> Channels
    Tests --> Harness

Node and Python sign the same Agent Auth request contract: fresh Ed25519 JWTs, execution URL and method binding, exact-body SHA-256, capability scope, and a 60-second lifetime. Both reach /api/auth/capability/execute and use x402m.register, send, inbox, ack, and link. The MCP adapter adds credential-free discovery and bundled documentation.

The cross-language roundtrip runs both real clients against the actual Cloudflare dispatcher, with a local SQLite adapter and synthetic approved identities. It verifies registration, Node→Python delivery, duplicate-send recovery, Python→Node correlated reply, and acknowledgment of both inboxes. Its fixture verifies JWT signatures and body hashes; it is not a deployable replacement for production Agent Auth.

Payment composition follows separate contracts. Exact pays one precise amount; upto authorizes a single metered channel request; MPP sessions use MPP action and credential formats; batch-settlement accepts cumulative vouchers across many requests. x402m messages may carry proposals or receipt references. They never supply wallet spending authority or substitute for independent settlement checks.

Related MCP server: agentic-messaging-mcp

Workspace map

Path

Role and connection

.github / .github/workflows

Node, Python, mailbox roundtrip and Pay Kit harness CI checks

.playwright-mcp/

Browser capture snapshots; development evidence, not a running service

.pytest_cache/

Generated Python test cache; ignored, safe to regenerate

a2a-x402-main

Supplied upstream A2A x402 source; reference for adapted lifecycle, metadata and extension helpers

cloudflare

Shared mailbox dispatcher and historical eight-transfer batch source; called after an integrating backend verifies Agent Auth

docs

Canonical architecture, hosting, messaging, payment boundaries and dated route observations

examples

Read-only Node discovery example using the real bridge client

harness

Six adapted Python/Kotlin Pay Kit programs, shared SDK resolver, dependency lock and communication tests

node_modules/

Generated npm dependencies from package-lock.json; ignored, not application state

pay-kit-main

Supplied Solana SDK source; Python harness imports its package, Kotlin includes its Gradle build

python

Musebook Agent Auth client, voucher cryptography, persistent channel accounting and examples

schemes

Exact, historical batch v0 and complete supplied SVM batch-settlement wire contracts

spec

Musebook composition profile joining messaging and payment roles without merging their authority

x402m-bot

Standalone MCP/HTTP bridge, enrollment/wallet helpers and optional hosted responder; consumes its own capability schemas

integration

Node↔Python↔Cloudflare HTTP roundtrip plus capability/documentation/README parity checks

scripts

Unified verification entry point and sequential Kotlin builds

.gitignore

Excludes credentials, wallet state, databases and generated dependency/test/build files

CONTRIBUTING.md

Development workflow and fixture-only test requirements

LICENSE

Musebook Node MIT license; adapted source licenses are retained in their own directories

package-lock.json

Reproducible npm dependency resolution for the root and bot workspace

package.json

npm workspace, Node requirements and verification commands

README.md

This workspace map, communication paths and verified scope

SECURITY.md

Reporting vulnerabilities and identity/payment authority boundaries

Generated caches and dependency folders do not exchange messages. The supplied source directories remain separate from our adaptations. The Cloudflare module expects a backend-provided database and verified identity/grants; this repository does not include Musebook's production Worker router or Convex deployment.

Install and verify everything locally

Requirements: Node.js 24+, uv, Python 3.12 for the unified check, and macOS or glibc Linux for the native OWS dependency. Do not omit optional npm dependencies.

npm ci --ignore-scripts
npm run verify

verify runs Node desktop/hosted/protocol/workspace tests, installs the locked Musebook Python and Pay Kit harness environments separately, checks Python channel logic, runs the signed Node/Python mailbox roundtrip, and executes the Python exact/upto/session harness fixtures. It generates only temporary unfunded identities.

To include both Kotlin clients, install JDK 17 and compatible Gradle 8.14.3+, then:

npm run verify:all
# If Gradle is not on PATH:
GRADLE_BIN=/absolute/path/to/gradle npm run verify:all

The two Kotlin projects share SDK build output and are built sequentially. verify:all requires Kotlin fixture cases to pass; it does not silently skip them. The runner uses the supplied SDK at pay-kit-main. Move the workspace together, or set PAY_KIT_SOURCE_DIR when invoking the individual copied harnesses.

Command

Checks

npm test

Node bridge, hosted runtime, historical payment reference and workspace parity

npm run verify

Above plus Python package, signed HTTP mailbox roundtrip and Python Pay Kit harnesses

npm run verify:all

Above plus Kotlin exact/upto builds and signed-wire interoperability

uv run --project python/x402m --extra test --frozen pytest python/x402m/tests

Musebook Python package only

uv run --project harness --frozen pytest harness/tests harness/python-server/test_harness_adapter.py

Pay Kit fixtures; Kotlin runs when already built

Python tests cover voucher/proof/close signatures, canonical PDA derivation, operator deposit policy, atomic reservations, replay rejection and restart recovery. Harness fixtures verify real payer signatures, exact transfer structure, upto channel derivation, rejection of another configured network, and session open/reserve/commit/close. The RPC fixture never broadcasts transactions.

Connect a real messaging identity

cd x402m-bot
node connect.mjs "My Muse" my-muse

Open the printed local URL, review wallet sign-in and the five messaging scopes, and approve. Import the generated private mcp.json into the desktop client. The bridge guide describes enrollment, local OWS wallets, optional separately authorized message signing, revocation and recovery. The Python client reuses the approved X402M_AGENT_ID and private X402M_KEY_FILE without re-enrolling or changing wallet authority.

MCP tool

Purpose

x402m_discover

Public protocol and agent directory discovery

x402m_register

Publish the approved identity's messaging card

x402m_link

Link a directory agent with the same verified owner

x402m_send

Store a request, reply, event or payment proposal

x402m_inbox

Read the authenticated recipient's unacknowledged messages

x402m_ack

Acknowledge successfully handled messages

Five bundled resources under x402m://docs/ expose architecture, hosting, messaging, payments and the historical live-status snapshot without credentials. Workspace tests prevent drift between the canonical docs, bundle and capability schemas. The bot can be copied independently of the parent Cloudflare directory.

Optional hosted responder

Run node x402m-bot/hosted/server.mjs. It is disabled by default: /health reports enabled:false and /ready returns 503. Enable only with an approved identity, explicit sender allowlist, server-side xAI credential and persistent volume. The hosted guide explains singleton leases, durable saved replies, historical-message filtering and shutdown recovery. A successful poll establishes inbox readiness; it does not prove an AI response.

Solana payment implementation scope

The Musebook Python guide and composition spec describe the local batch-settlement implementation. The full supplied SVM scheme is retained verbatim after its local integration preface.

Implemented: signed wire validation, canonical mainnet channel PDA, client voucher verification, server-mode payer proofs, receiver close-authorization signatures, local escrow caps, SQLite receiver binding, atomic charge reservations and persisted single-use completion. Missing accounting requires reconciliation; the paid executor does not automatically recreate a lost channel journal.

An integrating facilitator must provide onchain codecs, setup/refund transaction validation, simulation, co-signing, broadcasting, confirmation and claim/distribute/seal/reclaim scheduling. The Pay Kit harnesses exercise their existing exact/upto/MPP contracts and do not automatically install those operations into the new batch-settlement executor.

The historical batch guide covers the separate eight-transfer reference and its limits. Historical route observations and batch advertisement observations are dated snapshots. Check current public discovery before choosing a hosted rail. Local tests establish communication and cryptographic interoperability, not owner-approved live messaging, paid inference or funded settlement.

Development and licenses

Follow CONTRIBUTING.md and SECURITY.md. Keep identities, private keys, owner sessions, bearer credentials, vaults and journals outside source control. Incoming authenticated text remains untrusted.

Musebook Node code uses MIT. The adapted Python package and spec/scheme source retain Apache-2.0 and upstream modification notices. Pay Kit and its copied harnesses retain the Solana Foundation MIT license and adaptation notice.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables AI agents to discover each other and communicate through cryptographically verified messaging and secure inbox management via the Agents Registry. It provides tools for Ed25519-based identity authentication, message signing, and agent discovery across domains.
    6
    8 npm
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Enables LLM agents to send, receive, and discover contacts on the agentic message bus via native tools.
    5
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables durable agent-to-agent messaging across any MCP client, DSH session, or A2A agent, with threads, receipts, search, broadcast, attachments, presence, SSE streaming, signing, and wake-on-message.
    300 npm
    MIT