notch-mcp 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 josecadenax
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,142 @@
1
+ <p align="center">
2
+ <img src="docs/assets/logo/notch-logo-256.png" alt="Notch logo" width="160" height="160">
3
+ </p>
4
+
5
+ [Español](README.md) | English
6
+
7
+ # Notch
8
+
9
+ [![Tests](https://github.com/josecadenax/notch/actions/workflows/test.yml/badge.svg)](https://github.com/josecadenax/notch/actions/workflows/test.yml)
10
+ [![Public API](https://img.shields.io/website?url=https%3A%2F%2Fnotch-production-721b582b.up.railway.app&up_message=online&down_message=offline&label=public%20API)](https://notch-production-721b582b.up.railway.app)
11
+ [![License: ISC](https://img.shields.io/badge/license-ISC-blue)](LICENSE)
12
+ [![Node 22+](https://img.shields.io/badge/node-%3E%3D22-339933?logo=nodedotjs&logoColor=white)](package.json)
13
+ [![Stellar testnet](https://img.shields.io/badge/Stellar-testnet-7D00FF?logo=stellar&logoColor=white)](https://stellar.expert/explorer/testnet)
14
+ [![x402](https://img.shields.io/badge/x402-pay%20per%20use-413A68)](https://www.x402.org)
15
+ [![MCP server](https://img.shields.io/badge/MCP-server-18A8B5)](docs/mcp.md)
16
+
17
+ **Pay-per-use timestamps for AI agents, on Stellar.**
18
+
19
+ An agent hashes what it produced, pays 0.01 USDC with x402, and Notch anchors that hash in a Stellar transaction. From then on, anyone can prove for free that the document existed no later than that date.
20
+
21
+ **Track:** API de pago (x402) · Código 402 · BAF México × Programa de Embajadores de Stellar · Stellar testnet (test money, no real value)
22
+
23
+ ## The problem
24
+
25
+ Agents now write reports, contracts and datasets, and often get paid for them. When someone asks "was this written before the deadline?" or "was it changed afterwards?", the only evidence is the agent's own logs, which the same party controls.
26
+
27
+ An agent also has no account, no credit card and no contract with a timestamp provider. What it can do is pay one cent per call, which is why Notch charges with x402: no sign-up, no API key and no subscription.
28
+
29
+ ## How Notch solves it
30
+
31
+ ```mermaid
32
+ sequenceDiagram
33
+ participant A as Agent
34
+ participant N as Notch API
35
+ participant F as x402 facilitator
36
+ participant S as Stellar
37
+ A->>A: SHA-256 of the file (the file stays local)
38
+ A->>N: POST /stamp { hash }
39
+ N-->>A: 402 Payment Required (0.01 USDC)
40
+ A->>N: POST /stamp + signed payment
41
+ N->>F: verify payment
42
+ N->>S: transaction with the hash as memo
43
+ S-->>N: ledger closed, date fixed
44
+ N->>F: settle payment (only if the stamp succeeded)
45
+ N-->>A: 200 { tx, ledger, stampedAt }
46
+ Note over A,S: Later, anyone: GET /verify, or read the tx on Stellar. Free.
47
+ ```
48
+
49
+ - **Only the hash travels.** The document never leaves the machine.
50
+ - **The date is Stellar's**, the close time of the ledger, not the server's clock.
51
+ - **Verification is free** and does not need Notch: the memo of the transaction can be read on any explorer.
52
+ - **You pay only for stamps that exist.** A failed stamp is never charged.
53
+
54
+ ## Try it now
55
+
56
+ The API is deployed on Stellar testnet: **https://notch-production-721b582b.up.railway.app**
57
+
58
+ ```
59
+ curl https://notch-production-721b582b.up.railway.app/
60
+ curl -i -X POST https://notch-production-721b582b.up.railway.app/stamp -H 'content-type: application/json' \
61
+ -d '{"hash":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}' | head -1
62
+ ```
63
+
64
+ The second call answers `402 Payment Required`: no payment, no stamp. Verifying a real stamp is free:
65
+
66
+ ```
67
+ curl "https://notch-production-721b582b.up.railway.app/verify?hash=20ef27f25fd5ca7a2ae2c8b7447058cb317a0cc576fd4b25750281a909353de9&tx=16e1df0c10c019c7b8f9235f27e8e1282968f2fdb835778668c878b06d27a80d"
68
+ ```
69
+
70
+ It answers `"valid": true` with the ledger date. The [stamp transaction](https://stellar.expert/explorer/testnet/tx/16e1df0c10c019c7b8f9235f27e8e1282968f2fdb835778668c878b06d27a80d) can be opened in Stellar Expert.
71
+
72
+ ## Use it from Claude Desktop (MCP)
73
+
74
+ Notch ships a local MCP server. Claude Desktop starts it on your computer and stamps or verifies files for you, paying against the public API.
75
+
76
+ | Tool | Cost | What it does |
77
+ |---|---|---|
78
+ | `stamp_file` | 0.01 USDC | Hashes locally, pays with x402 and anchors the stamp |
79
+ | `verify_stamp` | free | Checks a file against its stamp, straight on Stellar |
80
+ | `check_balance` | free | Shows your wallet, its balance and how many stamps are left |
81
+
82
+ ```
83
+ npm install
84
+ npm run setup:accounts -- --agent-only # creates your testnet wallet in .env.agent
85
+ ```
86
+
87
+ Then add `notch` to Claude Desktop's config. The steps are in [docs/mcp.md](docs/mcp.md).
88
+
89
+ **The paying wallet is yours.** It is created on your machine, its key never reaches the server, and the client only pays the account it has pinned (`EXPECTED_PAYEE`), so a fake API cannot charge you. Use a dedicated wallet with a small balance.
90
+
91
+ ## Demo video
92
+
93
+ ![Demo video](docs/assets/demo/notch-demo.gif)
94
+
95
+ A 1:23 animation built from the real output of a run on Stellar testnet, with the waits shortened. The hashes shown can be opened in Stellar Expert. [Download the video (mp4)](https://github.com/josecadenax/notch/raw/main/docs/assets/demo/notch-demo-backup.mp4).
96
+
97
+ ## How to run it
98
+
99
+ Needs Node 22 or newer. The code lives in [`partes/josecadenax`](partes/josecadenax/README.md).
100
+
101
+ ```
102
+ npm install
103
+ npm run setup:accounts # testnet accounts, keys saved in .env
104
+ npm start # API on http://localhost:3001
105
+ npm run stamp -- file.pdf # another terminal: hash, pay and stamp
106
+ npm run verify -- file.pdf <tx> # check a file against a stamp
107
+ npm test # 57 tests
108
+ ```
109
+
110
+ To stamp against the public API instead of your local server, create your wallet with `npm run setup:accounts -- --agent-only`, copy its `AGENT_SECRET` into `.env` and run:
111
+
112
+ ```
113
+ API_URL=https://notch-production-721b582b.up.railway.app npm run stamp -- file.pdf
114
+ ```
115
+
116
+ ## Documentation
117
+
118
+ - [Architecture](docs/architecture.md): pieces, API contract, what is on chain, errors and charges.
119
+ - [Demo guide](docs/demo.md): the 5-minute script and the exact commands.
120
+ - [MCP server](docs/mcp.md): how to use Notch from Claude Desktop, the agent wallet and the safety rules.
121
+ - [Deployment](docs/deploy.md): how to publish your own server (Railway), which secrets are needed and where they live.
122
+ - [x402 facilitator](docs/facilitator.md): how to try the OpenZeppelin facilitator on testnet and measure its daily limit.
123
+ - [Mainnet](docs/mainnet.md): what the code already protects, what is missing and the step-by-step plan for real money.
124
+
125
+ ## Test hashes
126
+
127
+ A real run on Stellar testnet:
128
+
129
+ - Payment of 0.01 USDC (x402): [`15ae64c6…43bd`](https://stellar.expert/explorer/testnet/tx/15ae64c6e6a6bca9ae3775ca4971f0d5f7d6d89dfcd6ec9c2ceadd778e2743bd)
130
+ - Stamp, with the file hash in its memo: [`980e4423…1bc0`](https://stellar.expert/explorer/testnet/tx/980e4423e8a7476d899aed94d7d4220f5071ee45bdaa939a0f7c04a76cfc1bc0)
131
+
132
+ A stamp made against the public API (deployed on Railway): [`16e1df0c…a80d`](https://stellar.expert/explorer/testnet/tx/16e1df0c10c019c7b8f9235f27e8e1282968f2fdb835778668c878b06d27a80d)
133
+
134
+ ## Current limits
135
+
136
+ - **Testnet and mainnet.** The public API above runs on testnet (test money). There is also a mainnet API with real money, already tried with real stamps: its addresses and how to use it are in [docs/mainnet.md](docs/mainnet.md). On both, each user uses their own funded wallet, with the spending cap the client already enforces. Enforcing that limit in the account itself (for example with smart accounts) would be a future improvement, not a requirement.
137
+ - **The paying wallet depends on the user.** Notch never creates or holds it: the server only charges and stamps.
138
+ - **A single server instance**, because stamps are signed in a queue using Stellar sequence numbers.
139
+
140
+ ## Team and parts
141
+
142
+ - [josecadenax](https://github.com/josecadenax): [their part](partes/josecadenax/README.md)
package/README.md CHANGED
@@ -1,3 +1,144 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="docs/assets/logo/notch-logo-256.png" alt="Logo de Notch" width="160" height="160">
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ Español | [English](README.en.md)
6
+
7
+ # Notch
8
+
9
+ [![Tests](https://github.com/josecadenax/notch/actions/workflows/test.yml/badge.svg)](https://github.com/josecadenax/notch/actions/workflows/test.yml)
10
+ [![Public API](https://img.shields.io/website?url=https%3A%2F%2Fnotch-production-721b582b.up.railway.app&up_message=online&down_message=offline&label=public%20API)](https://notch-production-721b582b.up.railway.app)
11
+ [![License: ISC](https://img.shields.io/badge/license-ISC-blue)](LICENSE)
12
+ [![Node 22+](https://img.shields.io/badge/node-%3E%3D22-339933?logo=nodedotjs&logoColor=white)](package.json)
13
+ [![Stellar testnet](https://img.shields.io/badge/Stellar-testnet-7D00FF?logo=stellar&logoColor=white)](https://stellar.expert/explorer/testnet)
14
+ [![x402](https://img.shields.io/badge/x402-pay%20per%20use-413A68)](https://www.x402.org)
15
+ [![MCP server](https://img.shields.io/badge/MCP-server-18A8B5)](docs/mcp.md)
16
+
17
+ **Sellos de tiempo de pago por uso para agentes de IA, sobre Stellar.**
18
+
19
+ Un agente calcula el hash de lo que produjo, paga 0.01 USDC con x402, y Notch ancla ese hash en una transacción de Stellar. Desde ese momento, cualquiera puede comprobar gratis que el documento existía a más tardar en esa fecha.
20
+
21
+ **Track:** API de pago (x402) · Código 402 · BAF México × Programa de Embajadores de Stellar · Stellar testnet (dinero de prueba, sin valor real)
22
+
23
+ ## El problema
24
+
25
+ Los agentes ya escriben informes, contratos y conjuntos de datos, y a veces cobran por ellos. Cuando alguien pregunta "¿esto existía antes de la fecha límite?" o "¿se modificó después?", la única evidencia son los registros del propio agente, que controla la misma parte.
26
+
27
+ Un agente además no tiene cuenta, tarjeta ni contrato con un proveedor de sellos de tiempo. Lo que sí puede hacer es pagar un centavo por llamada, y por eso Notch cobra con x402: sin registro, sin llave de API y sin suscripción.
28
+
29
+ ## Cómo lo resuelve Notch
30
+
31
+ ```mermaid
32
+ sequenceDiagram
33
+ participant A as Agente
34
+ participant N as API de Notch
35
+ participant F as Facilitador x402
36
+ participant S as Stellar
37
+ A->>A: SHA-256 del archivo (el archivo no sale de la máquina)
38
+ A->>N: POST /stamp { hash }
39
+ N-->>A: 402 Payment Required (0.01 USDC)
40
+ A->>N: POST /stamp + pago firmado
41
+ N->>F: verifica el pago
42
+ N->>S: transacción con el hash como memo
43
+ S-->>N: ledger cerrado, la fecha queda fija
44
+ N->>F: liquida el pago (solo si el sello se creó)
45
+ N-->>A: 200 { tx, ledger, stampedAt }
46
+ Note over A,S: Después, cualquiera: GET /verify, o leer la tx en Stellar. Gratis.
47
+ ```
48
+
49
+ - **Solo viaja el hash.** El documento nunca sale de la máquina.
50
+ - **La fecha es la de Stellar**, la hora de cierre del ledger, no el reloj del servidor.
51
+ - **Verificar es gratis** y no requiere a Notch: el memo de la transacción se lee en cualquier explorador.
52
+ - **Solo pagas por sellos que existen.** Un sello fallido nunca se cobra.
53
+
54
+ ## Pruébalo ahora
55
+
56
+ La API está desplegada en Stellar testnet: **https://notch-production-721b582b.up.railway.app**
57
+
58
+ ```
59
+ curl https://notch-production-721b582b.up.railway.app/
60
+ curl -i -X POST https://notch-production-721b582b.up.railway.app/stamp -H 'content-type: application/json' \
61
+ -d '{"hash":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}' | head -1
62
+ ```
63
+
64
+ La segunda llamada responde `402 Payment Required`: sin pago no hay sello. Verificar un sello real es gratis:
65
+
66
+ ```
67
+ curl "https://notch-production-721b582b.up.railway.app/verify?hash=20ef27f25fd5ca7a2ae2c8b7447058cb317a0cc576fd4b25750281a909353de9&tx=16e1df0c10c019c7b8f9235f27e8e1282968f2fdb835778668c878b06d27a80d"
68
+ ```
69
+
70
+ Responde `"valid": true` con la fecha del ledger. La [transacción del sello](https://stellar.expert/explorer/testnet/tx/16e1df0c10c019c7b8f9235f27e8e1282968f2fdb835778668c878b06d27a80d) se puede abrir en Stellar Expert.
71
+
72
+ ## Úsalo desde Claude Desktop (MCP)
73
+
74
+ Notch incluye un servidor MCP local. Claude Desktop lo arranca en tu computadora y sella o verifica archivos por ti, pagando contra la API pública.
75
+
76
+ | Herramienta | Costo | Qué hace |
77
+ |---|---|---|
78
+ | `stamp_file` | 0.01 USDC | Calcula el hash local, paga con x402 y ancla el sello |
79
+ | `verify_stamp` | gratis | Comprueba un archivo contra su sello, directo en Stellar |
80
+ | `check_balance` | gratis | Muestra tu cartera, el saldo y cuántos sellos te quedan |
81
+
82
+ ```
83
+ npm install
84
+ npm run setup:accounts -- --agent-only # crea tu cartera de testnet en .env.agent
85
+ ```
86
+
87
+ Después se añade `notch` a la configuración de Claude Desktop. Los pasos están en [docs/mcp.md](docs/mcp.md).
88
+
89
+ **La cartera que paga es tuya.** Se crea en tu máquina, su llave nunca llega al servidor, y el cliente solo paga a la cuenta que tiene fijada (`EXPECTED_PAYEE`), así que una API falsa no puede cobrarte. Usa una cartera dedicada con poco saldo.
90
+
91
+ ## Demo en video
92
+
93
+ ![Demo en video](docs/assets/demo/notch-demo.gif)
94
+
95
+ Animación de 1:23 hecha con la salida real de una ejecución en Stellar testnet, con las esperas acortadas. Los hashes que aparecen se pueden abrir en Stellar Expert. [Descargar el video (mp4)](https://github.com/josecadenax/notch/raw/main/docs/assets/demo/notch-demo-backup.mp4).
96
+
97
+ ## Cómo correrlo
98
+
99
+ Requiere Node 22 o superior. El código vive en [`partes/josecadenax`](partes/josecadenax/README.md).
100
+
101
+ ```
102
+ npm install
103
+ npm run setup:accounts # cuentas de testnet, las llaves se guardan en .env
104
+ npm start # API en http://localhost:3001
105
+ npm run stamp -- archivo.pdf # en otra terminal: calcula el hash, paga y sella
106
+ npm run verify -- archivo.pdf <tx> # comprueba un archivo contra un sello
107
+ npm test # 57 pruebas
108
+ ```
109
+
110
+ Para sellar contra la API pública en lugar de tu servidor local, crea tu cartera con `npm run setup:accounts -- --agent-only`, copia su `AGENT_SECRET` a `.env` y ejecuta:
111
+
112
+ ```
113
+ API_URL=https://notch-production-721b582b.up.railway.app npm run stamp -- archivo.pdf
114
+ ```
115
+
116
+ ## Documentación
117
+
118
+ Los documentos técnicos están en inglés:
119
+
120
+ - [Arquitectura](docs/architecture.md): piezas, contrato de la API, qué queda en la cadena, errores y cobros.
121
+ - [Guía de la demo](docs/demo.md): el guion de 5 minutos y los comandos exactos.
122
+ - [Servidor MCP](docs/mcp.md): cómo usar Notch desde Claude Desktop, la cartera del agente y las reglas de seguridad.
123
+ - [Despliegue](docs/deploy.md): cómo publicar tu propio servidor (Railway), qué secretos hacen falta y dónde viven.
124
+ - [Facilitador x402](docs/facilitator.md): cómo probar el facilitador de OpenZeppelin en testnet y medir su límite diario.
125
+ - [Mainnet](docs/mainnet.md): qué ya está protegido en el código, qué falta y el plan paso a paso para usar dinero real.
126
+
127
+ ## Hashes de prueba
128
+
129
+ Una ejecución real en Stellar testnet:
130
+
131
+ - Pago de 0.01 USDC (x402): [`15ae64c6…43bd`](https://stellar.expert/explorer/testnet/tx/15ae64c6e6a6bca9ae3775ca4971f0d5f7d6d89dfcd6ec9c2ceadd778e2743bd)
132
+ - Sello, con el hash del archivo en su memo: [`980e4423…1bc0`](https://stellar.expert/explorer/testnet/tx/980e4423e8a7476d899aed94d7d4220f5071ee45bdaa939a0f7c04a76cfc1bc0)
133
+
134
+ Sello hecho contra la API pública (desplegada en Railway): [`16e1df0c…a80d`](https://stellar.expert/explorer/testnet/tx/16e1df0c10c019c7b8f9235f27e8e1282968f2fdb835778668c878b06d27a80d)
135
+
136
+ ## Límites actuales
137
+
138
+ - **Testnet y mainnet.** La API pública de arriba usa testnet (dinero de prueba). También hay una API en mainnet con dinero real, ya probada con sellos reales: sus direcciones y cómo usarla están en [docs/mainnet.md](docs/mainnet.md). En ambas, cada usuario usa su propia cartera ya fondeada, con el tope de gasto que ya aplica el cliente. Imponer ese límite en la propia cuenta (por ejemplo con cuentas inteligentes) sería una mejora futura, no un requisito.
139
+ - **La cartera que paga depende del usuario.** Notch nunca la crea ni la custodia: el servidor solo cobra y sella.
140
+ - **Una sola instancia del servidor**, porque los sellos se firman en cola con números de secuencia de Stellar.
141
+
142
+ ## Equipo y partes
143
+
144
+ - [josecadenax](https://github.com/josecadenax): [su parte](partes/josecadenax/README.md)
@@ -0,0 +1,156 @@
1
+ # Going to mainnet
2
+
3
+ Mainnet moves **real money**. Notch runs on testnet by default and nothing here changes that: mainnet is something you ask for twice.
4
+
5
+ ```
6
+ STELLAR_NETWORK=pubnet # which network
7
+ NOTCH_ALLOW_MAINNET=1 # "yes, I mean real money"
8
+ ```
9
+
10
+ Without both, the server, the CLI and the MCP server refuse to run on mainnet.
11
+
12
+ ## What the code already does
13
+
14
+ | Piece | On mainnet |
15
+ |---|---|
16
+ | Network, passphrase, Horizon, USDC, explorer | Switch together with `STELLAR_NETWORK`. The USDC asset is checked in tests against the contract `@x402/stellar` uses |
17
+ | Facilitator | Defaults to `https://channels.openzeppelin.com/x402` and the server refuses to start without `FACILITATOR_API_KEY` |
18
+ | Soroban RPC | The paying client needs `SOROBAN_RPC_URL`. SDF runs no public one for mainnet, so there is no default and the client refuses to start without it |
19
+ | API and payee pins | The official mainnet API and payee are pinned by default (see [Live deployment](#live-deployment)). Another server needs `NOTCH_API_URL` and `EXPECTED_PAYEE`. The testnet public API is never used by mistake |
20
+ | Payment network | The client refuses any request that is not `stellar:pubnet` before signing |
21
+ | Accounts | `setup:accounts` will not create or fund accounts on mainnet (no Friendbot). `--keys-only` makes keys offline |
22
+ | Messages | `check_balance` and the server say which network they are on and whether the money is real |
23
+
24
+ ## Live deployment
25
+
26
+ Since 25 Nov 2026 there is an official mainnet API on Railway, a second service next to the testnet one, with its own volume.
27
+
28
+ | | |
29
+ |---|---|
30
+ | API | `https://zestful-mercy-production-31bdd567.up.railway.app` |
31
+ | Payee (receives the 0.01 USDC) | `GD6QIPHGOHOCPCWUCR3CLLN54FXWLDU3JJACQRTIQCA4YK4RDU5IPHRW` |
32
+ | Stamper (signs the stamp) | `GBCA6ESEFFROJKVSV2CO5UCLFTXK2RYFRNLNTNODSA7HAXXMXDDXWUB6` |
33
+
34
+ Compare the payee with Stellar Expert before paying. The first real stamps were made on this network: [stamp](https://stellar.expert/explorer/public/tx/0c157854ad4253bac48f768063ae9bea05f43d4a8cdaaf1c973193d4c6082bd9) and its [payment](https://stellar.expert/explorer/public/tx/4c7925bcdd9ff4e4355138c621391a70d786bc2e36073ce11d1f41d58dec7bc0).
35
+
36
+ ## What is NOT done or not verified
37
+
38
+ - OpenZeppelin's daily fee limit on mainnet, terms and any SLA are unknown. Ask them.
39
+ - One early settlement answered 402 although the payment went through on the network (one stamp, charged once). It did not happen again in two more tries. The server now logs how every settlement ends (`[facilitator]` lines), so the next one will leave the reason.
40
+ - No limit of stamps per day is enforced beyond the per-minute rate limit.
41
+
42
+ ## The Soroban RPC: what it is and what users must do
43
+
44
+ The paying client prepares the USDC transfer before it signs, and for that it asks a **Soroban RPC**. On every payment it makes three requests:
45
+
46
+ | # | Request | Why |
47
+ |---|---|---|
48
+ | 1 | `getLatestLedger`: what is the current ledger? | To know until which ledger the payment authorization is valid (300 seconds is about 60 ledgers) |
49
+ | 2 | `simulateTransaction`: would this transfer work? | The client builds a USDC `transfer` from the payer to the payee and checks that the balance and the trustline are there, and what authorization it needs |
50
+ | 3 | `simulateTransaction` again, now signed | To confirm the transfer is still valid once the authorization is signed |
51
+
52
+ A fourth request, to estimate how long a ledger takes, goes to Horizon, which is public.
53
+
54
+ What the RPC does **not** do: it does not send the payment (the facilitator submits it), it never sees the secret key (the authorization is signed locally) and simulating spends nothing. If the balance or the trustline is missing, the simulation fails before anything is signed, which is a safety net.
55
+
56
+ What the provider can see: the payer and payee addresses, the amount and the signed authorization. Not the secret key and not your files (only a hash goes to Notch, and not to the RPC). On mainnet, pick a provider you trust.
57
+
58
+ **On testnet users do nothing:** SDF runs a free public RPC and Notch uses it. **On mainnet Stellar runs none**, so each user who pays must:
59
+
60
+ 1. Choose a provider with a free tier from <https://developers.stellar.org/docs/data/rpc/providers> and check its limits.
61
+ 2. Sign up and get an access URL.
62
+ 3. Put it in `SOROBAN_RPC_URL`, in the `env` block of the Notch server in Claude Desktop (see [mcp.md](mcp.md#mainnet)).
63
+
64
+ Three requests per payment is very little, so a free tier is enough for normal use. The real friction is the sign-up with a third party, not the cost. Options to remove it later: a small Notch service that forwards only these requests (you would pay for the usage and have to control abuse), or nothing at all. A provider key must never be hard-coded in this public repository.
65
+
66
+ How a user finds out they have to do this: if anything is missing the MCP server says so, all at once, in its log and in the answer to any tool call (see [mcp.md](mcp.md#mainnet)).
67
+
68
+ ## Accounts and what each one holds
69
+
70
+ | Account | Role | Needs |
71
+ |---|---|---|
72
+ | **payee** | Receives the 0.01 USDC of each stamp | XLM for its reserve, a USDC trustline. Its **secret** must be kept offline: it is the only way to withdraw what it earns |
73
+ | **stamper** | Signs the stamp transactions and pays their fee (a fraction of a cent) | XLM for its reserve and fees. Its secret lives on the server |
74
+ | **agent** | The user's paying wallet. A dedicated account the user **brings**, not one Notch creates | XLM for its reserve, a USDC trustline and some USDC. Its secret stays on the user's machine |
75
+
76
+ An account must keep a reserve: 1 XLM, plus 0.5 XLM for each trustline. A stamp transaction costs 0.00001 XLM, so the stamper's fees are negligible next to its reserve.
77
+
78
+ As a first, minimal funding, think in terms of: payee about 2 XLM, stamper about 2 XLM, agent about 2 XLM plus 1 USDC (100 stamps). Check current prices yourself before buying anything.
79
+
80
+ ## Plan, in order
81
+
82
+ ### 1. Prepare (no money moves)
83
+
84
+ Decide where the **payee** lives. It is the account that receives the money, and the server only needs its public address.
85
+
86
+ - **A wallet you already have, such as Freighter (recommended).** The secret stays in the wallet and never goes into a file or onto a server. Switch Freighter to mainnet, copy the address of an account and use it as `PAYEE_PUBLIC`. Add the USDC asset from Freighter (that creates the trustline) and withdraw from Freighter when you want. Then you only generate the stamper and the agent:
87
+
88
+ ```bash
89
+ STELLAR_NETWORK=pubnet npm run setup:accounts -- --keys-only --stamper-only # stamper into .env.mainnet-stamper
90
+ ```
91
+
92
+ - **A new account made here.** It also saves `PAYEE_SECRET` in a file, which you must keep offline:
93
+
94
+ ```bash
95
+ STELLAR_NETWORK=pubnet npm run setup:accounts -- --keys-only # payee and stamper into .env.mainnet
96
+ ```
97
+
98
+ The **paying wallet (agent)** is not made here: each user brings their own, as [mcp.md](mcp.md#on-mainnet-bring-your-own) explains. This is also what you do for your own stamps: use an account you control and have funded, ideally a dedicated one.
99
+
100
+ Use a dedicated account for the stamper too, never your main wallet. The stamper's secret lives on the server and the agent's in Claude Desktop's config, so each should hold only what you can afford to lose.
101
+
102
+ This generates keys offline and prints the public addresses. **Back up the secrets in a password manager now.** Losing one means losing what is in that account.
103
+
104
+ Then:
105
+
106
+ - Create a mainnet facilitator key at <https://channels.openzeppelin.com/gen>. The docs say it asks you to sign in with GitHub, but it has also returned the key straight away. Either way it is shown once: save it right away. Which network a key is for is decided by trying it, not by the page, so run the check below.
107
+ - Choose a Soroban RPC provider. Public ones with a free tier are listed at <https://developers.stellar.org/docs/data/rpc/providers>. Check their limits.
108
+ - Confirm the facilitator supports mainnet, with no payment involved:
109
+
110
+ ```bash
111
+ STELLAR_NETWORK=pubnet FACILITATOR_API_KEY=<mainnet key> npm run facilitator:check
112
+ ```
113
+
114
+ ### 2. Fund the accounts and add the trustlines
115
+
116
+ You send the XLM yourself (from your wallet or exchange) to the public addresses of the payee and the stamper. The agent is the account you bring: if it is not ready yet, fund it too. Each account needs its 1 XLM base reserve to exist, plus 0.5 XLM for each trustline. Notch cannot and should not move your money.
117
+
118
+ Then the USDC trustline, on the payee and on the agent when they do not have it. If the payee is a Freighter account, add the USDC asset from Freighter instead. An agent account that already holds USDC needs nothing. The script only shows what it would do unless you add `--yes`, and it reads the secret from a variable, never from the command line:
119
+
120
+ ```bash
121
+ export STELLAR_NETWORK=pubnet NOTCH_ALLOW_MAINNET=1
122
+ node --env-file=.env.mainnet partes/josecadenax/scripts/add-trustline.js PAYEE_SECRET # shows the plan
123
+ node --env-file=.env.mainnet partes/josecadenax/scripts/add-trustline.js PAYEE_SECRET --yes # does it
124
+ ```
125
+
126
+ For an agent that needs it, run the same script with `--env-file` pointing to the file where you keep its `AGENT_SECRET`, and `AGENT_SECRET` as the variable name.
127
+
128
+ Finally make sure the agent holds some USDC. Check everything, read-only. The agent only needs its **public** address here:
129
+
130
+ ```bash
131
+ STELLAR_NETWORK=pubnet AGENT_PUBLIC=G...your agent address... node --env-file=.env.mainnet partes/josecadenax/scripts/check-accounts.js
132
+ ```
133
+
134
+ It must say `All good.` before you go on.
135
+
136
+ ### 3. First real stamp, locally
137
+
138
+ Run the server on your machine with the mainnet settings (the facilitator key, `STELLAR_NETWORK=pubnet`, `NOTCH_ALLOW_MAINNET=1`, the payee and the stamper) and stamp one file with the CLI, setting `SOROBAN_RPC_URL`, `API_URL=http://localhost:...` and the same two network variables. That is one cent. Open both transactions on the public explorer and verify the file with `npm run verify`.
139
+
140
+ ### 4. Deploy
141
+
142
+ Deploy from a branch, not from `main`, until the mainnet code is merged. A **second** Railway service, separate from the testnet one, with its own volume. Variables: `STELLAR_NETWORK=pubnet`, `NOTCH_ALLOW_MAINNET=1`, `PAYEE_PUBLIC`, `STAMPER_PUBLIC`, `STAMPER_SECRET`, `FACILITATOR_API_KEY`, `TRUST_PROXY=1`, `REGISTRY_PATH=/data/stamps.json`. Never `PAYEE_SECRET` or `AGENT_SECRET`.
143
+
144
+ ### 5. Make the official deployment official
145
+
146
+ Once the mainnet API is live, fill in `OFFICIAL.mainnet` in `src/config.js` with its public URL, the payee and the stamper (public keys only). From then on users of that API set neither `NOTCH_API_URL` nor `EXPECTED_PAYEE`: the client pins them by default, as it does on testnet. Publish the same payee in the README so anyone can compare it with Stellar Expert.
147
+
148
+ ### 6. Open it up
149
+
150
+ Publish the mainnet API URL and payee so users can pin them (`NOTCH_API_URL`, `EXPECTED_PAYEE`), say clearly what a stamp proves (existence and date, not authorship or legal validity), and start with a low limit of stamps per day until you know how the facilitator behaves.
151
+
152
+ ## Safety habits
153
+
154
+ - Use a **dedicated** paying wallet with a small balance. The MCP server can spend what it holds, up to the cap per stamp.
155
+ - Keep `PAYEE_SECRET` offline. Anything on Railway can leak.
156
+ - Do the first runs with cents, not dollars.
package/docs/mcp.md ADDED
@@ -0,0 +1,187 @@
1
+ # Notch MCP server
2
+
3
+ Lets Claude Desktop (or any MCP client) stamp and verify files against the public Notch API.
4
+ It runs **on your computer** as a local process. Claude starts it; nothing is hosted for you.
5
+
6
+ ```
7
+ Claude Desktop ──stdio──> notch MCP server (your Mac) ──https + x402──> Notch API (Railway) ──> Stellar
8
+ hashes the file locally
9
+ holds the agent wallet
10
+ ```
11
+
12
+ Only the SHA-256 of a file leaves your computer, never the file itself.
13
+
14
+ ## Tools
15
+
16
+ | Tool | Cost | What it does |
17
+ |---|---|---|
18
+ | `stamp_file(path)` | 0.01 USDC | Hashes the file, pays with x402 and anchors the hash on Stellar. Stamping the same file twice is refused without charge and returns the existing stamp |
19
+ | `verify_stamp(path, tx?)` | free | Checks the file against a stamp, directly on Stellar. If `tx` is omitted it is looked up by the file's hash |
20
+ | `check_balance()` | free | Shows the paying wallet, its USDC balance, how many stamps it can still pay, the spend cap and the only account it will pay. Never shows the secret |
21
+
22
+ ## Your wallet
23
+
24
+ Stamps are paid from **your own wallet**, the "paying wallet" or agent wallet. It is a Stellar account that only you hold, and Notch never creates, holds or sees it:
25
+
26
+ - Its secret key (`AGENT_SECRET`) never goes to Notch or to any server.
27
+ - The MCP server signs each payment on its own, without a confirmation window, so it needs the secret key itself. A wallet app that keeps the key inside it (Freighter, for example) cannot sign for it.
28
+ - Anyone who can read the secret can spend the balance, and it sits in plain text in Claude Desktop's config. **Use a dedicated account with a small balance**, never your main wallet.
29
+
30
+ ### On mainnet: bring your own
31
+
32
+ Use an account you already control and have funded. There is nothing to create, only to configure:
33
+
34
+ 1. **Pick the account.** It has to be one whose secret key you can export. A good choice is a new secondary account in your wallet (in Freighter, add an account), funded with a small amount. Export its secret key only when you are about to paste it into the config.
35
+ 2. **Make sure it is ready.** It needs XLM for its reserve (1 XLM, plus 0.5 XLM for the USDC trustline), the USDC trustline and some USDC. If it already holds USDC it is ready.
36
+ 3. **Put the secret in `AGENT_SECRET`** (see [Mainnet](#mainnet)).
37
+ 4. **Check it, read-only, with its public address only** (no secret needed):
38
+
39
+ ```bash
40
+ STELLAR_NETWORK=pubnet AGENT_PUBLIC=G...your address... node partes/josecadenax/scripts/check-accounts.js
41
+ ```
42
+
43
+ 5. Ask Claude *"check my Notch balance"* to see the wallet, its balance and how many stamps it can pay.
44
+
45
+ If you have no account to bring, `STELLAR_NETWORK=pubnet npm run setup:accounts -- --keys-only --agent-only` makes a new key offline, with nothing on the network. You fund it yourself and must back up its secret.
46
+
47
+ ### On testnet: create a test wallet
48
+
49
+ Testnet money is free, so here Notch can create and fund the wallet for you, from the project folder:
50
+
51
+ ```bash
52
+ npm run setup:accounts -- --agent-only
53
+ ```
54
+
55
+ This creates a new wallet, funds it with test XLM, buys 1 USDC of test money for it (enough for about 100 stamps) and saves its keys in `.env.agent`, readable only by you. It prints the wallet address. It never overwrites an existing `.env.agent`.
56
+
57
+ To top it up later, send test USDC to the wallet address from <https://faucet.circle.com> (choose Stellar testnet). Ask Claude *"check my Notch balance"* at any time to see how many stamps are left.
58
+
59
+ > The default `npm run setup:accounts` (without `--agent-only`) is for people who run their own Notch server: it also creates the payee and stamper accounts.
60
+
61
+ ## Setup
62
+
63
+ 1. Get the code and install dependencies (Node 22 or newer):
64
+
65
+ ```bash
66
+ git clone https://github.com/josecadenax/notch.git
67
+ cd notch
68
+ npm install
69
+ ```
70
+
71
+ 2. Get your paying wallet, as shown above. On testnet, `npm run setup:accounts -- --agent-only` creates one: open `.env.agent` and copy the `AGENT_SECRET=...` value. On mainnet, bring your own account.
72
+
73
+ 3. Find the absolute path of Node, because Claude Desktop does not read your shell profile:
74
+
75
+ ```bash
76
+ which node
77
+ ```
78
+
79
+ 4. Edit Claude Desktop's config (`~/Library/Application Support/Claude/claude_desktop_config.json`) and add `notch` inside `mcpServers`:
80
+
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "notch": {
85
+ "command": "/absolute/path/to/node",
86
+ "args": ["/absolute/path/to/notch/partes/josecadenax/src/mcp-server.js"],
87
+ "env": {
88
+ "AGENT_SECRET": "S...your wallet secret..."
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ 5. Quit Claude Desktop completely (Cmd+Q) and open it again. Ask: *"Check my Notch balance"*, then *"Stamp /Users/me/Documents/contract.pdf with Notch"* and *"Verify that file"*.
96
+
97
+ Use **absolute paths** for files. Claude Desktop does not run in your project folder.
98
+
99
+ ## Mainnet
100
+
101
+ Everything above uses testnet and test money. Mainnet uses **real money**, so it is never on by accident: you have to ask for it, name everything it needs, and there are no defaults to fall back on. The full plan is in [mainnet.md](mainnet.md).
102
+
103
+ Add these to the `env` block of the `notch` server. `AGENT_SECRET` is the account you bring, as explained in [Your wallet](#on-mainnet-bring-your-own):
104
+
105
+ ```json
106
+ "env": {
107
+ "AGENT_SECRET": "S...the secret of a dedicated wallet with a small balance...",
108
+ "STELLAR_NETWORK": "pubnet",
109
+ "NOTCH_ALLOW_MAINNET": "1",
110
+ "NOTCH_API_URL": "https://...the mainnet Notch API...",
111
+ "EXPECTED_PAYEE": "G...the account that must receive the payment...",
112
+ "SOROBAN_RPC_URL": "https://...an RPC from your provider..."
113
+ }
114
+ ```
115
+
116
+ | Setting | What it is |
117
+ |---|---|
118
+ | `STELLAR_NETWORK=pubnet` | Use mainnet |
119
+ | `NOTCH_ALLOW_MAINNET=1` | A second, explicit "yes, real money" |
120
+ | `NOTCH_API_URL` | The Notch API to use. There is no default on mainnet |
121
+ | `EXPECTED_PAYEE` | The only account you will pay, so a fake API cannot charge you |
122
+ | `SOROBAN_RPC_URL` | A Soroban RPC from a provider. Stellar runs none for mainnet. See [what it is used for](mainnet.md#the-soroban-rpc-what-it-is-and-what-users-must-do) |
123
+
124
+ You do not have to remember this list. If something is missing, Notch tells you **all of it at once**, with the block to paste:
125
+
126
+ - when Claude Desktop starts the server, in its log (`~/Library/Logs/Claude/mcp-server-notch.log`), and
127
+ - in the answer to any tool. For example, asking *"check my Notch balance"* answers with what is missing and says to quit Claude Desktop (Cmd+Q) and open it again. Claude will explain it to you.
128
+
129
+ Once everything is set, `check_balance` shows `Network: mainnet (REAL money)`, your wallet, its balance and the only account it will pay. Start with cents.
130
+
131
+ ## Settings
132
+
133
+ All settings are environment variables in the `env` block above.
134
+
135
+ | Variable | Default | Meaning |
136
+ |---|---|---|
137
+ | `AGENT_SECRET` | none, required to stamp | Wallet that pays. Never leaves your machine. Not needed to verify |
138
+ | `SPEND_CAP` | `$0.02` | Most the server will pay for one stamp. If the API asks for more, nothing is signed |
139
+ | `NOTCH_API_URL` | the public Notch API | API to talk to |
140
+ | `EXPECTED_PAYEE` | pinned for the public API | Stellar account that must receive the payment. Required for any other API |
141
+ | `NOTCH_STAMPER` | pinned for the public API | Stellar account that signs stamps, used to tell whether a stamp was issued by that Notch |
142
+
143
+ ## Safety rules
144
+
145
+ The server enforces these before it signs anything:
146
+
147
+ - **Pinned payee.** The API says who to pay. If that account is not `EXPECTED_PAYEE`, the payment is refused, so a fake or hijacked API cannot collect your money. For the public API the payee is already pinned. For any other API you must set it.
148
+ - **https required.** Plain `http` is only accepted for `localhost`.
149
+ - **Spend cap.** Each stamp is limited to `SPEND_CAP`. x402 refuses to sign above it.
150
+ - **Balance check.** Without enough USDC nothing is signed.
151
+ - **Pay once.** There are no blind retries after a payment is sent. If something fails midway, the message says whether the balance changed.
152
+ - **No duplicates.** Stamping a file that is already stamped is not charged.
153
+
154
+ What it cannot protect you from: the wallet in `AGENT_SECRET` is only as safe as your computer. Keep its balance small.
155
+
156
+ ## Running against your own server
157
+
158
+ ```json
159
+ "env": {
160
+ "AGENT_SECRET": "S...",
161
+ "NOTCH_API_URL": "https://my-notch.example.com",
162
+ "EXPECTED_PAYEE": "G...the payee account of that server...",
163
+ "NOTCH_STAMPER": "G...the stamper account of that server..."
164
+ }
165
+ ```
166
+
167
+ For local development, `NOTCH_API_URL=http://localhost:3001` needs no `EXPECTED_PAYEE`.
168
+
169
+ ## Troubleshooting
170
+
171
+ | Symptom | Likely cause |
172
+ |---|---|
173
+ | Claude shows the server as failed | `command` is not the absolute path to Node, or the `args` path is wrong. Check Claude's MCP log |
174
+ | "Missing AGENT_SECRET" | The `env` block is missing or the key is empty. On testnet create a wallet with `npm run setup:accounts -- --agent-only`. On mainnet put the secret of the account you bring |
175
+ | `WALLET_NOT_FOUND` | The wallet was never funded. On testnet run `npm run setup:accounts -- --agent-only`. On mainnet send XLM to its address first |
176
+ | `PAYEE_MISMATCH` | The API is asking to pay an account other than `EXPECTED_PAYEE`. Do not continue until you know why |
177
+ | `INSUFFICIENT_BALANCE` | The agent wallet has less than 0.01 USDC |
178
+ | `API_UNREACHABLE` | The API is down or you are offline. Nothing was paid |
179
+ | "The file was not found" | Use an absolute path |
180
+
181
+ ## Try it without Claude
182
+
183
+ ```bash
184
+ npm run mcp # starts the server on stdio, waits for an MCP client
185
+ ```
186
+
187
+ The tests cover the logic without a network: `npm test`.