Skip to main content
Glama
ispyridis

Calibre RAG MCP Server

by ispyridis

search

Search your Calibre ebook library using natural language queries or field-specific metadata syntax to find books by content or attributes.

Instructions

Search the Calibre ebook library. Supports both full-text content search (default) and metadata search using field syntax.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query. For full-text: use natural language. For metadata: use field syntax (author:Name, title:"Title").
limitNoMaximum number of results (default: 50)
fuzzy_fallbackNoAlternative search terms if exact query fails

Implementation Reference

  • Core handler function that executes the book search using Calibre's 'calibredb search' and 'list' commands, fetches metadata, and formats results with epub URLs.
    async searchBooksMetadata(query, limit = 50) {
        try {
            const searchResult = await this.runCalibreCommand(['search', '--limit', limit.toString(), query]);
            
            if (!searchResult.trim()) {
                return [];
            }
    
            const bookIds = searchResult.trim();
            const idQuery = `id:${bookIds.replace(/,/g, ' OR id:')}`;
            
            const listResult = await this.runCalibreCommand([
                'list',
                '--fields', 'id,title,authors,series,tags,publisher,pubdate,formats,identifiers,comments',
                '--for-machine',
                '--search', idQuery
            ]);
    
            const books = JSON.parse(listResult || '[]');
            
            return books.map(book => ({
                id: book.id,
                title: book.title,
                authors: book.authors,
                series: book.series,
                tags: book.tags,
                publisher: book.publisher,
                published: book.pubdate,
                epub_url: this.createEpubUrl(book.authors, book.title, book.id),
                formats: book.formats ? book.formats.map(f => path.basename(f)) : [],
                full_formats: book.formats || [],
                has_text: book.formats ? book.formats.some(f => f.endsWith('.txt')) : false,
                description: book.comments ? 
                    book.comments.replace(/<[^>]+>/g, '').split('\n').slice(0, 2).join(' ').substring(0, 200) + '...' : 
                    null
            }));
            
        } catch (error) {
            this.log(`Metadata search failed: ${error.message}`);
            return [];
        }
    }
  • Input schema defining parameters for the 'search' tool: query (required), limit, fuzzy_fallback.
    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:966-987 (registration)
    Registration of the 'search' tool in the static tools array returned by 'tools/list' method.
        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']
        }
    },
  • Tool dispatch handler in 'tools/call' that validates input, calls searchBooksMetadata, formats response, and sends MCP success response.
    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.searchBooksMetadata(query, limit);
        const mcpResult = this.formatResponse(results, query, 'search');
        this.sendSuccess(id, mcpResult);
        break;
  • Helper function to format search results into MCP-compatible response structure with text summary and structured results.
    }
    
    formatResponse(searchResults, query, searchType = 'search') {
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the search types but lacks details on permissions needed, rate limits, response format, pagination, or error handling. For a search tool with no annotation coverage, this leaves significant gaps in understanding how it behaves in practice.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, consisting of two clear sentences that directly state the tool's purpose and key features. Every sentence earns its place by providing essential information without redundancy or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (search functionality with multiple modes), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the search returns, how results are structured, or any behavioral constraints. For a tool with no structured output information, the description should provide more context to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already documents all parameters thoroughly. The description adds minimal value by implying the 'query' parameter supports both full-text and metadata syntax, but this is also covered in the schema. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't significantly enhance parameter understanding beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Search the Calibre ebook library' with specific search types (full-text content and metadata). It distinguishes from some siblings like 'add_books_to_project' or 'create_project' by focusing on search functionality, though it doesn't explicitly differentiate from 'search_project_context' which appears to be a related search tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides some usage context by mentioning 'Supports both full-text content search (default) and metadata search using field syntax,' which implies when to use each mode. However, it doesn't explicitly state when to choose this tool over alternatives like 'search_project_context' or 'fetch,' nor does it mention any prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ispyridis/calibre-rag-mcp-nodejs'

If you have feedback or need assistance with the MCP directory API, please join our Discord server