mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 19:00:38 +09:00
Add standalone Paperclip MCP server package
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
08fea10ce1
commit
8cdba3ce18
12 changed files with 902 additions and 0 deletions
39
packages/mcp-server/src/config.ts
Normal file
39
packages/mcp-server/src/config.ts
Normal 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),
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue