@cadivus/mcp-server-lo-doc-reader 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,174 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # mcp-server-lo-doc-reader
2
+
3
+ **The local-first, privacy-focused MCP server for high-fidelity document parsing.**
4
+
5
+ `lo-doc-reader` is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that enables AI assistants (like Claude, Cursor, and Windsurf) to read complex documents by leveraging a local LibreOffice installation.
6
+
7
+ ## 🌟 Why lo-doc-reader?
8
+
9
+ While many document parsers struggle with complex layouts or legacy formats, `lo-doc-reader` uses the battle-tested LibreOffice engine to provide:
10
+
11
+ * **🔒 Absolute Privacy:** Your documents never leave your machine. No cloud APIs, no data collection, and no third-party processing.
12
+ * **🏛️ Superior Legacy Support:** Seamlessly handles `.doc`, `.rtf`, and older formats that break modern lightweight libraries.
13
+ * **⚙️ Headless Efficiency:** Runs in the background using isolated user profiles. It won't interfere with your open LibreOffice windows or documents.
14
+ * **💰 Zero Cost:** No per-page fees or subscription limits.
15
+
16
+ ## 🚀 Quick Start
17
+
18
+ ### Prerequisites
19
+ * **Node.js** ≥ 18
20
+ * **LibreOffice** ≥ 24.2 ([Download here](https://www.libreoffice.org/download/download/))
21
+
22
+ ### MCP Client Configuration
23
+ Add this to your `claude_desktop_config.json` or equivalent client settings:
24
+
25
+ ```json
26
+ {
27
+ "mcpServers": {
28
+ "lo-doc-reader": {
29
+ "command": "npx",
30
+ "args": ["-y", "@cadivus/mcp-server-lo-doc-reader"]
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ ## 📂 Supported File Formats
37
+
38
+ | Extension | Description |
39
+ | :--- | :--- |
40
+ | `.docx` / `.doc` | Microsoft Word (Modern & Legacy) |
41
+ | `.odt` / `.fodt` | OpenDocument Text / Flat XML |
42
+ | `.rtf` | Rich Text Format |
43
+ | `.epub` | Electronic Publication (E-books) |
44
+ | `.html` / `.htm` | Web Documents |
45
+
46
+ ## 🛠️ How It Works
47
+ 1. **Detection:** Automatically finds the `soffice` binary across macOS, Windows, and Linux.
48
+ 2. **Sandboxing:** Creates a temporary, isolated user profile for every request to ensure thread safety and prevent configuration conflicts.
49
+ 3. **Conversion:** Invokes a headless instance of LibreOffice to perform a native export to Markdown.
50
+ 4. **Cleanup:** Instantly purges all temporary files and profiles once the content is delivered to your LLM.
51
+
52
+ ## 🧰 Available Tools
53
+
54
+ ### `read_document`
55
+ Extracts text from a document and returns it as LLM-optimized Markdown.
56
+ * **Input:** `filePath` (The **absolute path** to your file).
57
+
58
+ ### `list_supported_formats`
59
+ Displays all extensions currently supported by your local installation.
60
+
61
+ ## ⚠️ Limitations & Notes
62
+ * **Formatting:** Complexity is limited by LibreOffice's Markdown export filter (tables and images may have simplified rendering).
63
+ * **Scopes:** Spreadsheets (`.xlsx`) and Presentations (`.pptx`) are not currently supported.
64
+ * **Paths:** Ensure you provide the *absolute* path to the file so the server can locate it reliably.
65
+
66
+ ## 🏷️ Keywords & Use Cases
67
+ `mcp-server`, `context-window`, `RAG`, `local-llm`, `document-parsing`, `privacy-focused-ai`, `word-to-markdown`, `offline-ai-tools`, `claude-desktop-tools`.
68
+
69
+ ## 📜 License
70
+
71
+ Copyright © 2026. Licensed under the **Apache License, Version 2.0**.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Convert a document to Markdown using LibreOffice.
3
+ * Creates unique temp directories for output and user profile to avoid conflicts.
4
+ * Cleans up directories after conversion (even on failure).
5
+ *
6
+ * Requires LibreOffice 26.2+ for Markdown export support.
7
+ */
8
+ export declare function convertToMarkdown(sofficePath: string, filePath: string): Promise<string>;
9
+ //# sourceMappingURL=converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CA2DjB"}
@@ -0,0 +1,68 @@
1
+ import { mkdtemp, readFile, rm } from "fs/promises";
2
+ import { execFile } from "child_process";
3
+ import { promisify } from "util";
4
+ import { tmpdir } from "os";
5
+ import { basename, extname, join } from "path";
6
+ const execFileAsync = promisify(execFile);
7
+ /**
8
+ * Convert a document to Markdown using LibreOffice.
9
+ * Creates unique temp directories for output and user profile to avoid conflicts.
10
+ * Cleans up directories after conversion (even on failure).
11
+ *
12
+ * Requires LibreOffice 26.2+ for Markdown export support.
13
+ */
14
+ export async function convertToMarkdown(sofficePath, filePath) {
15
+ // Create temp directories - mkdtemp appends random characters, so we capture the actual paths
16
+ const tmpDir = await mkdtemp(join(tmpdir(), "read-mcp-"));
17
+ const profileDir = await mkdtemp(join(tmpdir(), "read-mcp-profile-"));
18
+ try {
19
+ // Get the base filename without extension
20
+ const baseName = basename(filePath, extname(filePath));
21
+ const expectedMdFile = join(tmpDir, `${baseName}.md`);
22
+ // Run soffice conversion with unique user profile
23
+ // Use file:// protocol for the profile directory (required by LibreOffice)
24
+ const profileUrl = `file://${profileDir}`;
25
+ // Run Markdown conversion
26
+ await execFileAsync(sofficePath, [
27
+ "--headless",
28
+ `-env:UserInstallation=${profileUrl}`,
29
+ "--convert-to",
30
+ "md:Markdown",
31
+ "--outdir",
32
+ tmpDir,
33
+ filePath,
34
+ ], {
35
+ encoding: "utf8",
36
+ timeout: 30000, // 30 second timeout
37
+ });
38
+ // Check if Markdown file was created
39
+ try {
40
+ const markdownContent = await readFile(expectedMdFile, "utf8");
41
+ // Unescape backslash-escaped < and > characters
42
+ const unescapedContent = markdownContent
43
+ .replace(/\\</g, "<")
44
+ .replace(/\\>/g, ">");
45
+ return unescapedContent;
46
+ }
47
+ catch {
48
+ throw new Error("Conversion failed: Markdown output file was not created. " +
49
+ "Your LibreOffice version may be too old (Markdown export requires LibreOffice 26.2+).");
50
+ }
51
+ }
52
+ finally {
53
+ // Clean up temp directories (ignore errors)
54
+ try {
55
+ await rm(tmpDir, { recursive: true, force: true });
56
+ }
57
+ catch {
58
+ // Ignore cleanup errors
59
+ }
60
+ try {
61
+ await rm(profileDir, { recursive: true, force: true });
62
+ }
63
+ catch {
64
+ // Ignore cleanup errors
65
+ }
66
+ }
67
+ }
68
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,MA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AgB,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CACb,2DAA2D;gBAC3D,uFAAuF,CACxF,CAAC;QACJ,CAAC;IACH,CAAC;YAAS,CAAC;QACT,4CAA4C;QAC5C,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;QACD,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Supported file extensions and their descriptions */
2
+ export declare const SUPPORTED_FORMATS: Record<string, string>;
3
+ export declare const SUPPORTED_EXTENSIONS: string[];
4
+ //# sourceMappingURL=formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CASpD,CAAC;AAEF,eAAO,MAAM,oBAAoB,UAAiC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** Supported file extensions and their descriptions */
2
+ export const SUPPORTED_FORMATS = {
3
+ ".docx": "Microsoft Word document (Office Open XML)",
4
+ ".doc": "Microsoft Word document (legacy format)",
5
+ ".odt": "OpenDocument Text",
6
+ ".rtf": "Rich Text Format",
7
+ ".html": "HTML document",
8
+ ".htm": "HTML document",
9
+ ".epub": "Electronic Publication",
10
+ ".fodt": "Flat XML ODF Text Document",
11
+ };
12
+ export const SUPPORTED_EXTENSIONS = Object.keys(SUPPORTED_FORMATS);
13
+ //# sourceMappingURL=formats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.js","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAA2B;IACvD,OAAO,EAAE,2CAA2C;IACpD,MAAM,EAAE,yCAAyC;IACjD,MAAM,EAAE,mBAAmB;IAC3B,MAAM,EAAE,kBAAkB;IAC1B,OAAO,EAAE,eAAe;IACxB,MAAM,EAAE,eAAe;IACvB,OAAO,EAAE,wBAAwB;IACjC,OAAO,EAAE,4BAA4B;CACtC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { createServer } from "./server.js";
4
+ async function main() {
5
+ // Create the server
6
+ const { server, sofficePath } = await createServer();
7
+ // Log LibreOffice status to stderr
8
+ if (sofficePath) {
9
+ console.error(`[read-mcp] LibreOffice detected: ${sofficePath}`);
10
+ }
11
+ else {
12
+ console.error("[read-mcp] Warning: LibreOffice not found. Please install LibreOffice to use document conversion features.");
13
+ }
14
+ const transport = new StdioServerTransport();
15
+ await server.connect(transport);
16
+ }
17
+ main().catch((error) => {
18
+ console.error("Fatal error:", error);
19
+ process.exit(1);
20
+ });
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,KAAK,UAAU,IAAI;IACjB,oBAAoB;IACpB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,YAAY,EAAE,CAAC;IAErD,mCAAmC;IACnC,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,oCAAoC,WAAW,EAAE,CAAC,CAAC;IACnE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CACX,4GAA4G,CAC7G,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ /**
3
+ * Create and configure the MCP server with tool handlers.
4
+ * Returns the server instance and the detected soffice path.
5
+ */
6
+ export declare function createServer(): Promise<{
7
+ server: Server;
8
+ sofficePath: string | null;
9
+ }>;
10
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAiBnE;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC,CA6KD"}
package/dist/server.js ADDED
@@ -0,0 +1,172 @@
1
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
3
+ import { access, constants } from "fs/promises";
4
+ import { extname } from "path";
5
+ import { z } from "zod";
6
+ import { findSoffice } from "./soffice.js";
7
+ import { convertToMarkdown } from "./converter.js";
8
+ import { SUPPORTED_FORMATS, SUPPORTED_EXTENSIONS } from "./formats.js";
9
+ // Zod schema for read_document tool input
10
+ const ReadDocumentSchema = z.object({
11
+ filePath: z.string().min(1, "filePath is required"),
12
+ });
13
+ /**
14
+ * Create and configure the MCP server with tool handlers.
15
+ * Returns the server instance and the detected soffice path.
16
+ */
17
+ export async function createServer() {
18
+ const server = new Server({
19
+ name: "read-mcp",
20
+ version: "0.1.0",
21
+ }, {
22
+ capabilities: {
23
+ tools: {},
24
+ },
25
+ });
26
+ // Detect LibreOffice on startup
27
+ const sofficePath = await findSoffice();
28
+ // Handler for listing available tools
29
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
30
+ return {
31
+ tools: [
32
+ {
33
+ name: "read_document",
34
+ description: "Converts a document file to Markdown and returns the content. " +
35
+ "Supports: .docx, .doc, .odt, .rtf, .html, .htm, .epub, .fodt. " +
36
+ "Requires LibreOffice to be installed on the system. " +
37
+ "The file path must be an absolute path to an existing file.",
38
+ inputSchema: {
39
+ type: "object",
40
+ properties: {
41
+ filePath: {
42
+ type: "string",
43
+ description: "Absolute path to the document file to convert",
44
+ },
45
+ },
46
+ required: ["filePath"],
47
+ },
48
+ },
49
+ {
50
+ name: "list_supported_formats",
51
+ description: "Returns the list of supported file extensions and their descriptions. " +
52
+ "Use this to check which file types can be converted before calling read_document.",
53
+ inputSchema: {
54
+ type: "object",
55
+ properties: {},
56
+ },
57
+ },
58
+ ],
59
+ };
60
+ });
61
+ // Handler for tool calls
62
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
63
+ const { name, arguments: args } = request.params;
64
+ if (name === "read_document") {
65
+ // Validate input with zod
66
+ const parseResult = ReadDocumentSchema.safeParse(args);
67
+ if (!parseResult.success) {
68
+ return {
69
+ content: [
70
+ {
71
+ type: "text",
72
+ text: `Invalid input: ${parseResult.error.errors.map((e) => e.message).join(", ")}`,
73
+ },
74
+ ],
75
+ isError: true,
76
+ };
77
+ }
78
+ const { filePath } = parseResult.data;
79
+ // Check if LibreOffice was detected
80
+ if (!sofficePath) {
81
+ return {
82
+ content: [
83
+ {
84
+ type: "text",
85
+ text: "LibreOffice not found. Please install LibreOffice to use document conversion features. " +
86
+ "Visit https://www.libreoffice.org/download/download/ for installation instructions.",
87
+ },
88
+ ],
89
+ isError: true,
90
+ };
91
+ }
92
+ // Validate file exists
93
+ try {
94
+ await access(filePath, constants.F_OK);
95
+ }
96
+ catch {
97
+ return {
98
+ content: [
99
+ {
100
+ type: "text",
101
+ text: `File not found: ${filePath}`,
102
+ },
103
+ ],
104
+ isError: true,
105
+ };
106
+ }
107
+ // Validate extension is supported
108
+ const ext = extname(filePath).toLowerCase();
109
+ if (!SUPPORTED_EXTENSIONS.includes(ext)) {
110
+ return {
111
+ content: [
112
+ {
113
+ type: "text",
114
+ text: `Unsupported file extension: ${ext}. ` +
115
+ `Supported formats: ${SUPPORTED_EXTENSIONS.join(", ")}. ` +
116
+ `Use list_supported_formats for more details.`,
117
+ },
118
+ ],
119
+ isError: true,
120
+ };
121
+ }
122
+ // Convert the document
123
+ try {
124
+ const markdownContent = await convertToMarkdown(sofficePath, filePath);
125
+ return {
126
+ content: [
127
+ {
128
+ type: "text",
129
+ text: markdownContent,
130
+ },
131
+ ],
132
+ };
133
+ }
134
+ catch (error) {
135
+ const errorMessage = error instanceof Error ? error.message : String(error);
136
+ return {
137
+ content: [
138
+ {
139
+ type: "text",
140
+ text: `Conversion failed: ${errorMessage}`,
141
+ },
142
+ ],
143
+ isError: true,
144
+ };
145
+ }
146
+ }
147
+ if (name === "list_supported_formats") {
148
+ const formatsList = Object.entries(SUPPORTED_FORMATS)
149
+ .map(([ext, desc]) => `${ext}: ${desc}`)
150
+ .join("\n");
151
+ return {
152
+ content: [
153
+ {
154
+ type: "text",
155
+ text: `Supported file formats:\n\n${formatsList}`,
156
+ },
157
+ ],
158
+ };
159
+ }
160
+ return {
161
+ content: [
162
+ {
163
+ type: "text",
164
+ text: `Unknown tool: ${name}`,
165
+ },
166
+ ],
167
+ isError: true,
168
+ };
169
+ });
170
+ return { server, sofficePath };
171
+ }
172
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEvE,0CAA0C;AAC1C,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC;CACpD,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAIhC,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;QACE,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,OAAO;KACjB,EACD;QACE,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE;SACV;KACF,CACF,CAAC;IAEF,gCAAgC;IAChC,MAAM,WAAW,GAAG,MAAM,WAAW,EAAE,CAAC;IAExC,sCA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gBACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACzD,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,sBAAsB,YAAY,EAAE;yBAC3C;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;QACH,CAAC;QAED,IAAI,IAAI,KAAK,wBAAwB,EAAE,CAAC;YACtC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;iBAClD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,IAAI,EAAE,CAAC;iBACvC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,8BAA8B,WAAW,EAAE;qBAClD;iBACF;aACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,iBAAiB,IAAI,EAAE;iBAC9B;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Reset the soffice path cache. Useful for testing.
3
+ */
4
+ export declare function resetSofficeCache(): void;
5
+ /**
6
+ * Find the soffice binary using platform-specific detection strategy.
7
+ * Returns the absolute path or null if not found.
8
+ * Result is cached after first call.
9
+ */
10
+ export declare function findSoffice(): Promise<string | null>;
11
+ //# sourceMappingURL=soffice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"soffice.d.ts","sourceRoot":"","sources":["../src/soffice.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AA6BD;;;;GAIG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAsG1D"}
@@ -0,0 +1,135 @@
1
+ import { access, constants } from "fs/promises";
2
+ import { execFile } from "child_process";
3
+ import { promisify } from "util";
4
+ import { platform } from "os";
5
+ import { join } from "path";
6
+ const execFileAsync = promisify(execFile);
7
+ // Cache for the soffice path (detected once per server lifetime)
8
+ let sofficePathCache = undefined;
9
+ /**
10
+ * Reset the soffice path cache. Useful for testing.
11
+ */
12
+ export function resetSofficeCache() {
13
+ sofficePathCache = undefined;
14
+ }
15
+ /**
16
+ * Check if a file exists and is executable
17
+ */
18
+ async function isExecutable(path) {
19
+ try {
20
+ await access(path, constants.X_OK);
21
+ return true;
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ }
27
+ /**
28
+ * Run a command and return its stdout, or null if it fails
29
+ */
30
+ async function runCommand(command, args = []) {
31
+ try {
32
+ const { stdout } = await execFileAsync(command, args, { encoding: "utf8" });
33
+ return stdout.trim();
34
+ }
35
+ catch {
36
+ return null;
37
+ }
38
+ }
39
+ /**
40
+ * Find the soffice binary using platform-specific detection strategy.
41
+ * Returns the absolute path or null if not found.
42
+ * Result is cached after first call.
43
+ */
44
+ export async function findSoffice() {
45
+ // Return cached result if already computed
46
+ if (sofficePathCache !== undefined) {
47
+ return sofficePathCache;
48
+ }
49
+ const currentPlatform = platform();
50
+ const candidates = [];
51
+ if (currentPlatform === "darwin") {
52
+ // macOS detection strategy
53
+ // Priority 1: Standard Applications path
54
+ candidates.push("/Applications/LibreOffice.app/Contents/MacOS/soffice");
55
+ // Priority 2: Use mdfind to locate LibreOffice
56
+ const mdfindResult = await runCommand("mdfind", [
57
+ "kMDItemCFBundleIdentifier == 'org.libreoffice.script'",
58
+ ]);
59
+ if (mdfindResult) {
60
+ const appPath = mdfindResult.split("\n")[0]; // Take first result
61
+ if (appPath) {
62
+ candidates.push(join(appPath, "Contents/MacOS/soffice"));
63
+ }
64
+ }
65
+ }
66
+ else if (currentPlatform === "linux") {
67
+ // Linux detection strategy
68
+ // Priority 3 & 4: Check PATH and common locations
69
+ candidates.push("/usr/bin/soffice", "/usr/lib/libreoffice/program/soffice", "/snap/bin/libreoffice");
70
+ }
71
+ else if (currentPlatform === "win32") {
72
+ // Windows detection strategy
73
+ // Priority 5 & 6: Program Files directories
74
+ candidates.push("C:\\Program Files\\LibreOffice\\program\\soffice.exe", "C:\\Program Files (x86)\\LibreOffice\\program\\soffice.exe");
75
+ }
76
+ // Try all platform-specific candidates
77
+ for (const candidate of candidates) {
78
+ if (await isExecutable(candidate)) {
79
+ sofficePathCache = candidate;
80
+ return candidate;
81
+ }
82
+ }
83
+ // Priority 7: Final fallback using which/where on all platforms
84
+ const whichCommand = currentPlatform === "win32" ? "where" : "which";
85
+ const whichResult = await runCommand(whichCommand, ["soffice"]);
86
+ if (whichResult) {
87
+ const path = whichResult.split("\n")[0]; // Take first result
88
+ if (path) {
89
+ sofficePathCache = path;
90
+ return path;
91
+ }
92
+ }
93
+ // Priority 8: Try libreoffice (some distros use this name)
94
+ const libreofficeResult = await runCommand(whichCommand, ["libreoffice"]);
95
+ if (libreofficeResult) {
96
+ const path = libreofficeResult.split("\n")[0];
97
+ if (path) {
98
+ sofficePathCache = path;
99
+ return path;
100
+ }
101
+ }
102
+ // Priority 9: Try to find versioned libreoffice executables (e.g., libreoffice26.2, libreoffice24.8)
103
+ // These are common when installing from DEB packages from the LibreOffice website
104
+ if (currentPlatform === "linux") {
105
+ // Search for any libreoffice* executable in common bin directories
106
+ const searchDirs = ["/usr/local/bin", "/usr/bin", "/opt/bin"];
107
+ for (const dir of searchDirs) {
108
+ try {
109
+ const { stdout } = await execFileAsync("ls", [dir], {
110
+ encoding: "utf8",
111
+ });
112
+ // Filter for files starting with "libreoffice" (includes versioned ones like libreoffice26.2)
113
+ const files = stdout
114
+ .split("\n")
115
+ .filter((f) => f.startsWith("libreoffice"));
116
+ // Sort to get the highest version first (e.g., libreoffice26.2 > libreoffice26)
117
+ files.sort().reverse();
118
+ for (const file of files) {
119
+ const fullPath = join(dir, file);
120
+ if (await isExecutable(fullPath)) {
121
+ sofficePathCache = fullPath;
122
+ return fullPath;
123
+ }
124
+ }
125
+ }
126
+ catch {
127
+ // Directory doesn't exist or can't be read, continue to next
128
+ }
129
+ }
130
+ }
131
+ // Not found
132
+ sofficePathCache = null;
133
+ return null;
134
+ }
135
+ //# sourceMappingURL=soffice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"soffice.js","sourceRoot":"","sources":["../src/soffice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,iEAAiE;AACjE,IAAI,gBAAgB,GAA8B,SAAS,CAAC;AAE5D;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,gBAAgB,GAAG,SAAS,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,YAAY,CAAC,IAAY;IACtC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,UAAU,CACvB,OAAe,EACf,OAAiB,EAAE;IAEnB,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE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EAAE,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE;oBAClD,QAAQ,EAAE,MAAM;iBACjB,CAAC,CAAC;gBACH,8FAA8F;gBAC9F,MAAM,KAAK,GAAG,MAAM;qBACjB,KAAK,CAAC,IAAI,CAAC;qBACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;gBAC9C,gFAAgF;gBAChF,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;gBACvB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;oBACjC,IAAI,MAAM,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;wBACjC,gBAAgB,GAAG,QAAQ,CAAC;wBAC5B,OAAO,QAAQ,CAAC;oBAClB,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,6DAA6D;YAC/D,CAAC;QACH,CAAC;IACH,CAAC;IAED,YAAY;IACZ,gBAAgB,GAAG,IAAI,CAAC;IACxB,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@cadivus/mcp-server-lo-doc-reader",
3
+ "version": "0.1.0",
4
+ "description": "LibreOffice Document Reader MCP Server - converts documents to Markdown via MCP",
5
+ "type": "module",
6
+ "bin": {
7
+ "mcp-server-lo-doc-reader": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "start": "node dist/index.js",
15
+ "test": "tsx --test test/*.test.ts",
16
+ "test:e2e": "cd e2e-tests && npm test",
17
+ "typecheck": "tsc --noEmit",
18
+ "typecheck:all": "tsc --noEmit -p tsconfig.test.json"
19
+ },
20
+ "keywords": [
21
+ "mcp",
22
+ "libreoffice",
23
+ "document",
24
+ "markdown",
25
+ "docx",
26
+ "odt",
27
+ "converter"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git@github.com:cadivus/mcp-server-lo-doc-reader.git"
36
+ },
37
+ "dependencies": {
38
+ "@modelcontextprotocol/sdk": "^1.0.0",
39
+ "zod": "^3.22.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^20.0.0",
43
+ "tsx": "^4.21.0",
44
+ "typescript": "^5.0.0"
45
+ }
46
+ }