{"_id":"@402report/sdk","_rev":"2-bf18203a4376b98f24e01e542e94e300","name":"@402report/sdk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@402report/sdk","version":"0.1.0","keywords":["x402","http-402","agent-payments","agentic-payments","ai-agent","mcp","spend-tracking","402report"],"author":{"name":"Jan Heye"},"license":"MIT","_id":"@402report/sdk@0.1.0","maintainers":[{"name":"402report","email":"hello@402.report"}],"homepage":"https://402.report","bugs":{"url":"https://github.com/402-report/sdk/issues"},"dist":{"shasum":"0c04d3f04947bcf677757144366aa5e565b640fe","tarball":"https://registry.npmjs.org/@402report/sdk/-/sdk-0.1.0.tgz","fileCount":18,"integrity":"sha512-fISB1sAIMvpwbpr8+bCUe6R+4861ni7TeFEAoi+hnRdSLQnHu0WFUXctov0EPnHqEOTl57A+CBirxZ0hXofZDw==","signatures":[{"sig":"MEUCIQDoG0t2420kAOwj+EfdywmAri7gV87XKQXYDS/OGx4hfQIgN+kMmj0/j6051/pSvrZ1WxPkcy/jrhQQo98I95C1C2g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39356},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./spend":{"types":"./dist/spend.d.ts","default":"./dist/spend.js"}},"gitHead":"1d5c8fd179a847502f7beadfd9158b3adf43655d","private":false,"scripts":{"dev":"tsc --watch","build":"tsc","typecheck":"tsc --noEmit","prepublishOnly":"npm run typecheck:contract && npm run build","typecheck:contract":"tsc --noEmit -p tsconfig.contract.json"},"_npmUser":{"name":"402report","email":"hello@402.report"},"repository":{"url":"git+https://github.com/402-report/sdk.git","type":"git"},"_npmVersion":"10.8.2","description":"Route your AI agents' HTTP through 402.report and query their x402 spend — set your API key and go.","directories":{},"sideEffects":false,"_nodeVersion":"22.20.0","dependencies":{"@modelcontextprotocol/sdk":"^1.29.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@types/node":"^26.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1784136052008_0.675653172708222","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@402report/sdk","version":"0.1.1","private":false,"description":"Route your AI agents' HTTP through 402.report and query their x402 spend — set your API key and go.","license":"MIT","author":{"name":"Jan Heye"},"homepage":"https://402.report","repository":{"type":"git","url":"git+https://github.com/402-report/sdk.git"},"bugs":{"url":"https://github.com/402-report/sdk/issues"},"type":"module","sideEffects":false,"main":"./dist/index.js","types":"./dist/index.d.ts","publishConfig":{"access":"public"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./spend":{"types":"./dist/spend.d.ts","default":"./dist/spend.js"}},"keywords":["x402","http-402","agent-payments","agentic-payments","ai-agent","mcp","spend-tracking","402report"],"scripts":{"build":"tsc","dev":"tsc --watch","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"dependencies":{"@modelcontextprotocol/sdk":"^1.29.0"},"devDependencies":{"@types/node":"^26.0.0","typescript":"^6.0.3"},"_id":"@402report/sdk@0.1.1","gitHead":"292e09d71c313f27743244364b66d4e9512f35c1","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-tdA3OF2mYs5Z9bzUSyF62fRygaLo5cd8oRsERdL0dUBHHP4AJTWIeofNEYAc5OKNd6QMJbAMK8pIH1GW6HhzHQ==","shasum":"212a85b767a140cb5e05dff355db2d076a044b47","tarball":"https://registry.npmjs.org/@402report/sdk/-/sdk-0.1.1.tgz","fileCount":18,"unpackedSize":38848,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@402report%2fsdk@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICQ3/UXN4pDcWweGc0QlNOPARqgYd0UIUe6iPdkg3XEvAiEA0Ht8o4wli+RSqXhsdS0tCHU+vIgEyYmhDKo+aaGeTAU="}]},"_npmUser":{"name":"402report","email":"hello@402.report"},"directories":{},"maintainers":[{"name":"402report","email":"hello@402.report"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.1_1784138386499_0.4929939673743098"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-15T17:20:51.871Z","modified":"2026-07-15T17:59:46.963Z","0.1.0":"2026-07-15T17:20:52.138Z","0.1.1":"2026-07-15T17:59:46.630Z"},"bugs":{"url":"https://github.com/402-report/sdk/issues"},"author":{"name":"Jan Heye"},"license":"MIT","homepage":"https://402.report","keywords":["x402","http-402","agent-payments","agentic-payments","ai-agent","mcp","spend-tracking","402report"],"repository":{"type":"git","url":"git+https://github.com/402-report/sdk.git"},"description":"Route your AI agents' HTTP through 402.report and query their x402 spend — set your API key and go.","maintainers":[{"name":"402report","email":"hello@402.report"}],"readme":"# @402report/sdk\n\nRoute your AI agents' HTTP through [402.report](https://402.report) so every **x402** (HTTP 402)\nchallenge and payment is observed — and query that spend in code. Set one API key and go.\n\n402.report is **non-custodial**: it observes your agents' x402 activity, it never holds or\nsettles funds. Your agent still makes its own payments.\n\n```bash\nnpm install @402report/sdk\n```\n\nCreate an API key in the 402.report dashboard, then set it (e.g. `REPORT402_API_KEY`).\n\n## 1. Route your agent's HTTP\n\n`createProxyFetch` returns a drop-in `fetch` that transparently routes every request through the\nproxy. Use it anywhere a custom `fetch` is accepted:\n\n```ts\nimport { createProxyFetch } from \"@402report/sdk\";\n\nconst fetch = createProxyFetch({ apiKey: process.env.REPORT402_API_KEY! });\n\n// Observed by 402.report — the real request still goes to api.example.com.\nconst res = await fetch(\"https://api.example.com/premium\");\n```\n\nFor SDK clients that take a `baseURL` + headers instead of a `fetch` (the OpenAI SDK, axios):\n\n```ts\nimport { proxyClientConfig } from \"@402report/sdk\";\nimport OpenAI from \"openai\";\n\nconst { baseURL, headers } = proxyClientConfig({\n  apiKey: process.env.REPORT402_API_KEY!,\n  target: \"https://api.openai.com\",\n});\nconst openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY!, baseURL, defaultHeaders: headers });\n```\n\n## 2. Give your agent its spend as MCP tools\n\nThe 402.report MCP server exposes your spend + forensics as read-only tools. These helpers return\nthe exact config shapes each framework/client expects (no framework imports):\n\n```ts\nimport { mastraMcpServer, aiSdkMcpTransport, mcpClientJson } from \"@402report/sdk\";\n\n// Mastra\nimport { MCPClient } from \"@mastra/mcp\";\nconst mcp = new MCPClient({ servers: { report402: mastraMcpServer({ apiKey }) } });\nconst tools = await mcp.getTools();\n\n// Vercel AI SDK\nimport { experimental_createMCPClient as createMCPClient } from \"ai\";\nconst client = await createMCPClient({ transport: aiSdkMcpTransport({ apiKey }) });\n\n// Claude Desktop / Cursor / VS Code / Windsurf — write this JSON into their MCP config:\nconsole.log(JSON.stringify(mcpClientJson({ apiKey }), null, 2));\n```\n\n## 3. Query spend in code\n\n```ts\nimport { SpendClient } from \"@402report/sdk/spend\";\n\nconst spend = new SpendClient({ apiKey: process.env.REPORT402_API_KEY! });\nconst summary = await spend.getSpendSummary();            // last 30 days\nconst failed = await spend.listFailedPayments({ limit: 20 }); // paid-but-failed attempts\nawait spend.close();\n```\n\n`SpendClient` speaks MCP over Streamable HTTP and needs `@modelcontextprotocol/sdk` (installed as\na dependency). The routing/config helpers above have no runtime dependencies.\n\n## API\n\n| Export | What it does |\n| --- | --- |\n| `createProxyFetch({ apiKey, proxyUrl? })` | A `fetch` that routes requests through the proxy. |\n| `proxyClientConfig({ apiKey, target, proxyUrl? })` | `{ baseURL, headers }` for baseURL-style clients. |\n| `mcpHttpConfig` / `mastraMcpServer` / `aiSdkMcpTransport` / `mcpClientJson` | MCP connection config per framework/client. |\n| `SpendClient` (`@402report/sdk/spend`) | Typed spend + forensics queries by API key. |\n| `PROXY_URL`, `MCP_URL` | Hosted endpoint defaults. |\n\n## Self-hosting / local dev\n\nPoint at a local proxy with `proxyUrl` / `mcpUrl` (e.g. `http://localhost:8402` and\n`http://localhost:8402/mcp`).\n","readmeFilename":"README.md"}