This commit is contained in:
@@ -1,22 +1,45 @@
|
||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import { z } from "zod";
|
||||
|
||||
import { backlinkDocumentId, collectionId, direction, limit, offset, parentDocumentId, sort, userId } from "./common";
|
||||
import { handleSuccess, handleError } from "./utils";
|
||||
|
||||
import type { ToolsFactory } from "./toolsFactory";
|
||||
import type { DocumentsApi } from "../gen/api/outline";
|
||||
import type { Logger } from "pino";
|
||||
|
||||
export const registerDocumentTools: ToolsFactory<DocumentsApi> = (server: McpServer, client: DocumentsApi, logger: Logger): void => {
|
||||
import {
|
||||
backlinkDocumentId,
|
||||
collectionId,
|
||||
direction,
|
||||
limit,
|
||||
offset,
|
||||
parentDocumentId,
|
||||
sort,
|
||||
userId,
|
||||
} from "./common";
|
||||
import { handleSuccess, handleError } from "./utils";
|
||||
import type { ToolsFactory } from "./toolsFactory";
|
||||
import type { DocumentsApi } from "../gen/api/outline";
|
||||
|
||||
export const registerDocumentTools: ToolsFactory<DocumentsApi> = (
|
||||
server: McpServer,
|
||||
client: DocumentsApi,
|
||||
logger: Logger
|
||||
): void => {
|
||||
server.registerTool(
|
||||
"documents.info",
|
||||
"documents_info",
|
||||
{
|
||||
title: "Get Document Info",
|
||||
description: "Retrieve a document by its UUID, urlId, or shareId. At least one of these parameters must be provided.",
|
||||
description:
|
||||
"Retrieve a document by its UUID, urlId, or shareId. At least one of these parameters must be provided.",
|
||||
inputSchema: {
|
||||
id: z.string().optional().describe("Unique identifier for the document. Either the UUID or the urlId is acceptable."),
|
||||
shareId: z.string().optional().describe("Unique identifier for a document share, a shareId may be used in place of a document UUID"),
|
||||
id: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"Unique identifier for the document. Either the UUID or the urlId is acceptable."
|
||||
),
|
||||
shareId: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"Unique identifier for a document share, a shareId may be used in place of a document UUID"
|
||||
),
|
||||
},
|
||||
},
|
||||
async (args) => {
|
||||
@@ -27,9 +50,12 @@ export const registerDocumentTools: ToolsFactory<DocumentsApi> = (server: McpSer
|
||||
shareId: args?.shareId,
|
||||
},
|
||||
});
|
||||
return handleSuccess(response, logger.child({ tool: "documents.info" }));
|
||||
return handleSuccess(
|
||||
response,
|
||||
logger.child({ tool: "documents_info" })
|
||||
);
|
||||
} catch (error) {
|
||||
return handleError(error, logger.child({ tool: "documents.info" }));
|
||||
return handleError(error, logger.child({ tool: "documents_info" }));
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -47,10 +73,11 @@ export const registerDocumentTools: ToolsFactory<DocumentsApi> = (server: McpSer
|
||||
});
|
||||
|
||||
server.registerTool(
|
||||
"documents.list",
|
||||
"documents_list",
|
||||
{
|
||||
title: "List Documents",
|
||||
description: "This method will list all published documents and draft documents belonging to the current user.",
|
||||
description:
|
||||
"This method will list all published documents and draft documents belonging to the current user.",
|
||||
inputSchema: documentsListSchema.shape,
|
||||
},
|
||||
async (args) => {
|
||||
@@ -59,9 +86,12 @@ export const registerDocumentTools: ToolsFactory<DocumentsApi> = (server: McpSer
|
||||
const response = await client.documentsList({
|
||||
documentsListRequest: validatedArgs,
|
||||
});
|
||||
return handleSuccess(response, logger.child({ tool: "documents.list" }));
|
||||
return handleSuccess(
|
||||
response,
|
||||
logger.child({ tool: "documents_list" })
|
||||
);
|
||||
} catch (error) {
|
||||
return handleError(error, logger.child({ tool: "documents.list" }));
|
||||
return handleError(error, logger.child({ tool: "documents_list" }));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user