clone_project
Clone an Overleaf LaTeX project to your local machine for offline editing and version control integration.
Instructions
Clone an Overleaf project to a local directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | The ID of the Overleaf project | |
| localPath | Yes | The local path to clone the project to (absolute path) | |
| No | Overleaf account email (optional if configured globally) | ||
| token | No | Overleaf git token (optional if configured globally) |
Implementation Reference
- src/git-manager.ts:23-52 (handler)Core handler function that clones the Overleaf project using simple-git, handling authentication via provided credentials or global config.async cloneProject(projectId: string, localPath: string, email?: string, token?: string) { // Ensure parent directory exists await fs.ensureDir(path.dirname(localPath)); let gitUrl = ''; // Try to get credentials if not provided if (!email || !token) { const creds = await this.authManager.getCredentials(); if (creds) { gitUrl = this.getGitUrl(projectId, creds.email, creds.token); } else { // Fallback to no-auth URL (will likely fail or prompt if interactive, but MCP is non-interactive) // Ideally we should error here if no auth is available for a private repo, // but let's try to construct it. gitUrl = this.getGitUrl(projectId); } } else { gitUrl = this.getGitUrl(projectId, email, token); } const git: SimpleGit = simpleGit(); try { await git.clone(gitUrl, localPath); console.error(`Successfully cloned project ${projectId} to ${localPath}`); return { success: true, message: `Cloned to ${localPath}` }; } catch (error: any) { console.error('Clone failed:', error); throw new Error(`Failed to clone project: ${error.message}`); }
- src/index.ts:33-56 (schema)Input schema and metadata for the clone_project tool.name: 'clone_project', description: 'Clone an Overleaf project to a local directory', inputSchema: { type: 'object', properties: { projectId: { type: 'string', description: 'The ID of the Overleaf project', }, localPath: { type: 'string', description: 'The local path to clone the project to (absolute path)', }, email: { type: 'string', description: 'Overleaf account email (optional if configured globally)', }, token: { type: 'string', description: 'Overleaf git token (optional if configured globally)', }, }, required: ['projectId', 'localPath'], },
- src/index.ts:129-135 (registration)Registration and dispatch logic in the CallToolRequestHandler switch case, which calls the handler.case 'clone_project': { const { projectId, localPath, email, token } = request.params.arguments as any; const result = await gitManager.cloneProject(projectId, localPath, email, token); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }