overleaf-mcp-integration 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ # required
2
+ OVERLEAF_TOKEN=your_overleaf_git_token
3
+
4
+ # required
5
+ PROJECT_ID=your_overleaf_project_id
6
+
7
+ # Optional comma-separated project allowlist; defaults to PROJECT_ID
8
+ # OVERLEAF_ALLOWED_PROJECTS=your_overleaf_project_id
9
+
10
+ # Optional; defaults to ~/.cache/overleaf-mcp
11
+ # OVERLEAF_REPO_DIR=/absolute/path/to/overleaf-mcp-cache
12
+
13
+ # Optional when the server is installed as a wheel
14
+ # OVERLEAF_ENV_FILE=/absolute/path/to/.env
15
+
16
+ # Optional: Overleaf Git base URL (change for self-hosted instances)
17
+ # OVERLEAF_BASE_URL=git.overleaf.com
@@ -0,0 +1,40 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ checks:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - uses: astral-sh/setup-uv@v6
13
+ with:
14
+ enable-cache: true
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.13"
18
+ - run: uv sync --locked
19
+ - run: uv run ruff check overleaf_mcp tests
20
+ - run: uv run ruff format --check overleaf_mcp tests
21
+ - run: uv run mypy overleaf_mcp tests
22
+ - name: Run tests
23
+ env:
24
+ OVERLEAF_TOKEN: ci-test-token
25
+ PROJECT_ID: 0123456789abcdef01234567
26
+ run: uv run pytest
27
+ - run: uv build
28
+ - name: Install and smoke-test wheel
29
+ shell: bash
30
+ run: |
31
+ rm -rf /tmp/overleaf-mcp-wheel-check
32
+ uv venv --python 3.13 /tmp/overleaf-mcp-wheel-check/.venv
33
+ uv pip install --python /tmp/overleaf-mcp-wheel-check/.venv/bin/python dist/*.whl
34
+ unzip -l dist/*.whl
35
+ printf '%s\n' \
36
+ '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"ci","version":"1"}}}' \
37
+ '{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}' \
38
+ '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
39
+ | OVERLEAF_TOKEN=ci-test PROJECT_ID=0123456789abcdef01234567 timeout 15 /tmp/overleaf-mcp-wheel-check/.venv/bin/overleaf-mcp \
40
+ | grep '"id":2'
@@ -0,0 +1,34 @@
1
+ __pycache__/
2
+ *.py[codz]
3
+ *$py.class
4
+ *.so
5
+ .Python
6
+ build/
7
+ develop-eggs/
8
+ dist/
9
+ downloads/
10
+ eggs/
11
+ .eggs/
12
+ lib/
13
+ lib64/
14
+ parts/
15
+ sdist/
16
+ var/
17
+ wheels/
18
+ share/python-wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+ .pytest_cache/
23
+ .pyenv/
24
+ .env
25
+ .venv
26
+ env/
27
+ venv/
28
+ ENV/
29
+ env.bak/
30
+ venv.bak/
31
+ .ruff_cache/
32
+ .mypy_cache/
33
+ .dmypy.json
34
+ dmypy.json
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Younes Bensafia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.5
2
+ Name: overleaf-mcp-integration
3
+ Version: 0.1.0
4
+ Summary: MCP server for Overleaf projects via Git sync
5
+ Project-URL: Homepage, https://github.com/younesbensafia/overleaf-mcp-server
6
+ Project-URL: Repository, https://github.com/younesbensafia/overleaf-mcp-server
7
+ Project-URL: Issues, https://github.com/younesbensafia/overleaf-mcp-server/issues
8
+ Author: Younes Bensafia
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: git,latex,mcp,overleaf,sharelatex
12
+ Requires-Python: >=3.13
13
+ Requires-Dist: filelock>=3.16.0
14
+ Requires-Dist: gitpython>=3.1.46
15
+ Requires-Dist: mcp<2.0.0,>=1.26.0
16
+ Requires-Dist: pydantic-settings>=2.10.0
17
+ Requires-Dist: pydantic>=2.11.0
18
+ Description-Content-Type: text/markdown
19
+
20
+ # Overleaf MCP Server
21
+ <!-- mcp-name: io.github.YounesBensafia/overleaf-mcp-server -->
22
+
23
+ An MCP server focused only on Overleaf projects (via Overleaf Git sync).
24
+
25
+ ## What This Server Does
26
+
27
+ - Connects MCP-compatible clients to your Overleaf project through Git sync.
28
+ - Exposes file-level tools to list, read, write, and sync project content.
29
+ - Keeps workflow simple: pull latest files, edit, then push back to Overleaf.
30
+
31
+ ## Architecture
32
+
33
+ ```mermaid
34
+ flowchart LR
35
+ C[MCP Client\nClaude Desktop / other MCP host] -->|Tool Call| S[Overleaf MCP Server]
36
+ S -->|Git Sync| O[Overleaf Git Remote]
37
+ S -->|Read / Write| L[Local Repo Mirror]
38
+ L -->|Commit + Push| O
39
+ O -->|Pull / Fetch| L
40
+ S -->|Tool Result| C
41
+ ```
42
+
43
+ ## Tool Workflow
44
+
45
+ ```mermaid
46
+ sequenceDiagram
47
+ participant Client as MCP Client
48
+ participant Server as Overleaf MCP Server
49
+ participant Local as Local Mirror
50
+ participant Overleaf as Overleaf Git
51
+
52
+ Client->>Server: list_files / read_file
53
+ Server->>Local: Ensure local clone
54
+ Server->>Overleaf: git pull
55
+ Overleaf-->>Server: latest content
56
+ Server-->>Client: file list / file content
57
+
58
+ Client->>Server: write_file(path, content)
59
+ Server->>Local: update file
60
+ Server->>Local: git commit
61
+ Server->>Overleaf: git push
62
+ Server-->>Client: success + metadata
63
+ ```
64
+
65
+ ## Requirements
66
+
67
+ - Python 3.13+
68
+ - `uv` package manager
69
+ - An Overleaf plan with **Git integration** (individual, group, or institution license). Check if your institution provides free access at [Overleaf for Institutions](https://www.overleaf.com/for/institutions-using-overleaf) - use your institutional email. If your institution is not listed, [upgrade your plan](https://www.overleaf.com/user/subscription).
70
+
71
+ ## Git Setup
72
+
73
+ 1. **Enable Git** - open your project on Overleaf → **Menu** → enable **Git** under Integrations.
74
+ 2. **Copy project ID** - from the browser URL (e.g. `https://www.overleaf.com/project/69a4f7cc4eaf13bd56de5b04` → `69a4f7cc4eaf13bd56de5b04`).
75
+ 3. **Generate a Git token** - **Account Settings** → **Git integration authentication tokens** → **Generate new token**.
76
+ 4. **Configure `.env`** - copy `.env.example` to `.env` and fill in:
77
+
78
+ ```env
79
+ OVERLEAF_TOKEN=your_git_token
80
+ PROJECT_ID=your_project_id
81
+ ```
82
+
83
+ > `project_id` can also be passed per tool call, but `PROJECT_ID` is still required
84
+ > by the server configuration.
85
+
86
+ The Overleaf Git token is account-wide credential material. Store it only in
87
+ the MCP client's environment or a protected `.env` file, and rotate it if it
88
+ is exposed.
89
+
90
+ ## Safety Notes
91
+
92
+ Files in an Overleaf project are untrusted input. A `.tex` file or project
93
+ configuration can contain instructions aimed at the model; treat file contents
94
+ as data, not as commands. Keep `OVERLEAF_ALLOWED_PROJECTS` restricted to the
95
+ projects the server should be able to access:
96
+
97
+ ```env
98
+ OVERLEAF_ALLOWED_PROJECTS=project_id_a,project_id_b
99
+ ```
100
+
101
+ The default allowlist contains only `PROJECT_ID`.
102
+
103
+ ## Quick Start
104
+
105
+ ```bash
106
+ git clone https://github.com/younesbensafia/overleaf-mcp-server.git
107
+ cd overleaf-mcp-server
108
+ uv sync
109
+ cp .env.example .env # then edit with your token/project id
110
+ uv run overleaf-mcp
111
+ ```
112
+
113
+ Without a checkout, run the Git version directly with:
114
+
115
+ ```bash
116
+ uvx --from git+https://github.com/younesbensafia/overleaf-mcp-server overleaf-mcp
117
+ ```
118
+
119
+ Plain `uvx overleaf-mcp` is appropriate only after the project is published to
120
+ PyPI.
121
+
122
+ The server listens on stdio - connect your MCP client (Claude Desktop, etc.) to it.
123
+
124
+ For a large project, call `sync_project` first. The initial Git clone can take
125
+ longer than an MCP client's individual tool request timeout.
126
+
127
+ ## Available Tools
128
+
129
+ | Tool | Description |
130
+ |------|-------------|
131
+ | `list_files` | Pull and list files from Overleaf project |
132
+ | `read_file` | Read file content |
133
+ | `write_file` | Overwrite a complete text file, commit, and push to Overleaf |
134
+ | `edit_file` | Replace one exact text match, commit, and push to Overleaf |
135
+ | `sync_project` | Force a pull/sync from Overleaf |
136
+
137
+ `read_file` accepts optional zero-based `offset` and bounded `limit` line
138
+ parameters for reading large documents in chunks.
139
+
140
+ ## Claude Desktop Setup
141
+
142
+ Add to `~/.config/Claude/claude_desktop_config.json`:
143
+
144
+ ```json
145
+ {
146
+ "mcpServers": {
147
+ "overleaf": {
148
+ "command": "uv",
149
+ "args": ["--directory", "/path/to/overleaf-mcp-server", "run", "overleaf-mcp"],
150
+ "env": {
151
+ "OVERLEAF_TOKEN": "your_git_token",
152
+ "PROJECT_ID": "your_project_id"
153
+ }
154
+ }
155
+ }
156
+ }
157
+ ```
158
+
159
+ ## Troubleshooting
160
+
161
+ - **403 Forbidden on git operations:**
162
+ - Your plan doesn't include Git integration - follow the [Git Setup](#git-setup) section.
163
+ - Or the Git token is wrong - regenerate it at **Account Settings** → **Git integration authentication tokens**.
164
+ - **Wrong project content:**
165
+ - Set the correct `PROJECT_ID` in `.env`.
166
+ - Or pass `project_id` explicitly in tool calls.
167
+ - **Sync conflicts:**
168
+ - Run `sync_project` before `write_file` if the remote changed.
169
+ - **Server not starting:**
170
+ - Ensure dependencies are installed with `uv sync`.
171
+ - Verify Python 3.13+ is available.
172
+
173
+ ## License
174
+
175
+ MIT - See [LICENSE](LICENSE)
@@ -0,0 +1,156 @@
1
+ # Overleaf MCP Server
2
+ <!-- mcp-name: io.github.YounesBensafia/overleaf-mcp-server -->
3
+
4
+ An MCP server focused only on Overleaf projects (via Overleaf Git sync).
5
+
6
+ ## What This Server Does
7
+
8
+ - Connects MCP-compatible clients to your Overleaf project through Git sync.
9
+ - Exposes file-level tools to list, read, write, and sync project content.
10
+ - Keeps workflow simple: pull latest files, edit, then push back to Overleaf.
11
+
12
+ ## Architecture
13
+
14
+ ```mermaid
15
+ flowchart LR
16
+ C[MCP Client\nClaude Desktop / other MCP host] -->|Tool Call| S[Overleaf MCP Server]
17
+ S -->|Git Sync| O[Overleaf Git Remote]
18
+ S -->|Read / Write| L[Local Repo Mirror]
19
+ L -->|Commit + Push| O
20
+ O -->|Pull / Fetch| L
21
+ S -->|Tool Result| C
22
+ ```
23
+
24
+ ## Tool Workflow
25
+
26
+ ```mermaid
27
+ sequenceDiagram
28
+ participant Client as MCP Client
29
+ participant Server as Overleaf MCP Server
30
+ participant Local as Local Mirror
31
+ participant Overleaf as Overleaf Git
32
+
33
+ Client->>Server: list_files / read_file
34
+ Server->>Local: Ensure local clone
35
+ Server->>Overleaf: git pull
36
+ Overleaf-->>Server: latest content
37
+ Server-->>Client: file list / file content
38
+
39
+ Client->>Server: write_file(path, content)
40
+ Server->>Local: update file
41
+ Server->>Local: git commit
42
+ Server->>Overleaf: git push
43
+ Server-->>Client: success + metadata
44
+ ```
45
+
46
+ ## Requirements
47
+
48
+ - Python 3.13+
49
+ - `uv` package manager
50
+ - An Overleaf plan with **Git integration** (individual, group, or institution license). Check if your institution provides free access at [Overleaf for Institutions](https://www.overleaf.com/for/institutions-using-overleaf) - use your institutional email. If your institution is not listed, [upgrade your plan](https://www.overleaf.com/user/subscription).
51
+
52
+ ## Git Setup
53
+
54
+ 1. **Enable Git** - open your project on Overleaf → **Menu** → enable **Git** under Integrations.
55
+ 2. **Copy project ID** - from the browser URL (e.g. `https://www.overleaf.com/project/69a4f7cc4eaf13bd56de5b04` → `69a4f7cc4eaf13bd56de5b04`).
56
+ 3. **Generate a Git token** - **Account Settings** → **Git integration authentication tokens** → **Generate new token**.
57
+ 4. **Configure `.env`** - copy `.env.example` to `.env` and fill in:
58
+
59
+ ```env
60
+ OVERLEAF_TOKEN=your_git_token
61
+ PROJECT_ID=your_project_id
62
+ ```
63
+
64
+ > `project_id` can also be passed per tool call, but `PROJECT_ID` is still required
65
+ > by the server configuration.
66
+
67
+ The Overleaf Git token is account-wide credential material. Store it only in
68
+ the MCP client's environment or a protected `.env` file, and rotate it if it
69
+ is exposed.
70
+
71
+ ## Safety Notes
72
+
73
+ Files in an Overleaf project are untrusted input. A `.tex` file or project
74
+ configuration can contain instructions aimed at the model; treat file contents
75
+ as data, not as commands. Keep `OVERLEAF_ALLOWED_PROJECTS` restricted to the
76
+ projects the server should be able to access:
77
+
78
+ ```env
79
+ OVERLEAF_ALLOWED_PROJECTS=project_id_a,project_id_b
80
+ ```
81
+
82
+ The default allowlist contains only `PROJECT_ID`.
83
+
84
+ ## Quick Start
85
+
86
+ ```bash
87
+ git clone https://github.com/younesbensafia/overleaf-mcp-server.git
88
+ cd overleaf-mcp-server
89
+ uv sync
90
+ cp .env.example .env # then edit with your token/project id
91
+ uv run overleaf-mcp
92
+ ```
93
+
94
+ Without a checkout, run the Git version directly with:
95
+
96
+ ```bash
97
+ uvx --from git+https://github.com/younesbensafia/overleaf-mcp-server overleaf-mcp
98
+ ```
99
+
100
+ Plain `uvx overleaf-mcp` is appropriate only after the project is published to
101
+ PyPI.
102
+
103
+ The server listens on stdio - connect your MCP client (Claude Desktop, etc.) to it.
104
+
105
+ For a large project, call `sync_project` first. The initial Git clone can take
106
+ longer than an MCP client's individual tool request timeout.
107
+
108
+ ## Available Tools
109
+
110
+ | Tool | Description |
111
+ |------|-------------|
112
+ | `list_files` | Pull and list files from Overleaf project |
113
+ | `read_file` | Read file content |
114
+ | `write_file` | Overwrite a complete text file, commit, and push to Overleaf |
115
+ | `edit_file` | Replace one exact text match, commit, and push to Overleaf |
116
+ | `sync_project` | Force a pull/sync from Overleaf |
117
+
118
+ `read_file` accepts optional zero-based `offset` and bounded `limit` line
119
+ parameters for reading large documents in chunks.
120
+
121
+ ## Claude Desktop Setup
122
+
123
+ Add to `~/.config/Claude/claude_desktop_config.json`:
124
+
125
+ ```json
126
+ {
127
+ "mcpServers": {
128
+ "overleaf": {
129
+ "command": "uv",
130
+ "args": ["--directory", "/path/to/overleaf-mcp-server", "run", "overleaf-mcp"],
131
+ "env": {
132
+ "OVERLEAF_TOKEN": "your_git_token",
133
+ "PROJECT_ID": "your_project_id"
134
+ }
135
+ }
136
+ }
137
+ }
138
+ ```
139
+
140
+ ## Troubleshooting
141
+
142
+ - **403 Forbidden on git operations:**
143
+ - Your plan doesn't include Git integration - follow the [Git Setup](#git-setup) section.
144
+ - Or the Git token is wrong - regenerate it at **Account Settings** → **Git integration authentication tokens**.
145
+ - **Wrong project content:**
146
+ - Set the correct `PROJECT_ID` in `.env`.
147
+ - Or pass `project_id` explicitly in tool calls.
148
+ - **Sync conflicts:**
149
+ - Run `sync_project` before `write_file` if the remote changed.
150
+ - **Server not starting:**
151
+ - Ensure dependencies are installed with `uv sync`.
152
+ - Verify Python 3.13+ is available.
153
+
154
+ ## License
155
+
156
+ MIT - See [LICENSE](LICENSE)
@@ -0,0 +1,24 @@
1
+ import re
2
+ from pathlib import Path
3
+ from typing import ClassVar
4
+
5
+ from pydantic import Field, SecretStr
6
+ from pydantic_settings import BaseSettings, SettingsConfigDict
7
+
8
+ _ENV_FILE = Path(__file__).resolve().parent.parent / ".env"
9
+
10
+
11
+ class Config(BaseSettings):
12
+ model_config = SettingsConfigDict(env_file=_ENV_FILE, extra="ignore")
13
+
14
+ OVERLEAF_TOKEN: SecretStr = Field(...)
15
+ PROJECT_ID: str = Field(...)
16
+ OVERLEAF_REPO_DIR: Path = Path.home() / ".cache" / "overleaf-mcp"
17
+ PROJECT_ID_RE: ClassVar[re.Pattern[str]] = re.compile(r"^[0-9a-f]{24}$")
18
+ MAX_READ_BYTES: ClassVar[int] = 100_000
19
+ MAX_READ_LINES: ClassVar[int] = 10_000
20
+ MAX_WRITE_BYTES: ClassVar[int] = 2_000_000
21
+ IDENTITY: ClassVar[tuple[str, str]] = ("Overleaf MCP", "overleaf-mcp@localhost")
22
+
23
+
24
+ config = Config()
@@ -0,0 +1,4 @@
1
+ """Installable Overleaf MCP server package."""
2
+
3
+ __all__ = ["__version__"]
4
+ __version__ = "0.1.0"