Skip to main content
Glama
DietSense LaTeX MCP Server

DietSense LaTeX MCP Server

by yeeliyay

DietSense LaTeX MCP Server

Local-first LaTeX editing through Claude Desktop, Claude Code and Codex. Inspired by the workflow of community Overleaf MCP servers, but independently implemented for a controlled, GitHub-ready Python project.

輸出的pdf: An Evidence-Grounded AI Agent for Natural-Language Nutrition and Exercise Tracking A Verifiable System Design.pdf

Status: Working local MCP project scaffold. Tested Python editing core and LaTeX compilation. Claude Desktop/remote Overleaf interactions require configuration on your own machine. This is not an official Overleaf product, and does not access Overleaf private APIs.

Interaction model

Claude conversation → MCP tools → read → preview diff → human approval → edit+backup → pdfLaTeX build → diagnostics → optional git fetch / approved push

Features

MCP tool

Purpose

list_paper_sections, read_paper_section

Navigate \section, abstract and keywords

search_paper_text

Locate exact phrases

preview_section_edit

View a unified diff without writing

apply_section_edit

Edit with SHA-256 concurrency guard and backup

compile_and_diagnose

Run pdfLaTeX twice without shell escape; show warnings

restore_backup

Return to an earlier version

list_project_files, read_project_file

Inspect safe project text assets

git_sync_status, git_fetch_remote, git_push_to_overleaf

Optional Git Bridge with explicit push consent

Related MCP server: overleaf-multi-mcp

OpenSpec (spec-driven development)

This repository includes an openspec/ specification scaffold and a proposed (not yet implemented) add-pdf-layout-inspection change.

OpenSpec is a development-planning layer, not a replacement for the Python MCP server. Install the OpenSpec CLI with a compatible Node.js version, then run openspec init in the repository root to configure your supported coding assistant (e.g., Claude Code or Codex). Claude Desktop MCP configuration remains separate.

Read Windows OpenSpec instructions, baseline specifications, and the PDF layout inspection proposal.

Quick start (Windows)

Prerequisites: Python 3.11+, a TeX distribution (MiKTeX / TeX Live), optionally Git.

cd D:\DietSense-LaTeX-MCP
py -m venv .venv
.venv\Scripts\python.exe -m pip install -r requirements.txt
.venv\Scripts\python.exe -m unittest discover -s tests -v

Edit configs/claude-desktop-config.json to replace C:/PATH/TO/... with absolute paths. Paste the mcpServers object into Claude Desktop MCP configuration, usually %APPDATA%\Claude\claude_desktop_config.json on Windows, then restart Claude Desktop. The process launches with stdio; do not run server.py in a terminal and type chat messages into it.

Codex: use configs/codex-config.toml and place it into your Codex config as documented for your client.

Example prompts

  • 「列出 DietSense 的所有論文章節並讀取 Abstract」

  • 「把 Related Work 改成學術英文,但先預覽 diff,不要直接修改」

  • 「我確認這次差異,套用並重新編譯」

  • 「檢查第三頁表格超出欄寬的 LaTeX warning,先指出可能原因」

  • 「查看目前 Git 同步狀態;不要 push」

GitHub upload

Create an empty repository named DietSense-LaTeX-MCP, then run in this extracted folder:

git init
git add .
git commit -m "Initial commit: DietSense LaTeX MCP"
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/DietSense-LaTeX-MCP.git
git push -u origin main

A GitHub repository does not automatically make the MCP server run in Claude. Claude Desktop must separately start the local Python server.

Optional Overleaf bridge

Official Overleaf Git Integration is plan/owner dependent. If enabled, use your Overleaf project's Git URL to clone its LaTeX working tree separately, point LATEX_PROJECT_ROOT at that local clone and configure the Git remote name overleaf. Authenticate using Git Credential Manager, not token literals in tracked configs. The git_fetch_remote tool fetches only: it does not auto-merge. Pushing requires both a clean working tree and explicit user permission. See docs/OVERLEAF.md.

Safety and known limits

  • Editing tools work on main.tex; other text files can be inspected but not modified through these MCP tools.

  • Section matching assumes ordinary \section{...} headings in one main.tex. Duplicate headings and nested section replacement should be reviewed carefully.

  • Compilation needs pdflatex on PATH. No automatic PDF screenshot vision/layout repair is supplied.

  • An LLM client proposes replacement LaTeX; the server itself does not call GPT/Gemini.

  • Only document projects you trust should be compiled; TeX can read local files despite disabled shell escape. Run this server under a low-privilege user, never on untrusted projects with secrets nearby.

  • main.pdf is included only as the original sample if present, not generated by the MCP on every GitHub commit.

References

Licensed MIT. See LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers