search
Search your Calibre ebook library using natural language queries or metadata field syntax to find books by content, author, or title.
Instructions
Search the Calibre ebook library. Supports both full-text content search (default) and metadata search using field syntax.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query. For full-text: use natural language. For metadata: use field syntax (author:Name, title:"Title"). | |
| limit | No | Maximum number of results (default: 50) | |
| fuzzy_fallback | No | Alternative search terms if exact query fails |
Implementation Reference
- server.js:569-593 (handler)The handler for the 'search' tool in handleToolsCall. It extracts parameters, calls searchUnified, determines search type, formats response, and sends it.case 'search': const query = args.query; const limit = args.limit || 50; if (!query) { this.sendError(id, -32602, 'Missing required parameter: query'); return; } const results = await this.searchUnified(query, limit); // Determine search type const parsed = this.parseHybridQuery(query); let searchType; if (parsed.hasMetadata && parsed.hasContent) { searchType = 'hybrid'; } else if (parsed.hasMetadata) { searchType = 'metadata'; } else { searchType = 'fulltext'; } const mcpResult = this.formatDualResponse(results, query, searchType); this.sendSuccess(id, mcpResult); break;
- server.js:524-546 (schema)The schema definition for the 'search' tool, including name, description, and inputSchema, provided in the tools/list response.{ name: 'search', description: 'Search the Calibre ebook library. Supports both full-text content search (default) and metadata search using field syntax.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query. For full-text: use natural language. For metadata: use field syntax (author:Name, title:"Title").' }, limit: { type: 'integer', description: 'Maximum number of results (default: 50)', default: 50 }, fuzzy_fallback: { type: 'string', description: 'Alternative search terms if exact query fails' } }, required: ['query'] } },
- server.js:522-564 (registration)The handleToolsList method registers and returns the list of available tools, including the 'search' tool.handleToolsList(id) { const tools = [ { name: 'search', description: 'Search the Calibre ebook library. Supports both full-text content search (default) and metadata search using field syntax.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query. For full-text: use natural language. For metadata: use field syntax (author:Name, title:"Title").' }, limit: { type: 'integer', description: 'Maximum number of results (default: 50)', default: 50 }, fuzzy_fallback: { type: 'string', description: 'Alternative search terms if exact query fails' } }, required: ['query'] } }, { name: 'fetch', description: 'Fetch specific content from a book using epub:// URL', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'epub:// URL from search results' } }, required: ['url'] } } ]; this.sendSuccess(id, { tools: tools }); }
- server.js:343-357 (helper)Core helper method searchUnified that dispatches to metadata or full-text search based on query parsing.async searchUnified(query, limit = 50) { const parsed = this.parseHybridQuery(query); if (parsed.hasMetadata && parsed.hasContent) { // Hybrid search - not implemented in this version this.log('Hybrid search requested, falling back to metadata search'); return await this.searchBooksMetadata(query, limit); } else if (parsed.hasMetadata) { this.log(`Using metadata search for: ${query}`); return await this.searchBooksMetadata(query, limit); } else { this.log(`Using full-text search for: ${query}`); return await this.searchBooksFulltext(query, limit); } }