search_pages
Retrieve WikiJS pages by entering a search query, optionally narrowing results by path or locale, enabling efficient content discovery and integration.
Instructions
Search for pages in WikiJS by query string
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>"
},
"name": "search_pages"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| locale | No | Optional locale for the search (e.g., "en") | |
| path | No | Optional path to limit search scope | |
| query | Yes | Search query to find pages |
Implementation Reference
- src/mcp/tools/searchPage.ts:13-28 (handler)The createTool function returns the MCP tool handler for 'search_pages'. It extracts parameters from the request, calls wikiClient.searchPages, and returns the result as formatted JSON text content.
export const createTool = (wikiClient: WikiJSClient): ToolCallback<typeof PARAMETERS> => { return async (request) => { const { query, path, locale } = request const result = await wikiClient.searchPages(query, path, locale); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; } } - src/mcp/tools/searchPage.ts:6-10 (schema)Zod schema defining the input parameters for the search_pages tool: query (required string), path (optional string), locale (optional valid locale string).
export const PARAMETERS = { query: z.string().min(1, 'Query cannot be empty').describe('Search query to find pages'), path: z.string().optional().describe('Optional path to limit search scope'), locale: z.string().regex(/^[a-z]{2}(-[A-Z]{2})?$/, 'Invalid locale format').optional().describe('Optional locale for the search (e.g., "en")') }; - src/mcp/index.ts:41-45 (registration)Registration of the 'search_pages' tool on the MCP server using server.tool, providing name, description, parameters schema, and the handler function from createSearchPagesTool.
server.tool( 'search_pages', 'Search for pages in WikiJS by query string', SEARCH_PAGES_TOOL_PARAMETERS, createSearchPagesTool(this.wikiClient)); - src/wikijs/index.ts:22-25 (helper)Helper method on WikiJSClient that performs the GraphQL search for pages using the SDK and handles fallback for empty results.
async searchPages(query: string, path?: string, locale?: string) { const result = await this.sdk.SearchPages({ query, path, locale }); return result.pages?.search || { results: [], suggestions: [], totalHits: 0 }; }