treg README

The project's README from github.com/superdesigndev/treg. As one markdown file: README.md.

Treg (OpenRouter for Tools)

treg — the tool catalog for your agent

OpenRouter, but for agent tools instead of models. Point an agent at one base URL with one token and it can do the job: 3,000+ catalogued endpoints across 60+ providers — SEO and backlinks, social and trends, people and company enrichment, ads, scraping, image and video generation — priced per call, from a cent, with no provider signup. Plus your own team's keys, skills and CLIs, callable by every teammate's agent without the credential ever leaving the server.

Ask for the task, not the tool. You do not need to know which vendor sells backlink data, or to hold an account with them. Search for what you want to do, read the price, call it.

Built for the Superdesign team, live at treg.to — anyone can self-host.

Why it exists

The tools an agent needs for real work sit behind subscriptions nobody buys for a single run — Semrush $139/mo, Moz $99/mo, Crunchbase $99/mo, Apollo $59/seat — behind signup walls, or behind no public API at all (invite-only, partner-only, app-review-only). treg carries those accounts and bills fractions of a cent per call.

Two kinds of tool, one token

The vocabulary for the second half:

The one rule: the proxy relays, never models the upstream, and injects auth server-side — so it survives upstream API changes and callers never hold keys.


Part 1 · Using the registry

Visit treg.to (hosted on Render) — the dashboard, sign-in, and every URL below live there.

Quickstart

Same flow as the dashboard's Getting started guide:

# 1. install the CLI — also points it at the registry
curl -fsSL https://treg.to/install.sh | sh

# 2. sign in (GitHub default · --email for a one-time code · --token for agents/CI)
treg login

# 3. do something useful immediately — no key, nothing registered
treg catalog search "backlinks for a domain"     # find a tool by what it DOES
treg call tikhub.tiktok.user.profile --query uniqueId=tiktok
treg balance                                     # exactly what that cost

# (or `treg onboard` for the guided walkthrough)

Fish Audio provides S2.1 Pro speech, public-voice discovery, and private voice cloning. Speech is binary stdout, so redirect it to a file. A discovered voice's _id or a team voice id is the TTS reference_id; voices created on treg's Fish account are durable team resources:

treg call fishaudio.tts.s2-1-pro --method POST --header model=s2.1-pro \
  --data '{"text":"Hello from treg","format":"mp3"}' > speech.mp3
treg call fishaudio.voices.discover --query self=false --query licensed=false --query language=en
treg resources list --provider fishaudio --kind voice

With your own Fish key, requests remain an unrestricted, unmetered upstream relay and Fish owns the account boundary.

Catalog tool inputs are described by treg catalog get <id>. Tools marked strict_query reject undeclared or repeated query parameters, unsupported values and request bodies.

Your token identifies you on every call (X-Treg-Token header) and is the same for all tools. Discover what your team has shared: treg tool ls · check credential health: treg health.

Or install it as a Claude Code plugin

/plugin marketplace add superdesigndev/treg
/plugin install treg@treg

Installs with no token and no configuration. The skill loads as treg:treg and, on its first run, walks your agent through the rest — the CLI, sign-in, then treg mcp install — so you end up with the command line and treg's tools. Other agents: npx skills add superdesigndev/treg -s treg (the -s matters — without it you also get this repo's internal dev skills). See docs/CLAUDE-PLUGIN.md. MiniMax Code / MiniMax Agent users: the same skill ships via the MiniMax Plugin Marketplace (docs/MINIMAX-PLUGIN.md).

Claude.ai connector

The Claude Connectors Directory surface is https://treg.to/mcp/v2/. It exposes only curated catalog endpoints and separates read calls from write calls so Claude receives accurate safety signals. The existing /mcp/ surface remains available for catalog endpoints, team-owned tools, and imported skills. See the MCP and OAuth architecture for the boundary and implementation, and the submission runbook for release gates.

Call a tool you don't have a key for

The catalog is grouped by what endpoints do: keyword and rank tracking, backlinks and authority, AI visibility, trending and discovery, publishing to socials, people and company enrichment, ads management and creative, measurement.

treg catalog                                    # every platform, busiest first
treg catalog search "find a work email"         # by the job, not the vendor
treg catalog get hunter.people.email.find       # params, PRICE, example response
treg call hunter.people.email.find --query domain=reddit.com --query full_name="Alexis Ohanian"

