get_page_by_path
Retrieve a specific WikiJS page by providing its path and locale, enabling precise content access within WikiJS knowledge bases.
Instructions
Get a WikiJS page by its path and locale
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| locale | Yes | The locale of the page (e.g., "en") | |
| path | Yes | The path of the page to retrieve |
Implementation Reference
- src/mcp/tools/getPageByPath.ts:11-39 (handler)Factory function createGetPageByPathTool that returns the tool handler executing the get_page_by_path logic: extracts path/locale, calls wikiClient.getPageByPath, returns JSON content or error.export const createTool = (wikiClient: WikiJSClient): ToolCallback<typeof PARAMETERS> => { return async (request) => { try { const { path, locale } = request; const result = await wikiClient.getPageByPath(path, locale); 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 path: ${errorMessage}` } ], isError: true }; } } }
- src/mcp/tools/getPageByPath.ts:6-9 (schema)Zod schema defining input parameters for the get_page_by_path tool: path (string) and locale (string with format validation).export const PARAMETERS = { path: z.string().describe('The path of the page to retrieve'), locale: z.string().regex(/^[a-z]{2}(-[A-Z]{2})?$/, 'Invalid locale format').describe('The locale of the page (e.g., "en")') }
- src/mcp/index.ts:54-59 (registration)Registration of the get_page_by_path tool on the MCP server using server.tool, providing name, description, parameters schema, and handler factory.server.tool( 'get_page_by_path', 'Get a WikiJS page by its path and locale', GET_PAGE_BY_PATH_TOOL_PARAMETERS, createGetPageByPathTool(this.wikiClient) );
- src/wikijs/index.ts:37-40 (helper)WikiJSClient helper method getPageByPath that invokes the GraphQL SDK to fetch the page by path and locale, used by the tool handler.async getPageByPath(path: string, locale: string) { const result = await this.sdk.GetPageByPath({ path, locale }); return result.pages?.singleByPath || null; }