## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - App connectors let agents interact with external tools, suites, REST APIs, and chat channels under instance governance > - `doc/connections/CONNECTOR-PLAYBOOK.md` grew to 2,968 lines (171 KB) and accumulated stale guidance on `rest_api` adapters and setup UX, with no upfront research-and-interview gate to aim new connectors at user expectations > - An autonomous agent cannot reliably build a new connector in one command when the playbook mixes every track together and defaults blindly to remote MCP > - This pull request splits the playbook into a concise router plus six load-on-demand track guides and adds the `.agents/skills/create-connector` skill > - The benefit is that agents and contributors audit official vendor docs up front, recommend the right architecture track, and load only the guidance needed for that connector ## Linked Issues or Issue Description **Issue type** Outdated (no longer matches behavior) **Where is the issue?** `doc/connections/CONNECTOR-PLAYBOOK.md`, `doc/connections/README.md`, `.agents/skills/create-connector/` **What's wrong?** `doc/connections/CONNECTOR-PLAYBOOK.md` was a 2,968-line monolith that still claimed `rest_api` is not exposed through the gateway (despite `rest-registry.ts`, `browser-use-cloud`, and `google-workspace-rest-tools`), contradicted itself on one-screen setup vs. a two-step Access → Connect flow, and jumped straight into MCP endpoint probing without an official-docs feasibility audit or product alignment interview. **Suggested fix** Refactor `CONNECTOR-PLAYBOOK.md` into a short canonical router + universal invariants contract, move track-specific details into `doc/connections/tracks/`, and add `.agents/skills/create-connector/` with a mandatory Research-First → Proactive Recommendation & Interview gate. ## What Changed - Refactored `doc/connections/CONNECTOR-PLAYBOOK.md` from 2,968 lines to 184 lines (Phase 0 official-docs feasibility audit & interview, 6-track selection matrix, universal invariants, canonical one-screen setup UX, production validation matrix, preserved inbound anchors). - Created six focused track guides and one deep reference under `doc/connections/tracks/`: - `remote-mcp.md` (Track A) - `rest-adapter.md` (Track B) - `managed-oauth-suite.md` (Track C) - `connector-skills.md` (Track D) - `chat-channel.md` (Track E) - `local-and-aggregators.md` (Track F) - `app-definition-reference.md` (field reference, troubleshooting, provider attribution, proposal template) - Added `.agents/skills/create-connector/SKILL.md` and `.agents/skills/create-connector/brief-template.md` implementing the one-command connector workflow with three explicit human Stop Gates. - Updated `doc/connections/README.md` to link the modular playbook, track guides, and `create-connector` skill. ## Verification - Verified all relative markdown links across all 11 created/modified files resolve to existing files with zero broken links. - Verified `git diff --check` passes cleanly on all modified and added files. - Confirmed all existing inbound anchors to `CONNECTOR-PLAYBOOK.md` (`#step-9-align-with-production-validation`, `#chat-channel-connectors`, `#question-experience-inventory`, `#retain-inspectable-per-format-evidence`) remain intact. ## Risks - Low risk: documentation and agent-skill changes only; no runtime, schema, or UI code is modified. ## Model Used - Google Gemini (Antigravity agentic coding assistant, tool use and code execution enabled) ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
6.7 KiB
Track B: Reviewed Native REST Adapter
Use this track when an official remote HTTP MCP server does not exist, is desktop/local-only, is preview/unreliable, or fails to cover the core read/write jobs users expect — while the provider offers a well-documented HTTPS REST API.
Hard rule: Setting
transport: "rest_api"in anAppDefinitionnever enables arbitrary HTTP execution. Only reviewed adapters registered inserver/src/services/connectors/rest-registry.ts(or a dedicated reviewed adapter such asbrowser-use-cloudorgoogle-workspace-rest-tools) execute through the connection gateway.
Existing Reference Implementations
- Standard REST registry adapters:
server/src/services/connectors/supabase/andserver/src/services/connectors/vercel/, registered inserver/src/services/connectors/rest-registry.ts. - Dual-transport (MCP + REST fallback/migration):
server/src/google-workspace-rest-tools/(GOOGLE_WORKSPACE_TOOL_TRANSPORT). - Stateful REST adapter + live UI pane + bundled skill:
server/src/services/connectors/browser-use-cloud/(see BROWSER-USE.md).
When to Choose Track B Over Track A
Choose Track B during the upfront Connector Brief when:
- The vendor has a stable REST API (e.g., Microsoft Graph, Figma REST, Supabase Management API, Vercel REST) and either no hosted MCP or a hosted MCP that is read-only / severely incomplete for the agreed top 3–5 user jobs.
- Users need deterministic, strict-schema actions with clear risk classification (
readvswritevsdestructive), byte limits, and redaction guarantees that an upstream MCP does not provide. - The connection needs custom probe/health checks that do not trigger paid work or side effects.
Keep the initial toolset tight and job-focused (typically 5–15 high-value tools covering the agreed user jobs) rather than wrapping 200 raw API endpoints.
Module & Registry Contract
Keep all provider-specific endpoints, schemas, payload shaping, and error translation inside server/src/services/connectors/<provider>/ (per rules/module-boundaries.mdc). Shared gateway code stays provider-agnostic and owns grants, policy, approvals, rate limits, and audit.
Every standard REST adapter implements RestConnector in server/src/services/connectors/rest-registry.ts:
interface RestConnector {
sourceTemplateKey: string;
name: string;
matches(connection: Connection): boolean;
tools: Array<{
name: string;
title?: string | null;
description?: string | null;
inputSchema?: Record<string, unknown>;
annotations?: Record<string, unknown>;
}>;
risk(name: string): ToolRiskLevel;
isCurrent(entry: CatalogEntry): boolean;
client(
connection: Connection,
headers: Record<string, string>,
request: Request,
signal?: AbortSignal,
deadlineAt?: number,
): {
probe(): Promise<unknown>;
invoke(name: string, parameters: unknown): Promise<unknown>;
};
}
Mandatory Adapter Invariants
- Pinned base URLs & strict path validation: Never let agent arguments supply arbitrary URLs, hostnames, or path traversals (
..). Validate every ID/slug/ref with strict Zod regexes and.strict()schemas before constructing URLs. - Safe, cheap
probe(): Health checks and setup verification must execute one narrow, read-only, zero-cost API call (e.g., current user/profile, project metadata, or workspace list) using the resolved credential headers. Never trigger paid work or writes duringprobe(). - Explicit risk classification & schema hashing:
- Classify every tool explicitly in
risk(name)(read,write,destructive) and mirror it inannotations(readOnlyHint,destructiveHint). - Compute deterministic
descriptorHash/stableHash(server/src/services/tool-catalog-hash.ts) soisCurrent(entry)detects tool-schema changes cleanly for quarantine/review.
- Classify every tool explicitly in
- Bounded responses & redaction:
- Enforce a hard response byte ceiling (e.g.,
2 MiB) and respectsignal/deadlineAttimeouts. - Pass error messages through
redactSensitiveText(server/src/redaction.ts); never echo raw credentials or untrusted provider error bodies containing tokens. - Mark secret-bearing input fields in schemas so gateway argument summaries redact them and never return them.
- Enforce a hard response byte ceiling (e.g.,
- Untrusted content / prompt-injection screening: When tools return external user-authored content (emails, comments, docs, tickets, meeting notes), route results through Paperclip's prompt-injection guard where applicable (see GOOGLE-WORKSPACE.md and
doc/prompt-injection-prevention.md). - Resource boundary enforcement: If the
AppDefinitiondeclarestenantFields(e.g.,projectRef,teamId,siteId), read them fromconnection.config.methodConfigin the adapter and enforce them on every API call so an agent cannot pivot to another project/team.
Catalog, Auth, and UX Pairing
A Track B adapter still ships through the standard catalog pipeline:
- Official branding in
ui/public/brands/apps/+manifest.json(CONNECTOR-ICONS.md). - Reviewed
AppDefinitionwithtransport: "rest_api", auth mode (oauthorapi_key),tenantFields/credentialFields, and entry indoc/connections/tool-method-permission-reviews.json. - If OAuth requires a Paperclip-owned fixed-callback app, pair this track with Track C: Managed OAuth & Multi-Service Suites.
- If agents need standing workflow guidance to chain the REST tools effectively, pair with Track D: Connector-Provided Skills & Agent Instructions.
Verification Checklist (Track B Specific)
In addition to the universal verification ladder in CONNECTOR-PLAYBOOK.md:
- Unit tests (
server/src/services/connectors/<provider>/):- Every tool's valid input, invalid/traversal input rejection, and
.strict()unknown-key rejection. - Exact outbound URL, HTTP method, headers, and timeout/abort handling using mocked
request. - Oversized response truncation/rejection and credential redaction on 4xx/5xx provider errors.
- Resource boundary enforcement (configured
projectRef/teamIdcannot be overridden by caller args). risk(name)andisCurrent(entry)parity for every exported tool.
- Every tool's valid input, invalid/traversal input rejection, and
- Gateway & policy tests: Confirm
restConnectorFor(connection)resolves the adapter, catalog refresh populates all tools with expected risk levels, writes respect Ask-first/Off policy, and company B cannot invoke company A's connection. - Live proof: Run
probe(), one safe read tool, and (on a disposable resource) one write tool through a real run-scoped gateway, then revoke and verify immediate fail-closed behavior.