ShareLaTeX MCP
Provides tools for reading and editing self-hosted Overleaf/ShareLaTeX projects, including listing projects and files, reading and searching documents, editing files with optional SHA-256 checks, extracting section outlines, and compiling projects with diagnostics.
ShareLaTeX MCP
A local MCP server for reading and editing self-hosted ShareLaTeX / Overleaf projects from an MCP client. Python 3.11+, STDIO transport, MIT license. 0.1.0 is a preview: deployment compatibility depends on internal web and realtime APIs. No Git integration or paid Overleaf account is required.
Quick start
From a downloaded or cloned checkout, install uv and run:
uv sync --locked
uv run --locked sharelatex-mcp --helpSet two environment variables in the process that starts your MCP client:
OVERLEAF_URL: an HTTPS origin, for examplehttps://latex.example.org.OVERLEAF_COOKIE: one browser session cookie, asname=value.
Log into your instance, then open browser developer tools > Application (or
Storage) > Cookies and locate its session cookie. Common names are overleaf.sid
and overleaf_session2; use the actual name from your deployment.
PowerShell example (substitute values locally):
$env:OVERLEAF_URL = 'https://latex.example.org'
$env:OVERLEAF_COOKIE = 'overleaf.sid=REPLACE_WITH_YOUR_SESSION'
uv run --locked sharelatex-mcpBash/zsh example:
export OVERLEAF_URL='https://latex.example.org'
export OVERLEAF_COOKIE='overleaf.sid=REPLACE_WITH_YOUR_SESSION'
uv run --locked sharelatex-mcpThe server waits for JSON-RPC on stdin. Normally the MCP client launches it for
you; an idle terminal is not a connection test. Environment variables set in a
terminal are inherited only by programs launched from that terminal. GUI clients
may instead need a private env section in their server configuration.
.env.example documents variable names; the server does not load .env files.
Related MCP server: overleaf-mcp-server
Install without a checkout
A wheel works without uv at runtime:
python -m pip install /path/to/sharelatex_mcp-0.1.0-py3-none-any.whl
sharelatex-mcp --versionOr run the wheel in a uv-managed environment:
uvx --from /path/to/sharelatex_mcp-0.1.0-py3-none-any.whl sharelatex-mcpInstall the current main branch directly from GitHub:
uvx --from 'git+https://github.com/TeaCupMe/ShareLatexMCP.git@main' sharelatex-mcpThe distribution name is not yet assumed to be available on PyPI. Installation by package name alone is documented only after a PyPI release exists.
Connect a client
Any MCP client capable of launching a local STDIO process can use the installed
sharelatex-mcp command (or python -m sharelatex_mcp). Use an absolute executable
path if your client's PATH differs from the terminal's.
For a checkout, a Cursor-style configuration is:
{
"mcpServers": {
"sharelatex": {
"command": "uv",
"args": ["run", "--locked", "--directory", "/absolute/path/SharelatexMCP", "sharelatex-mcp"]
}
}
}For Windows, use a path such as C:/projects/SharelatexMCP. For installed wheels,
see examples/cursor.mcp.json and
examples/codex.config.toml. They contain placeholders,
not working credentials. Copy the needed example into your client's private
configuration; never commit its real cookie. The current checkout's .codex/,
.cursor/ and .env files are ignored and excluded from release archives.
Keep confirmation enabled for write_file, append_to_file and replace_in_file
in your MCP client. Tool annotations describe side effects; confirmation is
controlled by the host. Restart/reconnect the server after updating credentials
or installing a new version. The old python server.py launch remains supported
from a synced source checkout.
Cloud clients without local process execution cannot use this STDIO release. An HTTP service and multi-user authentication are outside version 0.1.0.
Tools
All project arguments accept a name or ID. Ambiguous names return matching IDs.
list_projects(): names, IDs and last-update timestamps.list_files(project): the complete file tree.read_file(project, file_path, start_line=None, end_line=None): full UTF-8 text or inclusive line range starting at 1.get_sections(project, file_path): heading titles, commands and line numbers.read_section(project, file_path, title): one section and its deeper headings.project_outline(project, root_file=None): tree and recursively included headings, with cycle detection and a limit of 30 included files.search_project(project, query, file_pattern="*", max_results=30, context_lines=0): literal case-insensitive search in editable documents, with glob path filtering, up to 200 results and up to 10 context lines.write_file(project, file_path, content, expected_sha256=None): create or replace text; existing documents are edited in place, other files use uploads.append_to_file(project, file_path, content, expected_sha256=None): append text.replace_in_file(project, file_path, old_text, new_text, expected_sha256=None): replace exactly one occurrence in an editable document.compile_project(project, root_file=None): compile status and capped error / warning diagnostics. Does not return the PDF or change source content.
For editable documents, writes read the latest realtime snapshot and submit a
versioned operation. expected_sha256 optionally checks the full UTF-8 content
against a SHA-256 hex digest before editing. It detects stale snapshots, while
concurrent changes remain subject to ShareLaTeX's operational transformation.
This guard is not supported for uploaded files. When a write outcome is unknown,
read the document before deciding to retry; the server never retries automatically.
Compatibility and limits
The CI matrix targets Windows, Linux and macOS on Python 3.11, 3.12 and 3.13. Passing local checks does not prove remote deployment compatibility on all hosts. Dependencies use MCP SDK 2.3.0 and pyoverleaf 0.1.8. uv.lock pins the development resolution; installed distributions constrain direct dependencies.
Only HTTPS on standard port 443 is supported. HTTP, custom ports and path prefixes are rejected explicitly due to pyoverleaf transport limitations.
Self-hosted deployments must support the legacy Socket.IO realtime protocol used by pyoverleaf. This is not a promise of current overleaf.com compatibility.
Root selection prefers main.tex, then a .tex containing documentclass. Set root_file explicitly when that differs from your project's configured root.
The LaTeX parser handles comments, nested heading braces and common literal blocks. It does not expand macros or execute TeX.
Uploaded images and PDFs are not read as text. Rename/delete, project creation, sharing permissions, PDF download and automatic cookie renewal are not included.
Troubleshooting
Authentication errors: sign into the browser again, replace the session cookie in your client's private configuration and restart the MCP process. A renewed browser session does not update an already-running process's environment.
Server not found: check executable PATH and absolute paths; try --help and
--version in a terminal. Protocol logs go to stderr, never stdout.
Windows import errors: browser_cookie3, pulled in by pyoverleaf, imports WMI even when authentication comes from the environment. Some sandboxes block that import; run in an environment with WMI access. No browser profile access is needed for this server's login path.
Compilation reports busy, timeout and unavailable logs separately. Realtime failures may indicate an incompatible deployment. Report sanitized errors without cookies or private document text; see SECURITY.md.
Development and releases
See CONTRIBUTING.md, CHANGELOG.md and release instructions. The offline suite, archive checks and installed-wheel smoke test require no ShareLaTeX credentials. The optional live script modifies only the explicitly chosen disposable test project and attempts to restore the source afterward.
This project is independent of Overleaf. See LICENSE for MIT terms.
Available Tools
11 toolsappend_to_fileADestructive
Append text to the end of an existing file in a ShareLaTeX project.
This changes the remote project. The MCP client controls user confirmation.
expected_sha256 optionally guards against stale content (UTF-8 SHA-256). project is a project name or id. file_path must
already exist. A text document is updated in place. An uploaded file
is downloaded, extended, and re-uploaded.
Inputs: content (required), project (required), file_path (required), expected_sha256. Returns: result
compile_projectARead-only
Compile a ShareLaTeX project and return errors and warnings.
Read-only with respect to project source. project is a project name or
id. The result starts with the compile status and then lists error and
warning lines from output.log. root_file overrides automatic root
selection. Busy, timeout and unavailable logs are reported explicitly.
Inputs: project (required), root_file. Returns: result
get_sectionsARead-only
Extract LaTeX section headings from a .tex file.
Read-only. project is a project name or id. Returns one heading per
line: line number, heading command (chapter, section, subsection, and
so on), then the heading title. Starred commands such as \section*
are included.
Inputs: project (required), file_path (required). Returns: result
list_filesARead-only
List the full file tree of one ShareLaTeX project.
Read-only. project is a project name or id. Each line is a path inside the project. Folders end with a slash. The bracketed type is folder, doc (an editable text document), or file (an uploaded binary).
Inputs: project (required). Returns: result
list_projectsARead-only
List every ShareLaTeX project the logged-in user can see.
Read-only. Returns one line per project: name, id, then last_updated,
separated by tabs. Archived and trashed projects are omitted. Other
tools accept either the name or the id.
Inputs: no named parameters. Returns: result
project_outlineARead-only
Summarize a ShareLaTeX project without reading every file.
Read-only. project is a project name or id. Returns the file tree,
the headings of the root .tex file, and the headings of files pulled
in by \input or \include. The root file is main.tex when it exists,
otherwise the first .tex document that contains \documentclass.
Includes are followed recursively with cycle detection. At most 30 files
are opened. root_file overrides automatic root selection.
Inputs: project (required), root_file. Returns: result
read_fileARead-only
Read text from one file in a ShareLaTeX project.
Read-only. project is a project name or id. file_path is the path
inside the project, such as main.tex or chapters/intro.tex. Omit
start_line and end_line to read the whole file. Line numbers are
1-based and inclusive. end_line past the end of the file is clamped.
Inputs: project (required), file_path (required), end_line, start_line. Returns: result
read_sectionARead-only
Read one LaTeX section, including its heading.
Read-only. project is a project name or id. title is the heading text inside the braces, such as Introduction. The result runs from that heading through the line before the next heading of the same or higher level. Deeper headings are included. If the title appears more than once, the tool reports the line numbers and does not guess.
Inputs: title (required), project (required), file_path (required). Returns: result
replace_in_fileADestructive
Replace one exact occurrence of text in a ShareLaTeX document.
This changes the remote project. The MCP client controls user confirmation.
expected_sha256 optionally guards against stale content (UTF-8 SHA-256). project is a project name or id. The file must be
an editable text document, not an uploaded binary. old_text must occur
exactly once. new_text may be empty to delete that occurrence.
Inputs: project (required), new_text (required), old_text (required), file_path (required), +1 more. Returns: result
search_projectARead-only
Search editable documents in one ShareLaTeX project.
Read-only. project is a project name or id. The match is
case-insensitive. Each hit is path, line number, and a short snippet.
file_pattern filters project paths using glob syntax. max_results is
1..200 (default 30); context_lines is 0..10. Uploaded files are skipped.
Inputs: query (required), project (required), max_results, file_pattern, +1 more. Returns: result
write_fileADestructive
Create or overwrite a file in a ShareLaTeX project.
This changes the remote project. The MCP client controls user confirmation.
expected_sha256 optionally guards against stale content (UTF-8 SHA-256). project is a project name or id. An existing text
document is updated in place. An existing uploaded file is re-uploaded.
A missing file is created by upload. content is the full new text.
Inputs: content (required), project (required), file_path (required), expected_sha256. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
The read-side tools have related but distinguishable roles: read_file is line-range based, read_section is heading based, get_sections lists headings, and project_outline aggregates across files. There is mild overlap (read_file with no line bounds could read a section, and get_sections largely duplicates part of project_outline), but descriptions make selection reasonably clear. The three write tools are cleanly separated by intent (create/overwrite, append, single exact replacement).
Nearly all tools follow a predictable verb_noun pattern (list_projects, read_file, search_project, write_file, compile_project). The single exception is project_outline, a noun-only name, which breaks the pattern but remains unambiguous. No mixed casing or verb-style chaos.
11 tools is well within the sweet spot and every tool maps to a distinct capability (discovery, reading at three granularities, searching, three editing modes, compiling). Nothing feels like filler or duplication that should be merged.
The read/search/edit/compile loop is covered, but there are notable lifecycle gaps: no create_project, delete_project, delete_file, or rename/move file, and no way to fetch compiled output (only log errors) or download an uploaded binary. An agent cannot remove a file or start a new project, which are realistic requests.
Maintenance
Related MCP Connectors
Search and read arXiv research papers via a hosted, read-only MCP server.
A MCP server built for developers enabling Git based project management with project and personal…
Edit your Overleaf LaTeX projects from Claude and ChatGPT; every change is a real Git commit.
Notes, files, GitHub, and Drive through one MCP connection.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server for interacting with Overleaf projects, enabling project listing, file reads, LaTeX section discovery, and revision-guarded writes through natural language.AGPL 3.0
- AlicenseAqualityDmaintenanceEnables AI agents to read, write, compile, and manage Overleaf projects through MCP, including file operations, project administration, and LaTeX compilation diagnostics.16MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to read, edit, upload, compile, and manage projects in a self-hosted Overleaf Community Edition via MCP, while also providing a git remote for cloning and pushing changes.1MIT
- AlicenseAqualityCmaintenanceEnables collaborative LaTeX editing on Overleaf with tracked changes, review comments, compilation, file management, and downloads via a single MCP connection.261AGPL 3.0