Skip to main content
Glama
ispyridis

Calibre RAG MCP Server

by ispyridis

create_project

Initialize a new vector-based RAG project for semantic book search and organization within your Calibre ebook library.

Instructions

Create a new RAG project for vector-based book search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesProject name (alphanumeric and underscores only)
descriptionNoProject description

Implementation Reference

  • The core handler function that creates a new RAG project directory, initializes the chunks subdirectory, creates and saves project.json configuration, registers the project in memory, and returns the project config.
    async createProject(name, description = '', selectedBooks = []) {
        const projectPath = path.join(CONFIG.RAG.PROJECTS_DIR, name);
        
        if (fs.existsSync(projectPath)) {
            throw new Error(`Project '${name}' already exists`);
        }
        
        // Create project directory structure
        fs.mkdirSync(projectPath, { recursive: true });
        fs.mkdirSync(path.join(projectPath, 'chunks'), { recursive: true });
        
        const projectConfig = {
            name,
            description,
            created_at: new Date().toISOString(),
            books: selectedBooks,
            chunk_count: 0,
            vector_dimension: CONFIG.RAG.VECTOR_DIMENSION
        };
        
        // Save project configuration
        fs.writeFileSync(
            path.join(projectPath, 'project.json'),
            JSON.stringify(projectConfig, null, 2)
        );
        
        this.projects.set(name, projectConfig);
        this.log(`Created project: ${name}`);
        
        return projectConfig;
    }
  • MCP tool schema definition in the tools/list response, specifying the input schema with required 'name' and optional 'description' parameters.
        name: 'create_project',
        description: 'Create a new RAG project for vector-based book search',
        inputSchema: {
            type: 'object',
            properties: {
                name: {
                    type: 'string',
                    description: 'Project name (alphanumeric and underscores only)'
                },
                description: {
                    type: 'string',
                    description: 'Project description'
                }
            },
            required: ['name']
        }
    },
  • server.js:1137-1163 (registration)
    Registration and dispatching logic in the tools/call handler switch statement, including input validation and invocation of the createProject handler.
    case 'create_project':
        const projectName = args.name;
        const projectDesc = args.description || '';
        
        if (!projectName) {
            this.sendError(id, -32602, 'Missing required parameter: name');
            return;
        }
        
        if (!/^[a-zA-Z0-9_]+$/.test(projectName)) {
            this.sendError(id, -32602, 'Project name must contain only alphanumeric characters and underscores');
            return;
        }
        
        try {
            const newProject = await this.createProject(projectName, projectDesc);
            this.sendSuccess(id, {
                content: [{
                    type: 'text',
                    text: `Created project '${projectName}' successfully!\n\nNext steps:\n1. Search for books using the 'search' tool\n2. Add books to the project using 'add_books_to_project'\n3. Use 'search_project_context' for RAG queries`
                }],
                project: newProject
            });
        } catch (error) {
            this.sendError(id, -32603, error.message);
        }
        break;

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