Paperclip MCP is a thin adapter that bridges the Model Context Protocol with the Paperclip control plane REST API. It runs as a stdio server, receives JSON-RPC tool calls from Claude Code (or any MCP host), and translates each call into an authenticated HTTP request — returning structured results the agent can reason about. There is no business logic inside the adapter: every tool is a direct, typed mapping onto one Paperclip API endpoint.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/bruhsb/paperclip-mcp/llms.txt
Use this file to discover all available pages before exploring further.
System diagram
The adapter sits between the MCP host and the Paperclip API. All communication with the host flows over stdio as JSON-RPC; all communication with the API flows over HTTP with a bearer token and optional run ID header.Entry flow
src/index.ts is the executable entry point. It performs three things in order:
Create the MCP Server
Instantiates a
Server from the MCP SDK with { capabilities: { tools: {} } }, declaring that this server exposes tools and nothing else.Register all tools
Calls
registerAllTools(server), which constructs a PaperclipClient, builds a Map<name, ToolDefinition> from ALL_TOOLS, and attaches the tools/list and tools/call request handlers.Key modules
src/index.ts
Entry point. Creates the
Server, calls registerAllTools, connects StdioServerTransport, and provides the top-level fatal error handler.src/tools/index.ts
Tool registry. Owns
ToolDefinition, ToolAnnotations, and ToolResult types. Exports ALL_TOOLS and registerAllTools().src/client.ts
PaperclipClient. Typed HTTP wrapper with get, post, patch, put, delete, and postForm methods. Reads credentials from getAuthConfig() at construction time and enforces AbortSignal.timeout.src/auth.ts
Reads and validates five environment variables at startup. Throws immediately if any required variable is missing — never defers validation to the first API call.
src/errors.ts
Defines
PaperclipApiError with status, statusText, and body properties. Thrown by PaperclipClient.handleResponse on any non-2xx HTTP response.src/tools/validation.ts
Shared helpers imported by every tool handler:
validate(), handleApiError(), toJsonSchema(), composeDescription(), and common Zod schemas.Tool handlers — src/tools/*.ts
Nineteen modules each export an array of ToolDefinition objects. Together they register 104 tools across every Paperclip domain:
| Module | Count | Representative tools |
|---|---|---|
identity.ts | 4 | paperclip_get_me, paperclip_get_inbox, paperclip_get_current_user, paperclip_revoke_current_session |
issues.ts | 7 | paperclip_list_issues, paperclip_get_issue, paperclip_checkout_issue, paperclip_release_issue, paperclip_update_issue |
comments.ts | 3 | paperclip_list_comments, paperclip_add_comment, paperclip_get_comment |
documents.ts | 5 | paperclip_list_documents, paperclip_get_document, paperclip_upsert_document, paperclip_delete_document, paperclip_get_document_revisions |
agents.ts | 17 | paperclip_list_agents, paperclip_create_agent, paperclip_invoke_heartbeat, paperclip_terminate_agent, paperclip_sync_agent_skills |
dashboard.ts | 1 | paperclip_get_dashboard |
approvals.ts | 11 | paperclip_list_approvals, paperclip_create_approval, paperclip_approve, paperclip_reject, paperclip_create_agent_hire |
goals.ts | 4 | paperclip_list_goals, paperclip_get_goal, paperclip_create_goal, paperclip_update_goal |
projects.ts | 8 | paperclip_list_projects, paperclip_create_project, paperclip_list_workspaces, paperclip_create_workspace, paperclip_delete_workspace |
activity.ts | 5 | paperclip_get_activity, paperclip_get_cost_summary, paperclip_get_costs_by_agent, paperclip_report_cost_event |
routines.ts | 9 | paperclip_list_routines, paperclip_create_routine, paperclip_add_routine_trigger, paperclip_run_routine, paperclip_list_routine_runs |
attachments.ts | 4 | paperclip_list_attachments, paperclip_upload_attachment, paperclip_download_attachment, paperclip_delete_attachment |
labels.ts | 2 | paperclip_list_labels, paperclip_create_label |
company.ts | 5 | paperclip_list_companies, paperclip_create_company, paperclip_update_company, paperclip_archive_company |
plugins.ts | 6 | paperclip_list_plugins, paperclip_install_plugin, paperclip_enable_plugin, paperclip_disable_plugin |
secrets.ts | 4 | paperclip_list_secrets, paperclip_create_secret, paperclip_update_secret, paperclip_rotate_secret |
runs.ts | 3 | paperclip_list_heartbeat_runs, paperclip_list_run_events, paperclip_get_run_log |
feedback.ts | 3 | paperclip_list_feedback_traces, paperclip_list_issue_feedback_traces, paperclip_get_feedback_trace_bundle |
company-import.ts | 3 | paperclip_export_company, paperclip_preview_company_import, paperclip_apply_company_import |
ToolDefinition and ToolAnnotations interfaces
These two interfaces are the contract every tool module must satisfy. They are defined insrc/tools/index.ts and re-exported for use in handler modules:
tools/list responses, allowing hosts to surface safety warnings or restrict dangerous tools. All read-only tools set readOnlyHint: true; write tools set destructiveHint and openWorldHint as appropriate.
All tool results share a single shape:
MCP protocol integration
The MCP SDK handles JSON-RPC framing over stdio. The server declares one capability —tools — and registers handlers for two message types.
| Handler | MCP message | What it does |
|---|---|---|
ListToolsRequestSchema | tools/list | Returns name, description, inputSchema, and annotations for every registered tool. Called by the host on startup. |
CallToolRequestSchema | tools/call | Looks up the tool by name, calls its handler, returns ToolResult. Unknown tool name → McpError(MethodNotFound). |
tools/call dispatch sequence:
Name lookup
The registry looks up
request.params.name in toolMap. An unknown name raises McpError(ErrorCode.MethodNotFound).Input validation
The handler calls
validate(Schema, args) (Zod). Invalid arguments throw McpError(ErrorCode.InvalidParams), which the SDK converts to a JSON-RPC error.HTTP call
The handler calls the appropriate
PaperclipClient method (get, post, patch, put, or delete).Authentication flow
Environment variables are injected by the Paperclip runtime before the process starts.src/auth.ts reads and validates them synchronously at startup — there is no deferred validation.
X-Paperclip-Run-Id is injected on all mutating requests (POST, PATCH, PUT, DELETE). The Paperclip API uses it to link each change to the originating run for auditability. Read requests (GET) do not require it.
src/auth.ts reads five environment variables:
| Variable | Required | Purpose |
|---|---|---|
PAPERCLIP_API_KEY | Yes | Short-lived JWT injected per run |
PAPERCLIP_API_URL | Yes | Base URL for the control plane |
PAPERCLIP_AGENT_ID | Yes | Identity of the running agent |
PAPERCLIP_COMPANY_ID | Yes | Company scope for all requests |
PAPERCLIP_RUN_ID | No | Current heartbeat run ID (audit trail) |
Adding a new tool
Create or open a tool module
Add a file under
src/tools/ (or open an existing one for the domain). Group related tools in one file, e.g. src/tools/projects.ts.Register the tool group in src/tools/index.ts
src/index.ts or any other file are needed.Extension points
| What to change | Where |
|---|---|
| Add new tools | src/tools/<module>.ts + ALL_TOOLS in src/tools/index.ts |
| Switch transport (stdio → HTTP/WS) | src/index.ts — swap StdioServerTransport |
| Add auth schemes (OAuth, token refresh) | src/auth.ts and src/client.ts |
| Richer error responses | Catch PaperclipApiError in handlers and return structured isError result |
| Custom timeout enforcement | Set PAPERCLIP_REQUEST_TIMEOUT_MS; PaperclipClient reads it at construction time |