latexmk-mcp 1.0.0 → 2.0.0

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.

Potentially problematic release.


This version of latexmk-mcp might be problematic. Click here for more details.

package/.codex ADDED
File without changes
package/AGENTS.md ADDED
@@ -0,0 +1,26 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+ The runtime is split across three source files. `src/index.ts` is the thin MCP entrypoint: tool metadata, server setup, and request dispatch. `src/handlers.ts` contains Zod schemas plus the tool implementations for compile, clean, dependency listing, watch sessions, config management, and citation inspection. `src/parser.ts` contains the structured LaTeX log parser. Tests live in `tests/`: `tests/index.test.ts` covers log parsing, and `tests/handlers.test.ts` covers config and citation handlers. `dist/` is generated output and should not be edited.
5
+
6
+ ## Build, Test, and Development Commands
7
+ Use the scripts from `package.json`:
8
+
9
+ - `bun run dev`: run the server directly from `src/index.ts`.
10
+ - `bun run build`: compile TypeScript to `dist/` with `tsc`.
11
+ - `bun test`: execute the Bun test suite.
12
+ - `node dist/index.js`: run the built MCP server over stdio.
13
+
14
+ Run `bun run build` before release; `prepublishOnly` already enforces it.
15
+
16
+ ## Coding Style & Naming Conventions
17
+ Write strict TypeScript as ESM with `NodeNext` conventions. Match the existing style in [`src/handlers.ts`](/home/aidan/projects/latexmk-mcp/src/handlers.ts) and [`src/parser.ts`](/home/aidan/projects/latexmk-mcp/src/parser.ts): 2-space indentation, double quotes, semicolons, and descriptive names such as `CompileSchema`, `handleCompile`, and `ParsedWarning`. Keep schemas and handler behavior in sync when tool inputs change.
18
+
19
+ ## Testing Guidelines
20
+ Tests use Bun's built-in runner via `bun:test`. Add new cases under `tests/*.test.ts` and name them after the behavior being verified, for example `should identify box warnings and dimensions`. Prefer file-based tests for handlers that can run against temp directories without a live `latexmk` install. If you add subprocess-heavy features such as watch mode, introduce a small seam or wrapper before trying to test them. Run `bun test` and `bun run build` before opening a pull request.
21
+
22
+ ## Commit & Pull Request Guidelines
23
+ Recent history favors small, incremental commits with a Conventional Commit lean, such as `refactor: split server entrypoint from handlers`, `feat: add structured latex log parsing`, and `test: cover config and citation handlers`. Prefer `refactor:`, `feat:`, `fix:`, `test:`, and `docs:` where they fit. Keep pull requests focused, explain user-visible behavior changes, and include relevant test/build results.
24
+
25
+ ## Security & Configuration Tips
26
+ This project shells out to `latexmk`, so validate new inputs before they reach `execFile` or `spawn`. Avoid passing unchecked command fragments through `extra_args`, and document any feature that depends on TeX binaries or `latexmk` being present on `$PATH`. Watch sessions are kept in memory only, so design follow-up changes with process cleanup in mind.
package/README.md CHANGED
@@ -7,7 +7,7 @@ A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that e
7
7
  ## Prerequisites
8
8
 
9
9
  - **Node.js** 18+
10
- - **latexmk** installed and on `$PATH` (usually ships with TeX Live or MiKTeX)
10
+ - **latexmk** installed and on `$PATH` (usually ships with major TeX distributions such as TeX Live or MiKTeX)
11
11
  - A TeX distribution with your required engines (`pdflatex`, `xelatex`, `lualatex`, …)
12
12
 
13
13
  ```bash
@@ -23,31 +23,13 @@ sudo pacman -S texlive-most
23
23
 
24
24
  ---
25
25
 
26
- ## Installation & Build
26
+ ## Installation
27
27
 
28
28
  ```bash
