diff options
Diffstat (limited to 'apps/mcp/src/shared.ts')
| -rw-r--r-- | apps/mcp/src/shared.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/mcp/src/shared.ts b/apps/mcp/src/shared.ts new file mode 100644 index 00000000..69672769 --- /dev/null +++ b/apps/mcp/src/shared.ts @@ -0,0 +1,34 @@ +import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import { CallToolResult } from "@modelcontextprotocol/sdk/types"; + +import { createHoarderClient } from "@karakeep/sdk"; + +const addr = process.env.KARAKEEP_API_ADDR; +const apiKey = process.env.KARAKEEP_API_KEY; + +export const karakeepClient = createHoarderClient({ + baseUrl: `${addr}/api/v1`, + headers: { + "Content-Type": "application/json", + authorization: `Bearer ${apiKey}`, + }, +}); + +export const mcpServer = new McpServer({ + name: "Karakeep", + version: "0.23.0", +}); + +export function toMcpToolError( + error: { code: string; message: string } | undefined, +): CallToolResult { + return { + isError: true, + content: [ + { + type: "text", + text: error ? JSON.stringify(error) : `Something went wrong`, + }, + ], + }; +} |
