search_docs
Search documentation using Elasticsearch query syntax. Enter a query string with keywords and operators (e.g., 'install AND guide'). Optionally specify a page number to paginate results.
Instructions
Search documentation using the probe search engine.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Elasticsearch query string. Focus on keywords and use ES syntax (e.g., "install AND guide", "configure OR setup", "api NOT internal"). | |
| page | No | Optional page number for pagination of results (e.g., 1, 2, 3...). Default is 1. |
Implementation Reference
- src/index.js:178-203 (handler)The main handler function that executes the 'search_docs' tool logic. It calls the `search` function from `@probelabs/probe` with the query and data directory path, returning the results as a string.
async executeDocsSearch(args) { try { // Always use the configured data directory const searchPath = config.dataDir; // Create a clean options object const options = { path: searchPath, query: args.query, maxTokens: 10000 // Set default maxTokens // Removed filesOnly, maxResults, session }; console.error("Executing search with options:", JSON.stringify(options, null, 2)); // Call search with the options object const result = await search(options); return result; } catch (error) { console.error('Error executing docs search:', error); throw new McpError( ErrorCode.MethodNotFound, `Error executing docs search: ${error.message || String(error)}` ); } } - src/index.js:58-61 (schema)JSDoc typedef for SearchDocsArgs, defining the input schema: `query` (string or string array) using Elasticsearch syntax.
/** * @typedef {Object} SearchDocsArgs * @property {string|string[]} query - The search query using Elasticsearch syntax. Focus on keywords. */ - src/index.js:97-119 (registration)Tool registration in the ListToolsRequestSchema handler. The tool name is set to the configured value (defaults to 'search_docs'). Defines input schema with required 'query' (string) and optional 'page' (number).
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: config.toolName, // Use configured tool name description: config.toolDescription, // Use configured description inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Elasticsearch query string. Focus on keywords and use ES syntax (e.g., "install AND guide", "configure OR setup", "api NOT internal").', }, page: { type: 'number', description: 'Optional page number for pagination of results (e.g., 1, 2, 3...). Default is 1.', default: 1, // Set a default value } }, required: ['query'] // 'page' is optional }, }, ], })); - src/index.js:121-128 (registration)CallToolRequestSchema handler that dispatches to executeDocsSearch when the tool name matches the configured name (default 'search_docs'). Validates required 'query' argument.
this.server.setRequestHandler(CallToolRequestSchema, async (request) => { // Check against the configured tool name if (request.params.name !== config.toolName) { throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}. Expected: ${config.toolName}` ); } - src/config.js:27-29 (helper)Configuration definition where the tool name 'search_docs' is set as the default value in the config, along with the tool description.
// MCP Tool configuration toolName: 'search_docs', toolDescription: 'Search documentation using the probe search engine.',