How a catalogued call is served — the credential ladder, in order:

  1. your team registered its own tool for that provider → that tool, that key;
  2. your team stored a secret for the provider → injected through a virtual tool;
  3. neither, and the endpoint has a verified public route → no provider key, free;
  4. otherwise → treg's own key, billed to the team's prepaid balance.

The anonymous price assumes the caller does not send a provider credential header. The faithful relay preserves caller headers, so a caller-supplied provider key can use that key's credits. Your own credential always beats treg's, so connecting a key you already pay for makes those calls free of the balance rather than duplicating them. An endpoint treg has no published price for is refused, not served free — you are told to connect your own key instead. Where several providers serve one capability, treg catalog search shows them side by side with prices; choosing is yours — treg does not silently pick or fail over between providers for you. (When treg's own account for a provider is out it may serve the same endpoint through a treg-owned relay account, disclosed on the response; a team can opt out.) The exception you opt into: treg.<capability> routed endpoints, where treg picks the provider for you and names it.

treg balance          # credit left, calls in flight, recent spend
treg topup            # add funds, or set up automatic top-ups

Out of balance is an HTTP 402 carrying balance_micro, estimated_cost_micro and a topup_url, so an agent can act on it without reading prose.

Enrich Arena lives at /enrich-arena, outside the dashboard. Compare enrichment answers with each vendor’s cost and speed, vote for the best answer in one click, or watch a sequential waterfall. Browsing is public; submitting requires login, and billable attempts use your team's credits. See the Arena guide.

Share & use your own tools

The zero-thought path — point treg at a project and it figures out what's shareable:

treg scan     # read-only preview: the keys, skills & CLIs upload would register
treg upload   # register them (encrypted server-side); idempotent, --replace to update

treg upload scans the .env (matching keys against ~80 known providers), every skill subdirectory, and installed catalog CLIs. Three kinds of things go into the registry — here's how to share and use each:

1. Endpoints (HTTP APIs)

Share — one upstream URL callable with a stored key, or bulk from a .env:

treg secret add STRIPE_KEY --value sk_live_123
treg add stripe --base-url https://api.stripe.com --secret STRIPE_KEY

treg upload env --select openai,stripe,resend     # or straight from the .env

Use — the agent-native way: build the real upstream request and prefix it with the proxy. treg resolves the tool by host, injects the credential, and relays everything else faithfully (your X-Treg-Token is stripped before the upstream sees it):

Real request:   GET https://api.intercom.io/conversations?per_page=5
Through treg:   GET https://treg.to/call/https://api.intercom.io/conversations?per_page=5
                    header:  X-Treg-Token: <your token>

Or the CLI shorthand — and treg calls for the audit log:

treg call intercom conversations --query per_page=5
treg call stripe v1/balance

2. CLIs

Share — automatic: treg upload detects installed catalog CLIs (stripe, gh, vercel, …) and registers them; a recipe-only catalog CLI skill (e.g. stripe-cli) auto-becomes runnable too.

Use — treg run executes the vendor CLI with the org's credential injected, so you never hold the key or log in:

treg run stripe -- get /v1/balance
treg run gh -- pr list
treg run --server agentmail-cli inboxes list   # runs on the registry server: the key never reaches you

--local (default) runs on your machine; --server runs on the registry and streams output back. For a whole session, treg shell start opens a subshell where every registered CLI injects automatically — just use stripe, gh, … normally; exit reverts. treg runs is the audit log.

3. Skills

Share — a skill is a whole capability (SKILL.md recipe + its secrets + its tool(s)), registered together so the whole team runs the same skill, maintained in one place:

treg upload skills --dir ~/.claude/skills --all   # register a folder of skills in one pass

Use — pull any shared skill into your agent; its API calls go through treg with your token, so the key stays on the server, never in the skill:

treg skill install seo-blog-writer      # writes into ./.claude/skills/  (--all for the library)

Manual registration — when the heuristics can't figure a tool out

# multi-credential tool (e.g. google-ads: OAuth bearer + a developer-token header)
treg tool add google-ads --base-url https://googleads.googleapis.com \
  --bind "secret=<oauth-id>,injector=oauth" \
  --bind "secret=<dev-id>,name=developer-token,format={secret}"

# one skill, step by step
treg skill init --dir ./my-skill          # drafts treg.json (guesses base_url, finds secrets)
treg skill add  --dir ./my-skill          # registers recipe + secrets + tool, atomically

# OAuth via the browser (mints the first token, treg holds it and auto-refreshes)
treg oauth connect gsc --client-secret client_secret.json \
  --scopes https://www.googleapis.com/auth/webmasters.readonly

Full options for every command: USAGE.md.

The CLI sends anonymous command usage to PostHog when using treg.to (no arguments or credentials). Disable with TREG_TELEMETRY=0 or DO_NOT_TRACK=1. See analytics details.

Teams

An account can own up to 10 teams. Joining other teams as a member does not count toward this limit.

Everything is scoped to an org: a token = a (user, org) membership, and every secret, tool, and skill belongs to the active org. Roles: owner / admin / member / viewer.

treg org create "Acme"                        # make a team, become owner
treg org invite [email protected]             # invite by email (pick role + tool access)
treg org join <code> --email [email protected]     # accept an invite (creates you if new)
treg org ls | use <slug> | members            # switch orgs, see the roster
treg org access <member> --tools a,b          # per-member tool access (admin+)

Going deeper


Part 2 · Self-hosting & development

Run it locally

One command (needs tmux + uv; it syncs the venv itself):

scripts/dev-local.sh up        # server on http://localhost:18790, dev-safe settings

That runs the server in tmux with hot-reload, its own sqlite DB (treg-dev.db), and email OTP dev mode (sign-in codes shown on the page — no mail sender needed). Day-to-day:

scripts/dev-local.sh cli login   # sandboxed CLI: never touches your real ~/.treg/config.json
scripts/dev-local.sh logs        # server output          · status / restart / down
scripts/dev-local.sh reset       # wipe the dev DB + CLI sandbox for a fresh start

Or run the server directly, without tmux:

bash scripts/build-dashboard.sh # Node 22.12+ and npm; build the Dashboard
uv sync                        # create the venv from uv.lock (pulls the server deps for dev)
uv run python -m treg upgrade  # prepare schema + run idempotent release tasks without serving
uv run python -m treg          # serve on 0.0.0.0:18790 (add --reload for dev)
uv run python -m treg keygen   # print a fresh Fernet key for TREG_SECRET_KEY

Installing to run a server (not from source): the base package is the CLI only. To run a registry, install the server extra — pip install "tools-registry[server]" — which adds FastAPI, the database drivers, and encryption. pip install tools-registry alone gives just the treg command for talking to an existing registry.

The official hosted service is available at treg.to. Its production topology and live settings are maintained in the private operator runbook.

Configuration

Environment variables (prefix TREG_, read from .env):

Var Default Purpose
TREG_DATABASE_URL sqlite+aiosqlite:///./treg.db DB URL (SQLite for dev, Postgres in prod)
TREG_READ_DATABASE_URL (empty) Optional SQLite / PostgreSQL read datasource; empty reuses the primary. Requires callers to opt in; existing queries are unchanged. See read datasource setup.
TREG_SECRET_KEY (empty) Fernet key for secrets-at-rest; empty → an ephemeral key is minted (secrets won't survive a restart)
TREG_PUBLIC_URL https://treg.to treg's public base, used to build the OAuth callback URI
TREG_SESSION_SECRET (empty) signs the dashboard session cookie; falls back to TREG_SECRET_KEY. Set a real value in prod
TREG_GITHUB_CLIENT_ID / _SECRET (empty) GitHub OAuth sign-in (callback <public_url>/auth/github/callback); empty hides the button
TREG_GOOGLE_CLIENT_ID / _SECRET (empty) Google OAuth sign-in (redirect <public_url>/auth/google/callback); empty hides the button
TREG_INSTAGRAM_CLIENT_ID / _SECRET (empty) Instagram App ID and secret for direct Instagram Login (redirect <public_url>/oauth/callback)
TREG_META_CLIENT_ID / _SECRET (empty) Meta app credentials for Facebook Pages, Meta Ads, and optional Instagram page-tools
TREG_OAUTH_REVIEW_PENDING instagram-login,page-messages Comma-separated registry review keys whose capabilities must remain gated; hosted review state is maintained privately.
TREG_RESEND_API_KEY / TREG_EMAIL_FROM (empty) transactional email via Resend (OTP codes + invites); From must be a Resend-verified sender
TREG_BLOCKED_EMAIL_DOMAINS (empty) comma-separated email domains refused at every sign-up/sign-in door and at team creation (subdomains included, case-insensitive). Empty blocks nothing — no list ships in the code
TREG_ADMIN_TOKEN (empty) cross-tenant super-admin bearer; authorizes every /admin/* endpoint. Empty disables the env path (only is_superadmin users reach /admin). Keep it long + secret.
TREG_EMAIL_DEV_MODE false when true, /auth/email/start returns the OTP in its response (no mail sender needed) — dev/local only, never in prod.
TREG_KV_URL (empty) shared key-value store (Redis protocol) for counters every worker must agree on, today the per-team review-invitation budget. Empty = an in-process fallback, fine for one worker

No .env is needed for local dev — every setting has a working default (ephemeral key, sqlite).

⚠️ Back these up before moving or redeploying: the Fernet key (TREG_SECRET_KEY) and the database (Postgres in prod; treg.db for a local sqlite run). Lose the Fernet key and every stored secret becomes unrecoverable.

Architecture

Request flow for /call: resolve tool (by URL host + longest base_url prefix, or by name) → decrypt its secret(s) → apply each binding's injector → stream to the upstream → fire-and-forget audit record. The infra relay streams bytes without business logic. The call application buffers responses needing settlement or ownership evidence up to 8 MiB; larger responses return a 502 without charging instead of a truncated success. Authorized free final downloads needing no body evidence stream in full, as do own-key and own-tool responses.

Module map (src/treg/):

Module Role
proxy.py relay() — the whole product in one function: a faithful streaming proxy
injectors.py the auth-shape seam: env, cli_auth, secret_file, oauth place a secret into a header/query
oauth.py token freshness (single-flight refresh) + the connect flow (consent URL, code exchange)
health.py credential health: refresh oauth, probe tools, webhook the owner of anything broken
convert.py scaffold a skill directory into a registerable bundle manifest
api.py the API — the only brain; CLI + skill are thin clients over it
cli.py the treg CLI
models.py SQLModel tables: Org, User, Membership, Invite, Secret, Tool, Bundle, PendingOAuth, CallRecord
crypto.py config.py db.py audit.py Fernet encryption + tokens · settings · async DB · deferred audit writer

The 4 auth shapes (per binding injector): env (plain string / API key) · secret_file (a JSON token file, pull a field) · oauth (a JSON OAuth token, auto-refreshed if refreshable) · cli_auth (material lifted from a CLI's keychain).

Faithful-relay contract: the proxy alters only three things, everything else is verbatim:

  1. hop-by-hop transport headers (re-derived per hop),
  2. treg's own control + edge-forwarding headers (x-treg-token, x-treg-org, ngrok-skip-browser-warning, x-forwarded-*, via, …) and treg's session cookie — all stripped, never leak upstream,
  3. the injected credential(s).

OAuth, three ways to get the first token: manual upload (drop in a token.json) · auto-refresh (if the token carries refresh_token + client creds, treg keeps it fresh, you never re-upload) · hosted connect flow (treg oauth connect → browser consent → treg captures the token itself).

Health checks: give a tool an optional probe ({method, path, expect_status}); a periodic run (on demand or via cron) validates every credential, refreshes OAuth, and webhooks the owner of any that break.

Deep design lives in docs/context/ (per-subsystem fragments).

Tests

uv run --with pytest-xdist pytest -n auto -q   # daily local default (same shape as CI)
uv run --frozen python -m pytest -q            # serial: debugging one test, or order

Coverage: proxy walking-skeleton, all injector shapes, per-user auth + CRUD + audit, skill composer, URL-passthrough + faithful relay, OAuth refresh + connect flow, health checks, treg run/shell, upload/scan, orgs + invites, the dashboard API, CLI.

Contributing & docs

treg/
├── src/treg/            # the package (api, cli, proxy, injectors, oauth, health, convert, models, …)
│   └── web/             # dashboard, landing, tutorial, llms.txt, skill.md, install.sh
├── tests/               # pytest suite (CI + local default: pytest-xdist -n auto)
├── docs/
│   ├── context/         # design fragments (codemap system) + generated index
│   └── ONBOARDING.md    # first-time bootstrap
├── USAGE.md             # full treg CLI reference
└── pyproject.toml

Per-subsystem design docs are fragments in docs/context/, each citing its src/treg/* sources. Working in this repo with an AI agent? The /tools-registry-context skill loads the right fragment for what you're touching and keeps the docs in sync — run /tools-registry-context sync before pushing.

Roadmap: MCP support · finer permission tiers · at-rest key-management hardening · possible Loopni merge.

License

Apache 2.0 with additional terms (LICENSE): use it freely — including commercially, inside your own organization (self-hosting your own registry is encouraged). The restriction: don't redistribute the code to third parties as a competing hosted/managed registry service without written permission ([email protected]). Using the hosted treg.to API inside your own product — with pass-through billing via X-Treg-Meta and usage/by-tag — is allowed without permission; that's calling our API, not redistributing our software.

Pinned customer read scopes

For a restricted customer agent, treg org agent-new bot --pin customer=cust_A enforces attribution and scopes call/run history, archived results and shared-provider async ownership to that pin. Foreign or unattributed ids return 404; an unpinned operator keeps the org-wide view and shared balance. BYOK account access and public media URLs retain their existing permissions. See the multi-tenancy contract for multiple pins, migration and replay behavior.

treg (superdesigndev/treg)

Searching Database…

5.7K ·GitHub
这是什么?Treg 是 agent 工具领域的 OpenRouter:只需一个基础 URL 和一个 token,agent 就能调用 60 多家服务商的 3000 多个编目端点——涵盖 SEO、数据增强、广告、爬虫、图像和视频生成——还能用上你们团队自己的密钥、技能和 CLI。
这是托管服务、命令行工具,还是我自己跑的东西?三种都是。带控制台和登录功能的托管注册中心在 treg.to,pip 包提供 treg CLI,而 server 扩展(FastAPI、数据库驱动、加密)让你可以把整个注册中心自己部署。
我怎么把我的编程 agent 接上去?把它作为 Claude Code 插件安装——不需要 token 或配置;然后 treg:treg 技能会引导你的 agent 完成登录和 treg mcp install。其他 agent 则运行 npx skills add superdesigndev/treg -s treg。
使用这个目录,我需要注册 Semrush 或 Fish Audio 这类服务商的账号吗?不需要。每次调用都会按凭据阶梯逐级尝试:先是你团队注册的工具,然后是已保存的密钥,接着是经过验证的公共通道(免费、无需服务商密钥),最后用 treg 自己的密钥,费用计入你们团队的预付余额。
目录调用要花多少钱,预付余额用完了会怎样?按次计费,低至一美分,新注册的验证账号一次性获赠 1.00 美元免费额度。付不起的调用会返回 HTTP 402,附上当前余额、预估费用和充值链接;没有公布价格的端点会被直接拒绝,而不是免费提供服务。
我的整个团队能共用一个注册中心吗,还是只能我自己用?它天生就是面向团队的:一切都以组织(org)为范围——一个 token 代表一个用户-组织成员关系——设有 owner、admin、member 和 viewer 角色,每个密钥、工具和技能都属于当前的组织。一个账号最多可以拥有 10 个团队。
如果我们团队通过 treg 共用一个付费 API 密钥,这个密钥会离开服务器吗?不会——鉴权是在服务器端注入的,代理只忠实地转发请求,所以调用方拿不到密钥,凭据始终留在注册中心里。你自己的密钥优先级永远高于 treg 的,而且调用你自己的工具不会被计量计费。
我怎么把自己的工具、CLI 和技能分享给队友?运行 treg upload:它会扫描你的 .env(对照约 80 家已知服务商)、每个 skill 子目录以及已安装的目录类 CLI,把端点、CLI 或整个技能(一份 SKILL.md 配方加上它的密钥和工具)注册上去。
作者为什么不直接买 Semrush 或 Apollo,而要开发这个?干活用的工具都藏在没人会为一次调用而购买的订阅后面——Semrush 每月 139 美元、Moz 每月 99 美元、Crunchbase 每月 99 美元、Apollo 每席位每月 59 美元——或者要求注册,甚至根本不提供公开 API。treg 替你承载这些账号,每次调用只收几分之一美分。
treg shell start 是什么?它会打开一个子 shell,其中每个已注册的 CLI——比如 stripe、gh、vercel 等——都会自动注入组织凭据,所以你不用登录就能正常使用它们。退出后一切恢复原状,treg runs 就是审计日志。
自己部署需要什么?一条命令,前提是装好 tmux 和 uv:它会自己同步 venv,并在 tmux 里以热重载方式运行服务器,使用本地 sqlite 数据库,还有邮箱 OTP 开发模式——登录验证码直接显示在页面上。生产环境通常用 Postgres。
Size
98.1 MB
Stars
5.7K
Updated
CommitOct 17
Age
3mo
Commits · 90 Days