Skip to main content
Glama
README.md
# cstcloud-latex-mcp

> MCP Server for editing LaTeX projects on [latex.cstcloud.cn](https://latex.cstcloud.cn) from any IDE.

A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server and VS Code / Antigravity extension that lets you manage, edit, compile, and bidirectionally sync your CSTCloud LaTeX projects directly from VS Code, Cursor, Antigravity, and any other MCP-compatible editor.

## VS Code Extension

Search **`CSTCloud LaTeX`** (or **`nowhere.cstcloud-latex`**) in the **VS Code Extensions Marketplace** (or Open VSX), or install directly from:
- <https://marketplace.visualstudio.com/items?itemName=nowhere.cstcloud-latex>

## Features

- 📋 **List Projects** — Browse all your LaTeX projects
- 📁 **File Tree** — View the full file/folder structure of any project
- 📖 **Read Files** — Read `.tex`, `.bib`, `.cls`, and other source files
- ✏️ **Write Files** — Edit and save file content back to the cloud
- 🔨 **Compile** — Trigger remote LaTeX compilation (pdflatex, xelatex, lualatex)
- 📊 **Compile Logs** — Get structured error/warning reports from build logs

## Quick Start

### 1. Get Your Cookie

1. Visit [latex.cstcloud.cn](https://latex.cstcloud.cn) and log in
2. Open DevTools (F12) → Application → Cookies
3. Copy the value of the `overleaf.sid` cookie

### 2. Configure Your IDE

#### VS Code / Cursor

Add to your MCP settings (`.vscode/mcp.json` or user settings):

```json
{
  "mcpServers": {
    "cstcloud-latex": {
      "command": "npx",
      "args": ["cstcloud-latex-mcp"],
      "env": {
        "CSTCLOUD_COOKIE": "your-overleaf.sid-cookie-value"
      }
    }
  }
}
```

#### Antigravity

Add to your MCP configuration:

```json
{
  "mcpServers": {
    "cstcloud-latex": {
      "command": "npx",
      "args": ["cstcloud-latex-mcp"],
      "env": {
        "CSTCLOUD_COOKIE": "your-overleaf.sid-cookie-value"
      }
    }
  }
}
```

### 3. Start Using

Once configured, your AI assistant can use these tools:

| Tool | Description |
|------|-------------|
| `list_projects` | List all your LaTeX projects |
| `get_project_files` | Get the file tree of a project |
| `read_file` | Read a document's content |
| `write_file` | Update a document's content |
| `compile_project` | Trigger remote LaTeX compilation |
| `get_compile_log` | Get compilation errors and warnings |
| `start_sync` | Start real-time bidirectional sync to a local folder |
| `stop_sync` | Stop an active bidirectional sync session |
| `sync_status` | Inspect active sync sessions and logs |

### 4. Bidirectional Sync (Open in IDE)

Sync any CSTCloud project to a local folder and open it directly in your IDE:

```bash
# Continuous bidirectional sync
CSTCLOUD_COOKIE="your-cookie" node dist/index.js sync <projectId> ./my-paper

# One-shot reconciliation
CSTCLOUD_COOKIE="your-cookie" node dist/index.js sync <projectId> ./my-paper --once
```

Or ask your AI assistant to call `start_sync` with `project_id` and `local_dir`. Sync metadata is stored in `~/.cstcloud-sync/`, and IDE/LaTeX temporary files are ignored by default (customizable via `.cstcloudignore`).

**Example conversation:**

> **You:** "Show me my LaTeX projects on CSTCloud"
>
> **AI:** *(calls `list_projects`)* "You have 3 projects: ..."
>
> **You:** "Open the main.tex file in my thesis project and fix the bibliography errors"
>
> **AI:** *(calls `get_project_files` → `read_file` → `write_file` → `compile_project` → `get_compile_log`)*

## Environment Variables

| Variable | Required | Description |
|----------|----------|-------------|
| `CSTCLOUD_COOKIE` | ✅ | Your `overleaf.sid` session cookie |
| `CSTCLOUD_BASE_URL` | ❌ | Custom server URL (default: `https://latex.cstcloud.cn`) |

## Development

```bash
# Clone the repo
git clone https://github.com/YOUR_USERNAME/cstcloud-latex-mcp.git
cd cstcloud-latex-mcp

# Install dependencies
npm install

# Build
npm run build

# Run locally
CSTCLOUD_COOKIE="your-cookie" node dist/index.js
```

## Roadmap

- [x] Project listing and file tree
- [x] Document read/write
- [x] Remote compilation and log parsing
- [x] Bidirectional file sync (local ↔ cloud)
- [ ] PDF download/preview
- [ ] Multi-server support

## License

[MIT](LICENSE)

TDQS

A3.9/5.0

Scored across 10 tools

Disambiguation5/5

Each tool targets a clearly distinct resource or lifecycle stage: listing projects, inspecting a file tree, reading/writing a single file, compiling, fetching logs, and the start/stop/status of sync sessions. The hierarchy (list_projects -> get_project_files -> read_file) is explained in descriptions, so an agent can pick the right tool without confusion.

Naming Consistency4/5

Nearly all tools follow a snake_case verb_noun pattern (list_projects, get_project_files, read_file, write_file, compile_project, get_compile_log, start_sync, stop_sync, configure_auth). The only deviation is sync_status, which is noun-only rather than verb_noun, a minor inconsistency within an otherwise predictable set.

Tool Count5/5

Ten tools is well within the ideal range and each earns its place, covering project discovery, file operations, compilation, diagnostics, auth, and sync. There is no obvious redundancy or padding in the set.

Completeness3/5

The surface covers reading and replacing file content plus compilation and sync, but there is no way to create a new project, create a new file, or delete/rename files, so write_file only fully serves existing documents. These are notable gaps that would cause dead ends for common project-setup and cleanup workflows.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues