Reviewed-on: #1 Co-authored-by: Timo Behrendt <t.behrendt@t00n.de> Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
29 lines
940 B
TypeScript
29 lines
940 B
TypeScript
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
|
import { handleSuccess, handleError } from "./utils";
|
|
|
|
import type { ToolsFactory } from "./toolsFactory";
|
|
import type { CollectionsApi } from "../gen/api/outline";
|
|
import type { Logger } from "pino";
|
|
|
|
export const registerCollectionTools: ToolsFactory<CollectionsApi> = (server: McpServer, client: CollectionsApi, logger: Logger) => {
|
|
server.registerTool(
|
|
"collections_list",
|
|
{
|
|
title: "List Collections",
|
|
description: "List all collections in the Outline workspace",
|
|
inputSchema: {},
|
|
},
|
|
async () => {
|
|
try {
|
|
const response = await client.collectionsList();
|
|
return handleSuccess(response, logger.child({ tool: "collections_list" }));
|
|
} catch (err) {
|
|
const error = handleError(err, logger.child({ tool: "collections_list" }));
|
|
logger.error(error);
|
|
return error;
|
|
}
|
|
}
|
|
);
|
|
};
|