Add standalone Paperclip MCP server package

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-04-06 07:17:48 -05:00
parent 08fea10ce1
commit 8cdba3ce18
12 changed files with 902 additions and 0 deletions

View file

@ -0,0 +1,39 @@
export interface PaperclipMcpConfig {
apiUrl: string;
apiKey: string;
companyId: string | null;
agentId: string | null;
runId: string | null;
}
function nonEmpty(value: string | undefined): string | null {
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
}
function stripTrailingSlash(value: string): string {
return value.replace(/\/+$/, "");
}
export function normalizeApiUrl(apiUrl: string): string {
const trimmed = stripTrailingSlash(apiUrl.trim());
return trimmed.endsWith("/api") ? trimmed : `${trimmed}/api`;
}
export function readConfigFromEnv(env: NodeJS.ProcessEnv = process.env): PaperclipMcpConfig {
const apiUrl = nonEmpty(env.PAPERCLIP_API_URL);
if (!apiUrl) {
throw new Error("Missing PAPERCLIP_API_URL");
}
const apiKey = nonEmpty(env.PAPERCLIP_API_KEY);
if (!apiKey) {
throw new Error("Missing PAPERCLIP_API_KEY");
}
return {
apiUrl: normalizeApiUrl(apiUrl),
apiKey,
companyId: nonEmpty(env.PAPERCLIP_COMPANY_ID),
agentId: nonEmpty(env.PAPERCLIP_AGENT_ID),
runId: nonEmpty(env.PAPERCLIP_RUN_ID),
};
}