Skip to main content
Glama
Datanest agent MCP

Datanest agent MCP

Official
README.md
# Datanest agent MCP

The agent commerce layer behind [Datanest](https://datanest-stores.com), a store for
production-ready digital developer products (code toolkits, templates, cheatsheets).
It runs as Cloudflare Pages Functions and exposes the catalogue to AI agents in three ways:

| Surface | Where | Notes |
|---|---|---|
| Remote MCP server (Streamable HTTP) | `https://datanest-stores.com/mcp` | 7 tools, no authentication for the read tools |
| REST API | `https://datanest-stores.com/api/agent/v1` | Same service layer, [OpenAPI 3.1](openapi.yaml) |
| x402 machine payments | `/api/x402/*` | On-chain USDC (Base), no Stripe account needed by the buyer's agent |

Try it without installing anything:

```bash
curl -s https://datanest-stores.com/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```

## MCP tools (7)

| Tool | What it does |
|---|---|
| `search_products` | Search and filter the catalogue (query, domain, category, tags, price cap, verified-only) |
| `get_product_details` | Full details for one product: files, prerequisites, supported versions, licence |
| `compare_products` | Side-by-side comparison of several products |
| `get_product_preview` | Preview snippets and the file list, without downloading |
| `create_checkout_link` | Prepares a Stripe Checkout link. Price is resolved server-side; the buyer authorizes the payment |
| `check_order_status` | Polls the status of a checkout session |
| `get_purchase_access` | Returns download access for a paid order after an ownership check |

Products marked `unaudited` or `deprecated` are listed but cannot be bought through agent checkout.

## HTTP routes

`/health`, `/.well-known/mcp.json`, `/.well-known/ai-plugin.json`, `/mcp`,
`/api/agent/v1/*` (REST), `/api/x402/*`, `/api/webhooks/stripe`, `/api/download`,
`/api/fulfilled`, `/api/click`. See [`src/router.ts`](src/router.ts).
The x402 flow is documented in [`docs/x402-payment-flow.md`](docs/x402-payment-flow.md).

## Develop

Requires Node.js 20+.

```bash
npm ci
npm run typecheck
npm test            # 203 tests pass, 6 more are skipped (see test/fork)
npm run build       # writes dist/_worker.js and dist/functions/[[path]].js
```

The `test/fork` suite replays x402 verification against a forked Base chain and only runs
with `X402_FORK=1` and a local [Foundry](https://getfoundry.sh) `anvil` binary.

## About the bundled catalogue

`data/catalog.json` is a snapshot of the public catalogue at
[datanest-stores.com/catalog.json](https://datanest-stores.com/catalog.json), embedded at
build time so read paths need no database. It does not contain Stripe price IDs or payment
links, so `create_checkout_link` will not work against it. To run your own instance, replace
the file with your catalogue (same shape as `CatalogProduct` in [`src/types.ts`](src/types.ts),
including `stripe_price_id` and `checkout_url` for sellable products).

Order fulfilment (creating the purchase and the download token after payment) is not part of
this repository.

## Configuration

All bindings are optional; features switch off when their binding is missing.
Set secrets with `wrangler pages secret put`, never in the repository.

| Binding | Purpose |
|---|---|
| `STRIPE_SECRET_KEY` | Create Checkout Sessions (`create_checkout_link`) |
| `STRIPE_WEBHOOK_SECRET` | Verify `/api/webhooks/stripe` events |
| `RESEND_API_KEY` | Send purchase receipts |
| `SUPABASE_FUNCTIONS_URL`, `SUPABASE_ANON_KEY` | Download function used by `get_purchase_access` |
| `CHECKOUT_ALLOWED_REDIRECT_HOSTS` | Allowed success/cancel redirect hosts |
| `AGENT_API_CORS_ORIGINS` | Origins allowed to call the REST API from a browser |
| `PUBLIC_BASE_URL` | Canonical public base URL |
| `RATE_LIMIT_KV` | KV namespace for durable rate limiting and idempotency |
| `CLICKS_R2`, `PRODUCTS` | R2 buckets for click events and product zips (download failover) |
| `X402_ENABLED`, `X402_PAYTO`, `X402_MASTER_PUB`, `X402_NETWORK`, `X402_RPC_URL`, `X402_RPC_URL_VERIFY`, ... | x402 payments; see `src/types.ts` for the full list and defaults. Fails closed when misconfigured |

## Registry listing

Listed in the official MCP Registry as `dev.pages.datanest-stores/store`
(see [`server.json`](server.json)).

## Licence

[MIT](LICENSE), Copyright (c) 2026 Mikivia Oy. Datanest is a brand of Mikivia Oy.
Product downloads sold through the store carry their own licence files.
Support: support@datanest-stores.com