# TDM Agent Integration Kit

> Developer integration tools for adding TDM payments to AI agents, apps, and workflows. CLI, MCP server, and copy-paste examples.

- **Type:** MCP server
- **Install:** `agentstack add mcp-todealmarket-tdm-agent-integration-kit`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [ToDealMarket](https://agentstack.voostack.com/s/todealmarket)
- **Installs:** 0
- **Category:** [Finance & Payments](https://agentstack.voostack.com/c/finance-and-payments)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [ToDealMarket](https://github.com/ToDealMarket)
- **Source:** https://github.com/ToDealMarket/TDM-Agent-Integration-Kit
- **Website:** https://todealmarket.com/

## Install

```sh
agentstack add mcp-todealmarket-tdm-agent-integration-kit
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# TDM Agent Integration Kit

**Developer Integration Tools**

[](./LICENSE)
[](https://modelcontextprotocol.io/)
[](https://github.com/ToDealMarket/TDM-Agent-Integration-Kit/stargazers)
[](https://www.typescriptlang.org/)

*Reference implementations and copy-paste building blocks for teams that need to add TDM payments into existing projects.*

[Documentation](https://todealmarket.com/docs) • [API Reference](https://todealmarket.com/docs/api) • [GitHub](https://github.com/todealmarket) • [X/Twitter](https://x.com/todealmarket)

```
████████╗ ██████╗  ███╗   ███╗
╚══██╔══╝ ██╔══██╗ ████╗ ████║
   ██║    ██║  ██║ ██╔████╔██║
   ██║    ██║  ██║ ██║╚██╔╝██║
   ██║    ██████╔╝ ██║ ╚═╝ ██║
   ╚═╝    ╚═════╝  ╚═╝     ╚═╝

TDM Integration Kit [V0.1]
CLI + Client + MCP
Mode: local-first | Docs: todealmarket.com/docs
```

---

## What is TDM Agent Integration Kit?

This kit gives developers three public integration surfaces they can use from almost any stack:

- `tdm` CLI for shellable flows
- local signer HTTP on `127.0.0.1` for advanced local agents
- MCP for agent runtimes that already speak MCP

The public GitHub repo for `tdm-sdk` shows the open contract-facing SDK
surface: https://github.com/ToDealMarket/tdm-sdk

The current `tdm-sdk` npm beta used throughout this kit remains broader and
includes the CLI and operator flows referenced below.

It also now covers the local catalog and runtime-ops path:

- named storage roots
- folder import and sync
- watch loops for long-lived operator machines
- local or tunnel publish flows for stored assets and folders
- optional `tdm workspace` orchestration for reusable vault + storage + agent contours
- `tdm status`, `tdm where`, and `tdm workspace status` for the main operator view

## What is inside

- [`client`](./client): tiny `@tdm/client` wrapper for CLI + local signer
- [`examples`](./examples): copy-paste recipes for common stacks
- [`mcp-server`](./mcp-server): standalone `@tdm/mcp-server` reference package

---

## Build An Integration In 10 Minutes

1. Install and connect TDM.

```bash
npm install -g tdm-sdk
tdm connect
tdm status
```

`tdm connect` now stores your primary wallet locally. In the current
multi-wallet MVP, you can keep one wallet per supported network for local
signing and seller payouts, and `tdm connect` also attempts a safe default
payout sync for the same network when that payout slot is still empty.

- it does not overwrite an already saved payout wallet automatically
- use `tdm connect --no-sync-payout-wallet` if you want a local-only connect
- if your account requires step-up for a new payout destination, run
  `tdm security totp enroll`, then `tdm security totp verify`, and rerun
  `tdm connect` or use `tdm payout wallets set`
- you can save payout wallets per network, so for example one wallet can be
  used for `Solana` and another for `Base`/EVM without replacing the other

`tdm security totp enroll` now opens a local setup page with a QR by default.
Use `--no-browser` when you want terminal-only setup with the secret or
`otpauth://` URL.

If an operator jumps straight into a live command such as `tdm make payable`,
`tdm payout request`, or `tdm unlock`, the interactive CLI can now auto-start the same Live TDM
setup instead of leaving the runtime half-configured.

## Vault and agent binding

Agent isolation is vault-first, not fuzzy session magic:

- the selected vault comes from `--vault `, or `TDM_VAULT`, or the active
  vault marker written by `tdm vault use`
- each named vault has its own credentials file under
  `~/.tdm/vaults//credentials.json`
- keyring refs are namespaced per vault, so the same agent name in two vaults
  does not collide
- agents are stored under that vault's local `credentials.agents` map and are
  registered live from that same vault contour
- MCP follows the same resolution order, so it reads one explicit vault
  context instead of merging multiple vaults together

In practice, one agent belongs to one selected vault at a time. Workspaces can
attach agents for orchestration, but they do not replace vault ownership.

2. Start the local signer if your integration needs local signatures.

```bash
tdm signer serve
```

By default, TDM now asks the OS for a random free localhost port and prints the
exact base URL plus signer token.

3. Save the printed signer token and signer URL.

```bash
TDM_SIGNER_TOKEN=...
TDM_SIGNER_URL=http://127.0.0.1:
```

If you want a fixed port for local development examples, start it explicitly
with one:

```bash
tdm signer serve --port 41001
```

4. Smoke test the local signer.

```bash
curl http://127.0.0.1:/v1/health
```

5. Pick a recipe from [`examples`](./examples) or use [`@tdm/client`](./client).

---

## Local catalogs and runtime workspaces

If the operator wants to keep files on their own machine or server instead of
moving everything into external hosting first, the public CLI path is now:

```bash
tdm storage add media ./seller-storage --use
tdm storage import-dir ./products/docs --storage media
tdm storage publish ./products/docs --storage media --mode tunnel
tdm workspace create seller-lab --storage media --use
tdm workspace attach-agent seller-lab worker-1
tdm status
tdm workspace status
tdm make payable --asset  --storage media --price 0.05
```

That flow keeps the catalog local-first while still allowing public delivery
through a tunnel or other operator-managed hostname.

## Optional runtime route policy

If an integration needs a stricter outbound policy, TDM now supports an
optional layered allowlist:

- project allowlist for shared defaults across the repo
- vault allowlist for one isolated contour and the agents inside it

This layer is optional. If you do not configure it, the runtime keeps the
broader flexible behavior instead of blocking routes by default.

```bash
tdm trust verify domain --target api.example.com --resource res_demo123
tdm allowlist add api.example.com
tdm allowlist add api.example.com --scope vault --vault seller-bot --verified
tdm allowlist check https://api.example.com/private/route --vault seller-bot
tdm allowlist list --vault seller-bot
```

---

## How to use this kit

Start with the smallest surface that solves the task:

- use `CLI` when the host project can shell out and just needs payment setup or payable resource registration
- use `@tdm/client` when you want one JavaScript entrypoint for CLI plus local signer access
- use `chargeFetchHandler(...)`, `chargeExpressHandler(...)`, `tdm-sdk/authorize`, `tdm-sdk/checkout`, `tdm-sdk/session-tanks`, or `createGatewayClients(...)` when you want a direct live gateway integration in JavaScript without building a fake monolithic SDK wrapper
- use `Local signer HTTP` when the host project is Python, Go, Ruby, or mixed-stack
- use `MCP` when the runtime already speaks MCP and only needs session checks or payment guidance

Treat the examples as reference implementations, not as plugins that must be installed exactly as-is.

## Current routing notes

For recovery and sweep-style flows, the current public SDK behavior is:

- Solana Jupiter:
  - with `JUPITER_API_KEY`, use `https://api.jup.ag/swap/v1`
  - without a key, the SDK keeps a compatibility fallback to `https://lite-api.jup.ag/swap/v1`
- Base Odos:
  - without `ODOS_API_KEY`, use `https://api.odos.xyz`
  - with `ODOS_API_KEY`, use `https://enterprise-api.odos.xyz`

These details matter for builders wiring local recovery helpers or copying SDK
examples into their own stack.

---

## Who this kit is for

This kit is for:

- coding agents integrating TDM into existing apps
- developers adding paid access to APIs, routes, tools, bots, and local workflows
- teams that want a practical starting point instead of building every integration piece from scratch

This kit is not the buyer-facing checkout product.

End buyers should not need to install `npm` or run local TDM tooling just to pay. For broad buyer adoption, the right path is a hosted or embedded checkout surface on top of TDM, while this kit remains the integration layer for builders.

---

## Public discovery and checkout entry points

Public payable resources can also be exposed through shareable discovery and checkout entry points:

- x402/Bazaar-style listing feed: `GET /api/v1/bridge/x402/resources`
- MPP-style service feed: `GET /api/v1/bridge/mpp/services`
- MPP-oriented discovery text feed: `GET /api/v1/bridge/mpp/llms.txt`
- buyer entry redirect: `GET /api/v1/bridge/buy/:resourceId`
- programmatic checkout-session entry: `POST /api/v1/bridge/purchase`

These endpoints do not replace TDM checkout or authorization. They help external tools, directories, and lightweight clients find a resource and enter the normal purchase flow.

---

## Choose The Right Surface

### CLI

Best when:
- your stack can run shell commands
- you want the quickest possible integration
- you need `connect`, `make payable`, `balance`, `payout request`, or `unlock`

### Local signer HTTP

Best when:
- you need local signing without exporting keys
- your app already knows how to build payloads
- you want language-agnostic access from Python, Go, Ruby, Node, or local tools

### MCP

Best when:
- your runtime already supports MCP
- you only need local TDM session-state hints
- you want a narrow agent helper instead of a general-purpose signer

### Integration Examples

Available in [`examples`](./examples):
- Express.js paywall
- Next.js gated content
- Python FastAPI
- Telegram bot

---

## Important boundaries

- `@tdm/client` is intentionally thin; it keeps the public integration path explicit
- `@tdm/client` is for CLI plus local signer workflows; it is not the new live gateway facade layer
- local signer mode is for advanced users and custom integrations
- review what your app signs and keep wallet credentials in your local environment
- for paid files, prefer short-lived links or inline payloads over permanent public redirects

---

## Suggested rollout

- use [`examples/express-paywall`](./examples/express-paywall) or [`examples/nextjs-gated`](./examples/nextjs-gated) for agent or API paths
- use [`examples/python-fastapi`](./examples/python-fastapi) when the host stack is Python
- use [`examples/telegram-bot`](./examples/telegram-bot) for bot-style creator or agent delivery

---

## Repository Structure

```
TDM-Agent-Integration-Kit/
├── README.md              ← You are here
├── LICENSE                ← MIT License
├── client/
│   ├── src/               ← Client source code
│   ├── dist/              ← Built distribution
│   ├── test/              ← Client tests
│   ├── package.json       ← Client package config
│   ├── tsconfig.json      ← TypeScript config
│   └── README.md          ← Client documentation
├── mcp-server/
│   ├── src/               ← MCP server source
│   ├── dist/              ← Built distribution
│   ├── test/              ← MCP server tests
│   ├── package.json       ← MCP package config
│   ├── tsconfig.json      ← TypeScript config
│   └── README.md          ← MCP documentation
└── examples/
    ├── express-paywall/   ← Express.js integration
    ├── nextjs-gated/      ← Next.js integration
    ├── python-fastapi/    ← Python FastAPI integration
    ├── telegram-bot/      ← Telegram bot integration
    └── README.md          ← Examples overview
```

---

## Security Notes

- **No private keys in this repo** - This is guidance only
- **OS keyring required** - CLI stores keys securely
- **Local signer is localhost-only** - Advanced users only
- **Review local automations carefully** - especially when using advanced local signer flows
- **Keep wallet credentials under your control** - Never export private keys

---

## Contributing

Contributions welcome! Please:

1. Fork the repository
2. Create a feature branch
3. Update documentation
4. Add examples
5. Submit a pull request

---

## Documentation

- [TDM Documentation](https://todealmarket.com/docs)
- [SDK Reference](https://todealmarket.com/docs/api/sdk)
- [Integration Guide](https://todealmarket.com/docs/integration-kit)
- [Agent Payment Guide](https://todealmarket.com/docs/agent-pay)

---

## License

MIT License - see [LICENSE](./LICENSE) for details

---

**Built by the TDM team**

[Website](https://todealmarket.com) • [Documentation](https://todealmarket.com/docs) • [GitHub](https://github.com/todealmarket) • [X/Twitter](https://x.com/todealmarket)

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [ToDealMarket](https://github.com/ToDealMarket)
- **Source:** [ToDealMarket/TDM-Agent-Integration-Kit](https://github.com/ToDealMarket/TDM-Agent-Integration-Kit)
- **License:** MIT
- **Homepage:** https://todealmarket.com/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-todealmarket-tdm-agent-integration-kit
- Seller: https://agentstack.voostack.com/s/todealmarket
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
