some tools
Some checks failed
CI / Test (pull_request) Failing after 56s

This commit is contained in:
2025-07-15 19:31:10 +02:00
parent fcaff53fb4
commit 912a0f7351
8 changed files with 148 additions and 90 deletions

View File

@@ -1,49 +1,67 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { createOutlineClient, handleSuccess, handleError } from "./utils";
// Register document tools
export const registerDocumentTools = (server: McpServer) => {
server.registerTool(
"documents_list",
{
title: "List Documents",
description: "List all documents in the Outline workspace",
inputSchema: {},
},
async () => {
try {
const client = createOutlineClient();
const response = await client.documents.documentsList();
return handleSuccess(response);
} catch (error) {
return handleError(error);
}
}
);
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 => {
server.registerTool(
"documents_info",
"documents.info",
{
title: "Get Document Info",
description: "Retrieve a specific document by its ID or share ID",
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("Document UUID or URL ID"),
shareId: z.string().optional().describe("Document share ID"),
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) => {
try {
const client = createOutlineClient();
const response = await client.documents.documentsInfo({
const response = await client.documentsInfo({
documentsInfoRequest: {
id: args?.id,
shareId: args?.shareId,
},
});
return handleSuccess(response);
return handleSuccess(response, logger.child({ tool: "documents.info" }));
} catch (error) {
return handleError(error);
return handleError(error, logger.child({ tool: "documents.info" }));
}
}
);
const documentsListSchema = z.object({
offset,
limit,
sort,
direction,
collectionId,
userId,
backlinkDocumentId,
parentDocumentId,
template: z.boolean().optional(),
});
server.registerTool(
"documents.list",
{
title: "List Documents",
description: "This method will list all published documents and draft documents belonging to the current user.",
inputSchema: documentsListSchema.shape,
},
async (args) => {
try {
const validatedArgs = documentsListSchema.parse(args);
const response = await client.documentsList({
documentsListRequest: validatedArgs,
});
return handleSuccess(response, logger.child({ tool: "documents.list" }));
} catch (error) {
return handleError(error, logger.child({ tool: "documents.list" }));
}
}
);