get_page_by_id
Retrieve a specific WikiJS page by its unique ID using this tool, enabling quick content access and integration within the WikiJS MCP Server environment.
Instructions
Get a WikiJS page by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the page to retrieve |
Implementation Reference
- src/mcp/tools/getPageById.ts:12-37 (handler)The MCP tool handler function that extracts the page ID from the request, fetches the page using the WikiJS client, stringifies the result as JSON text content, or returns an error message if failed.return async (request) => { try { const { id } = request; const result = await wikiClient.getPageById(id); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: 'text', text: `Error getting page by ID: ${errorMessage}` } ], isError: true }; } }
- src/mcp/tools/getPageById.ts:6-8 (schema)Zod schema defining the input parameters for the tool: a required numeric 'id'.export const PARAMETERS ={ id: z.number().describe('The ID of the page to retrieve') };
- src/mcp/index.ts:47-52 (registration)Registration of the 'get_page_by_id' tool on the MCP server, providing name, description, parameters schema, and the handler factory function.server.tool( 'get_page_by_id', 'Get a WikiJS page by its ID', GET_PAGE_BY_ID_TOOL_PARAMETERS, createGetPageByIdTool(this.wikiClient) );
- src/wikijs/index.ts:32-35 (helper)Supporting method in WikiJSClient class that uses the GraphQL SDK to retrieve a page by its ID and returns the page data or null.async getPageById(id: number) { const result = await this.sdk.GetPageById({ id }); return result.pages?.single || null; }