mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 02:40:39 +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
31
packages/mcp-server/src/format.ts
Normal file
31
packages/mcp-server/src/format.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { PaperclipApiError } from "./client.js";
|
||||
|
||||
type McpTextResponse = {
|
||||
content: Array<{ type: "text"; text: string }>;
|
||||
};
|
||||
|
||||
export function formatTextResponse(value: unknown): McpTextResponse {
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: typeof value === "string" ? value : JSON.stringify(value, null, 2),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export function formatErrorResponse(error: unknown): McpTextResponse {
|
||||
if (error instanceof PaperclipApiError) {
|
||||
return formatTextResponse({
|
||||
error: error.message,
|
||||
status: error.status,
|
||||
method: error.method,
|
||||
path: error.path,
|
||||
body: error.body,
|
||||
});
|
||||
}
|
||||
return formatTextResponse({
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue