# Repository Briefing: superdesigndev/treg
> Source: https://repoforai.com/repo/superdesigndev/treg (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/superdesigndev/treg
- **Official Docs / Website**: https://treg.to
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: Python
- **License**: See repository
- **Engineering Health**: B+ (73/100 · Maintenance 35/35 · Adoption 21/25 · Releases 11/20 · License 6/20)
- **Review Snapshot**: 2026-11-29
- **Deployment / Stack Signals**: MCP, Self-Hosted, API, CLI
- **Momentum**: 10,008 ★ total (+58 24h / +1,149 7d) · 1,058 forks
- **Topics**: `dsh-plugin`, `agents`, `api-keys`, `cli`, `credentials`, `developer-tools`, `mcp`, `proxy`, `python`, `registry`, `secrets`
- **When to Use**: Best for: Teams that want several coding agents to discover and call shared APIs, CLIs, and skills without distributing provider credentials, while optionally using a metered hosted catalog. Skip if: You only need a few stable provider SDKs, require offline execution or a normalized cross-provider API, or cannot operate a credential gateway and verify its licensing terms.

## Overview
```text
### Architecture & Core Mechanics
Treg is a Python service that combines a team tool registry, an MCP surface, and a credential-injecting HTTP proxy. On `/call`, the application resolves a tool by name or by upstream host and longest matching `base_url` prefix, decrypts the selected secrets, applies the tool’s bindings, and hands the request to the upstream relay. A binding can inject a credential into a header or query parameter, and a tool can have several bindings. `proxy.py` handles byte streaming, while the application handles tool selection, settlement, and asynchronous audit recording.

The module boundaries keep transport separate from authentication and tool management. `injectors.py` handles credential placement, `oauth.py` handles consent, code exchange, and single-flight token refresh, and `health.py` probes tools and notifies owners when credentials break. `convert.py` scaffolds skill directories into registrable bundles. The relay preserves provider-specific API shapes rather than translating them into a universal schema. MCP adds a discovery and invocation surface; it does not replace the underlying HTTP API contract.

### Key Capabilities & Differentiators
The hosted catalog supports task-based search and per-endpoint inspection for services spanning SEO, social trends, enrichment, ads, web access, and media generation. `treg catalog get` exposes parameters, pricing, and an example response. Routing prefers a registered team tool, then a stored team provider credential, then a verified public route, and finally a priced call using Treg’s credential and the team’s prepaid balance. Using a team key bypasses Treg metering, not any charges imposed by the upstream provider. An unpriced endpoint is refused when it would otherwise require Treg’s credential.

Teams can register HTTP endpoints, authenticated vendor CLI binaries, and bundles that pair a `SKILL.md` with tools and secrets. `treg scan` previews what would be registered; `treg upload` registers it, and `--replace` updates existing entries. The hosted `/mcp/` surface includes catalog endpoints, team tools, and imported skills. The Claude directory connector at `/mcp/v2/` is narrower: it exposes curated catalog endpoints only, excludes image, video, and audio generation, and separates read from write calls.

### Trade-offs & Limitations
Compared with direct provider SDKs, Treg centralizes credential handling and discovery across agents, but adds a network hop and a privileged intermediary. Because the proxy preserves upstream API shapes, callers still need provider-specific request formats and error handling. Catalog search can show equivalent services and prices side by side, but ordinary calls do not silently select a different vendor or fail over across vendors. Compared with a generic reverse proxy, Treg adds credential bindings, OAuth refresh, catalog discovery, and settlement, at the cost of more state to operate.

Streaming has a specific boundary: when settlement or resource ownership requires checking the response body, the normal path buffers up to 8 MiB and returns an uncharged 502 if the response exceeds that limit. Declared `spooled_response` endpoints use a temporary file and can return the full response after settlement. Eligible free downloads and team-owned calls stream directly. Audit recording is asynchronous; validate its delivery guarantees before relying on it for compliance. The package metadata classifies the license as Other/Proprietary, so confirm the actual `LICENSE` terms before commercial deployment or redistribution.

### Hardware & Deployment Guide
The `tools-registry` package requires Python 3.12 or 3.13. The fastest evaluation path is the Render-hosted `treg.to` service via the CLI or an MCP client. For self-hosting, settings use the `TREG_` prefix; the default database URL is `sqlite+aiosqlite:///./treg.db`, with PostgreSQL intended for production. `TREG_READ_DATABASE_URL` configures an optional read datasource, but queries have to opt into it. Set a persistent `TREG_SECRET_KEY` before storing credentials: the fallback is ephemeral, and those encrypted secrets will not be usable after a restart. During rotation, the first key encrypts and every configured key can decrypt.

Supported configuration also includes AWS Secrets Manager startup settings and a KMS key identifier for stored credentials. Self-hosting moves the registry and proxy into your environment; it does not make external API calls offline or establish access to the hosted catalog’s provider accounts. Size for concurrent upstream requests, database activity, response buffering, and temporary-file I/O rather than GPU capacity. Package metadata identifies version `0.33.0`, while the release list includes `v1.0.0-beta.3` through `v1.0.0-beta.5`. With no release notes supplied, verify the target artifact and its upgrade path rather than assuming those version lines are interchangeable.
```

## Key Capabilities
```text
- Routing: `/call` resolves by tool name or by upstream host and longest `base_url` match.
- Credentials: A single HTTP request can receive multiple server-side bindings, such as an OAuth bearer and a developer-token header.
- Response handling: Evidence-dependent responses use an 8 MiB in-memory path; declared spooled endpoints use temporary files for settlement.
- Credential priority: Team tools and stored provider keys take precedence over verified public routes and metered Treg credentials.
- MCP boundaries: `/mcp/` supports team tools and skills; hosted `/mcp/v2/` is catalog-only, separates reads from writes, and excludes media generation.
- Operations: SQLite is the development default, PostgreSQL is the production option, and a separate read datasource is explicitly opt-in.
```

## Quick Start / Clone
```bash
# 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)
```