29
- git clone <this-repo>
30
- cd latexmk-mcp
31
- npm install
32
- npm run build # outputs to dist/
29
+ npx latexmk-mcp
33
30
  ```
34
31
 
35
- ---
36
-
37
- ## Running
38
-
39
- ```bash
40
- # Direct
41
- node dist/index.js
42
-
43
- # Via npm
44
- npm start
45
-
46
- # During development (no build step)
47
- npm run dev
48
- ```
49
-
50
- The server communicates over **stdio** (standard MCP transport).
32
+ This is the standard MCP usage pattern: no global install is required. `npx` downloads the published package and runs the stdio server on demand.
51
33
 
52
34
  ---
53
35
 
@@ -59,13 +41,15 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
59
41
  {
60
42
  "mcpServers": {
61
43
  "latexmk": {
62
- "command": "node",
63
- "args": ["/absolute/path/to/latexmk-mcp/dist/index.js"]
44
+ "command": "npx",
45
+ "args": ["-y", "latexmk-mcp"]
64
46
  }
65
47
  }
66
48
  }
67
49
  ```
68
50
 
51
+ The server communicates over **stdio** (standard MCP transport).
52
+
69
53
  ---
70
54
 
71
55
  ## Tools
@@ -84,8 +68,9 @@ Full compile of a LaTeX document with configurable engine, output format, biblio
84
68
  | `synctex` | boolean | `false` | Generate SyncTeX data |
85
69
  | `extra_args` | string[] | `[]` | Extra latexmk CLI flags |
86
70
  | `working_dir` | string | temp dir | Build directory |
71
+ | `return_pdf` | boolean | `false` | Return compiled PDF as base64 when building PDF output |
87
72
 
88
- **Returns:** `success`, `exit_code`, `output_file` path, `errors[]`, `warnings[]`, `working_dir`, `stdout`, `stderr`.
73
+ **Returns:** `success`, `exit_code`, `output_file`, `page_count`, structured `errors[]`, structured `warnings[]`, `missing_packages[]`, `install_hints[]`, `working_dir`, `stdout`, `stderr`, and optional `pdf_base64`.
89
74
 
90
75
  ---
91
76
 
@@ -99,7 +84,7 @@ Fast single-pass compile (no reruns, no bibliography) — ideal for quick syntax
99
84
  | `engine` | string | `pdflatex` | TeX engine |
100
85
  | `working_dir` | string | temp dir | Build directory |
101
86
 
102
- **Returns:** `success`, `errors[]`, `warnings[]`, `stdout`, `stderr`.
87
+ **Returns:** `success`, structured `errors[]`, structured `warnings[]`, `missing_packages[]`, `install_hints[]`, `stdout`, `stderr`.
103
88
 
104
89
  ---
105
90
 
@@ -134,12 +119,33 @@ List all file dependencies of a document (included `.tex` files, `.bib` files, p
134
119
 
135
120
  ---
136
121
 
122
+ ### `latexmk_watch_start` / `latexmk_watch_stop` / `latexmk_watch_list`
123
+ Manage background `latexmk -pvc` watch sessions. Start returns a `session_id`; stop terminates it; list shows active sessions with PID, job name, and start time.
124
+
125
+ ---
126
+
127
+ ### `latexmk_write_config` / `latexmk_read_config`
128
+ Write or inspect `.latexmkrc` files. The write tool can set engine, output mode, shell escape, extra `pdflatex` args, and custom Perl rules.
129
+
130
+ ---
131
+
132
+ ### `latexmk_list_citations`
133
+ Extract citation keys from LaTeX source and optionally compare them to a `.bib` file.
134
+
135
+ **Returns:** `cited_keys[]`, `cited_count`, and when `bib_path` is provided, `bib_entries[]`, `missing_from_bib[]`, and `unused_in_bib[]`.
136
+
137
+ ---
138
+
137
139
  ## Development
138
140
 
139
141
  ```bash
140
- npm run dev # run with tsx (no build needed)
141
- npm run build # compile TypeScript → dist/
142
- npm start # run compiled output
142
+ git clone <this-repo>
143
+ cd latexmk-mcp
144
+ npm install
145
+ bun run dev # run directly from src/index.ts
146
+ bun test # run tests
147
+ bun run build # compile TypeScript -> dist/
148
+ node dist/index.js
143
149
  ```
144
150
 
145
151
  ---