@zengjing/xmind-mcp 1.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.
- package/LICENSE +21 -0
- package/README.md +574 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +170 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/legacy-parser.d.ts +63 -0
- package/dist/core/legacy-parser.d.ts.map +1 -0
- package/dist/core/legacy-parser.js +139 -0
- package/dist/core/legacy-parser.js.map +1 -0
- package/dist/core/parser.d.ts +19 -0
- package/dist/core/parser.d.ts.map +1 -0
- package/dist/core/parser.js +111 -0
- package/dist/core/parser.js.map +1 -0
- package/dist/core/zen-parser.d.ts +15 -0
- package/dist/core/zen-parser.d.ts.map +1 -0
- package/dist/core/zen-parser.js +90 -0
- package/dist/core/zen-parser.js.map +1 -0
- package/dist/formatters/json-formatter.d.ts +69 -0
- package/dist/formatters/json-formatter.d.ts.map +1 -0
- package/dist/formatters/json-formatter.js +131 -0
- package/dist/formatters/json-formatter.js.map +1 -0
- package/dist/formatters/markdown-formatter.d.ts +40 -0
- package/dist/formatters/markdown-formatter.d.ts.map +1 -0
- package/dist/formatters/markdown-formatter.js +136 -0
- package/dist/formatters/markdown-formatter.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +117 -0
- package/dist/index.js.map +1 -0
- package/dist/model/schemas.d.ts +54 -0
- package/dist/model/schemas.d.ts.map +1 -0
- package/dist/model/schemas.js +64 -0
- package/dist/model/schemas.js.map +1 -0
- package/dist/model/types.d.ts +79 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +6 -0
- package/dist/model/types.js.map +1 -0
- package/dist/tools/branch-tool.d.ts +20 -0
- package/dist/tools/branch-tool.d.ts.map +1 -0
- package/dist/tools/branch-tool.js +150 -0
- package/dist/tools/branch-tool.js.map +1 -0
- package/dist/tools/parse-tool.d.ts +27 -0
- package/dist/tools/parse-tool.d.ts.map +1 -0
- package/dist/tools/parse-tool.js +126 -0
- package/dist/tools/parse-tool.js.map +1 -0
- package/dist/tools/search-tool.d.ts +27 -0
- package/dist/tools/search-tool.d.ts.map +1 -0
- package/dist/tools/search-tool.js +179 -0
- package/dist/tools/search-tool.js.map +1 -0
- package/dist/utils/errors.d.ts +26 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +41 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/file-utils.d.ts +25 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +58 -0
- package/dist/utils/file-utils.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +23 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zengjing
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
# XMind MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@zengjing/xmind-mcp)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/@zengjing/xmind-mcp)
|
|
6
|
+
[](https://modelcontextprotocol.io)
|
|
7
|
+
|
|
8
|
+
A Model Context Protocol (MCP) server for parsing and searching XMind mind map files (.xmind). Enables Claude and other AI applications to efficiently extract, search, and manipulate mind map data with token-aware formatting and intelligent error handling.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Full Document Parsing**: Convert entire XMind documents to structured Markdown or JSON format
|
|
13
|
+
- **Efficient Search**: Search nodes by keyword, label, or status marker with breadcrumb path resolution
|
|
14
|
+
- **Branch Extraction**: Extract specific subtrees with optional depth limiting for token optimization
|
|
15
|
+
- **Multi-Format Support**: Handles both Zen (modern JSON-based) and Legacy (XML-based) XMind formats
|
|
16
|
+
- **Token-Aware Output**: Estimates token consumption and provides optimization suggestions
|
|
17
|
+
- **Error Guidance**: Helpful error messages with actionable recovery steps
|
|
18
|
+
- **Claude Desktop Integration**: Ready to use as a Claude Desktop tool
|
|
19
|
+
|
|
20
|
+
## Table of Contents
|
|
21
|
+
|
|
22
|
+
- [Quick Start](#quick-start)
|
|
23
|
+
- [Installation](#installation)
|
|
24
|
+
- [Global Install (Recommended)](#global-install-recommended)
|
|
25
|
+
- [From Source](#from-source)
|
|
26
|
+
- [Usage](#usage)
|
|
27
|
+
- [Running the MCP Server](#running-the-mcp-server)
|
|
28
|
+
- [Claude Desktop Configuration](#claude-desktop-configuration)
|
|
29
|
+
- [Command-Line (CLI) Usage](#command-line-cli-usage)
|
|
30
|
+
- [Tools Documentation](#tools-documentation)
|
|
31
|
+
- [parse_xmind](#1-parse_xmind)
|
|
32
|
+
- [search_xmind_nodes](#2-search_xmind_nodes)
|
|
33
|
+
- [get_xmind_node_branch](#3-get_xmind_node_branch)
|
|
34
|
+
- [Debugging with MCP Inspector](#debugging-with-mcp-inspector)
|
|
35
|
+
- [Development](#development)
|
|
36
|
+
- [Limitations and Known Issues](#limitations-and-known-issues)
|
|
37
|
+
- [Troubleshooting](#troubleshooting)
|
|
38
|
+
- [Support](#support)
|
|
39
|
+
- [License](#license)
|
|
40
|
+
- [Changelog](#changelog)
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
> Get from zero to a working result in under a minute.
|
|
45
|
+
|
|
46
|
+
**Option A — Global install (fastest)**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install -g @zengjing/xmind-mcp
|
|
50
|
+
xmind-mcp --help # verify install
|
|
51
|
+
xmind-mcp ~/Documents/my-mindmap.xmind # try CLI on a file
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Option B — Local dev install**
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/hhtczengjing/xmind-mcp.git
|
|
58
|
+
cd xmind-mcp
|
|
59
|
+
npm install
|
|
60
|
+
npm run build
|
|
61
|
+
npm start # launches MCP server on stdio
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Then point Claude Desktop at the built `dist/index.js` (see [Claude Desktop Configuration](#claude-desktop-configuration)).
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
### Requirements
|
|
69
|
+
|
|
70
|
+
- Node.js 18.0 or higher (matches `engines.node` in `package.json`)
|
|
71
|
+
- npm or yarn package manager
|
|
72
|
+
|
|
73
|
+
### Global Install (Recommended)
|
|
74
|
+
|
|
75
|
+
The `bin` field in `package.json` exposes the `xmind-mcp` command globally, so most users can skip building from source:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm install -g @zengjing/xmind-mcp
|
|
79
|
+
xmind-mcp --help
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This gives you both:
|
|
83
|
+
- the `xmind-mcp` CLI (see [Command-Line Usage](#command-line-cli-usage))
|
|
84
|
+
- a runnable MCP server entry point at `<npm-prefix>/lib/node_modules/@zengjing/xmind-mcp/dist/index.js`
|
|
85
|
+
|
|
86
|
+
> 📌 Use `npm root -g` (macOS/Linux) or `%APPDATA%\npm` (Windows) to locate `dist/index.js` for your Claude Desktop config.
|
|
87
|
+
|
|
88
|
+
### From Source
|
|
89
|
+
|
|
90
|
+
1. **Clone the repository**
|
|
91
|
+
```bash
|
|
92
|
+
git clone https://github.com/hhtczengjing/xmind-mcp.git
|
|
93
|
+
cd xmind-mcp
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
2. **Install dependencies**
|
|
97
|
+
```bash
|
|
98
|
+
npm install
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
3. **Build the project**
|
|
102
|
+
```bash
|
|
103
|
+
npm run build
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
4. **Verify installation**
|
|
107
|
+
```bash
|
|
108
|
+
npm run lint
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Usage
|
|
112
|
+
|
|
113
|
+
### Running the Server
|
|
114
|
+
|
|
115
|
+
Start the MCP server via stdio transport:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npm start
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The server will start and listen for MCP protocol requests on stdin/stdout.
|
|
122
|
+
|
|
123
|
+
For development with hot reload:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm run dev
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Claude Desktop Configuration
|
|
130
|
+
|
|
131
|
+
To use with Claude Desktop, add the server to your `claude_desktop_config.json`:
|
|
132
|
+
|
|
133
|
+
**Location**: `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
|
|
134
|
+
|
|
135
|
+
**Configuration**:
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"mcpServers": {
|
|
139
|
+
"xmind-mcp": {
|
|
140
|
+
"command": "node",
|
|
141
|
+
"args": ["/path/to/xmind-mcp/dist/index.js"]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Replace `/path/to/xmind-mcp` with the absolute path to your xmind-mcp directory.
|
|
148
|
+
|
|
149
|
+
After adding the configuration, restart Claude Desktop. The three tools will be available to Claude.
|
|
150
|
+
|
|
151
|
+
### Command-Line (CLI) Usage
|
|
152
|
+
|
|
153
|
+
The project ships a standalone CLI built on the same parser/formatters that power the MCP tools. It's useful for quick inspection, scripting, and CI pipelines.
|
|
154
|
+
|
|
155
|
+
**Script alias** (from source): `npm run parse -- <file> [options]`
|
|
156
|
+
**Global command** (after `npm install -g`): `xmind-mcp <file> [options]`
|
|
157
|
+
**Direct binary**: `node dist/cli.js <file> [options]`
|
|
158
|
+
|
|
159
|
+
**Usage**
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
xmind-mcp <file-path> [options]
|
|
163
|
+
|
|
164
|
+
Arguments:
|
|
165
|
+
<file-path> Path to the .xmind file (supports ~ for home directory)
|
|
166
|
+
|
|
167
|
+
Options:
|
|
168
|
+
-f, --format Output format: 'markdown' (default) or 'json'
|
|
169
|
+
-o, --output Save output to file
|
|
170
|
+
-s, --search Filter results by keyword (case-insensitive)
|
|
171
|
+
-v, --verbose Show sheet titles and parsing details
|
|
172
|
+
-h, --help Show this help message
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Examples**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Print a Markdown outline to stdout
|
|
179
|
+
xmind-mcp ~/Documents/project-plan.xmind
|
|
180
|
+
|
|
181
|
+
# JSON output, saved to a file
|
|
182
|
+
xmind-mcp ~/Documents/strategy.xmind --format json -o strategy.json
|
|
183
|
+
|
|
184
|
+
# Filter content by a keyword
|
|
185
|
+
xmind-mcp ~/Documents/notes.xmind --search "deadline"
|
|
186
|
+
|
|
187
|
+
# Verbose mode (shows file metadata + per-sheet titles)
|
|
188
|
+
xmind-mcp ~/Documents/notes.xmind -v
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The CLI prints a header block with file metadata (format version, sheet count, total topics, parse timestamp) followed by the formatted content, and exits with status code `0` on success or `1` on error.
|
|
192
|
+
|
|
193
|
+
## Tools Documentation
|
|
194
|
+
|
|
195
|
+
### 1. parse_xmind
|
|
196
|
+
|
|
197
|
+
**Description**: Parse an entire XMind document and return formatted output (Markdown or JSON).
|
|
198
|
+
|
|
199
|
+
**When to use**:
|
|
200
|
+
- Analyzing complete mind map structures
|
|
201
|
+
- Creating summaries or reports from mind maps
|
|
202
|
+
- Understanding full document architecture
|
|
203
|
+
|
|
204
|
+
**Parameters**:
|
|
205
|
+
|
|
206
|
+
| Parameter | Type | Required | Default | Description |
|
|
207
|
+
|-----------|------|----------|---------|-------------|
|
|
208
|
+
| `path` | string | Yes | - | Absolute file path to the .xmind file. Supports `~` for home directory expansion. |
|
|
209
|
+
| `format` | string | No | `markdown` | Output format: `markdown` (token-efficient, recommended) or `json` (structured). |
|
|
210
|
+
|
|
211
|
+
**Examples**:
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
Tool Call:
|
|
215
|
+
parse_xmind
|
|
216
|
+
path: "~/Documents/project-plan.xmind"
|
|
217
|
+
format: "markdown"
|
|
218
|
+
|
|
219
|
+
Response:
|
|
220
|
+
Complete mind map structure in Markdown format with token estimate.
|
|
221
|
+
Includes recommendations for large documents (>20K tokens).
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
Tool Call:
|
|
226
|
+
parse_xmind
|
|
227
|
+
path: "/Users/alice/xmind/strategy.xmind"
|
|
228
|
+
format: "json"
|
|
229
|
+
|
|
230
|
+
Response:
|
|
231
|
+
Structure summary + full JSON representation with metadata.
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Output**:
|
|
235
|
+
- Formatted content (Markdown or JSON)
|
|
236
|
+
- Metadata: file path, XMind format (Zen/Legacy), sheet count, topic count
|
|
237
|
+
- Token estimation and optimization suggestions for large documents
|
|
238
|
+
- Character count and recommendations for context efficiency
|
|
239
|
+
|
|
240
|
+
**Token Efficiency**:
|
|
241
|
+
- Markdown format: ~1 token per 4 characters (most efficient)
|
|
242
|
+
- JSON format: ~1 token per 3 characters (more detailed metadata)
|
|
243
|
+
- Large documents (>20K tokens): Consider using search or branch extraction
|
|
244
|
+
|
|
245
|
+
### 2. search_xmind_nodes
|
|
246
|
+
|
|
247
|
+
**Description**: Search for nodes in an XMind file by keyword, label, or status marker with breadcrumb path resolution.
|
|
248
|
+
|
|
249
|
+
**When to use**:
|
|
250
|
+
- Finding specific topics in large mind maps without loading entire document
|
|
251
|
+
- Locating nodes by keyword, label, or marker type
|
|
252
|
+
- Narrowing context for focused analysis
|
|
253
|
+
|
|
254
|
+
**Parameters**:
|
|
255
|
+
|
|
256
|
+
| Parameter | Type | Required | Default | Description |
|
|
257
|
+
|-----------|------|----------|---------|-------------|
|
|
258
|
+
| `path` | string | Yes | - | Absolute file path to the .xmind file. Supports `~` for home directory. |
|
|
259
|
+
| `query` | string | Yes | - | Search keyword or phrase to match in node titles, notes, or labels. |
|
|
260
|
+
| `searchIn` | array | No | `['title', 'note', 'label']` | Fields to search in: `title`, `note`, `label`. Specify subset to optimize. |
|
|
261
|
+
| `caseSensitive` | boolean | No | `false` | Enable case-sensitive matching (default: case-insensitive). |
|
|
262
|
+
|
|
263
|
+
**Examples**:
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
Tool Call:
|
|
267
|
+
search_xmind_nodes
|
|
268
|
+
path: "~/Documents/project-plan.xmind"
|
|
269
|
+
query: "deadline"
|
|
270
|
+
searchIn: ["title", "note"]
|
|
271
|
+
|
|
272
|
+
Response:
|
|
273
|
+
Found 3 matches:
|
|
274
|
+
1. Project Deadline
|
|
275
|
+
Path: Project Plan > Timeline > Project Deadline
|
|
276
|
+
Match: title — "deadline"
|
|
277
|
+
Note: Must complete by end of Q3...
|
|
278
|
+
|
|
279
|
+
2. Milestone Due Date
|
|
280
|
+
Path: Project Plan > Phases > Phase 2 > Milestone Due Date
|
|
281
|
+
Match: note — "Deadline is Sept 30th"
|
|
282
|
+
...
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
Tool Call:
|
|
287
|
+
search_xmind_nodes
|
|
288
|
+
path: "/Users/alice/xmind/architecture.xmind"
|
|
289
|
+
query: "API"
|
|
290
|
+
caseSensitive: true
|
|
291
|
+
searchIn: ["title"]
|
|
292
|
+
|
|
293
|
+
Response:
|
|
294
|
+
Found 2 matches:
|
|
295
|
+
1. REST API Design
|
|
296
|
+
Path: Architecture > Backend > REST API Design
|
|
297
|
+
Match: title — "REST API Design"
|
|
298
|
+
...
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Output**:
|
|
302
|
+
- Match count and result details
|
|
303
|
+
- Breadcrumb paths (root → ... → node) for context
|
|
304
|
+
- Match type and matched text excerpt
|
|
305
|
+
- Node notes preview (first 80 characters) if available
|
|
306
|
+
- Matched nodes have IDs that can be used with `get_xmind_node_branch`
|
|
307
|
+
|
|
308
|
+
### 3. get_xmind_node_branch
|
|
309
|
+
|
|
310
|
+
**Description**: Extract a specific node and its subtree (up to specified depth) from an XMind file.
|
|
311
|
+
|
|
312
|
+
**When to use**:
|
|
313
|
+
- Focusing on specific branches to avoid token overload
|
|
314
|
+
- Extracting relevant subtrees for detailed analysis
|
|
315
|
+
- Limiting recursion depth for performance
|
|
316
|
+
- Narrowing context after search results
|
|
317
|
+
|
|
318
|
+
**Parameters**:
|
|
319
|
+
|
|
320
|
+
| Parameter | Type | Required | Default | Description |
|
|
321
|
+
|-----------|------|----------|---------|-------------|
|
|
322
|
+
| `path` | string | Yes | - | Absolute file path to the .xmind file. |
|
|
323
|
+
| `nodeId` | string | Yes | - | Target node ID to extract. Get IDs via `search_xmind_nodes` or `parse_xmind` output. |
|
|
324
|
+
| `depth` | number | No | unlimited | Maximum recursion depth for children (0 = node only, 1 = children, 2+ = deeper). |
|
|
325
|
+
|
|
326
|
+
**Examples**:
|
|
327
|
+
|
|
328
|
+
```
|
|
329
|
+
Tool Call:
|
|
330
|
+
get_xmind_node_branch
|
|
331
|
+
path: "~/Documents/project-plan.xmind"
|
|
332
|
+
nodeId: "topic-42a"
|
|
333
|
+
depth: 2
|
|
334
|
+
|
|
335
|
+
Response:
|
|
336
|
+
Extracted 8 nodes (depth: 2/2)
|
|
337
|
+
|
|
338
|
+
- Target Topic
|
|
339
|
+
- Child 1
|
|
340
|
+
- Grandchild 1
|
|
341
|
+
- Grandchild 2
|
|
342
|
+
- Child 2
|
|
343
|
+
> Supporting notes if available...
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
```
|
|
347
|
+
Tool Call:
|
|
348
|
+
get_xmind_node_branch
|
|
349
|
+
path: "/Users/alice/xmind/strategy.xmind"
|
|
350
|
+
nodeId: "analysis-backend"
|
|
351
|
+
|
|
352
|
+
Response:
|
|
353
|
+
Extracted 24 nodes (depth: 4/∞)
|
|
354
|
+
|
|
355
|
+
- Backend Architecture
|
|
356
|
+
- API Layer
|
|
357
|
+
- REST Endpoints
|
|
358
|
+
- GraphQL
|
|
359
|
+
- Database
|
|
360
|
+
- Schema Design
|
|
361
|
+
- Performance Tuning
|
|
362
|
+
...
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
**Output**:
|
|
366
|
+
- Node count and depth information
|
|
367
|
+
- Extracted subtree in Markdown outline format
|
|
368
|
+
- Metadata: actual depth reached vs requested depth
|
|
369
|
+
- Suitable for direct analysis or further processing
|
|
370
|
+
|
|
371
|
+
## Debugging with MCP Inspector
|
|
372
|
+
|
|
373
|
+
The [MCP Inspector](https://github.com/modelcontextprotocol/inspector) is the official debugger for MCP servers. It streams `ListTools` / `CallTool` traffic so you can verify your install and inspect each request/response without going through Claude Desktop.
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# From the project root, with deps installed
|
|
377
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
In the Inspector UI:
|
|
381
|
+
1. Confirm the three tools (`parse_xmind`, `search_xmind_nodes`, `get_xmind_node_branch`) appear under **Tools**.
|
|
382
|
+
2. Pick a tool, fill in `path` to a real `.xmind` file, and hit **Run**.
|
|
383
|
+
3. Use the **Notifications** / **Logs** pane to see structured log output (the server uses the `utils/logger.ts` module with `info` / `warn` / `error` levels).
|
|
384
|
+
|
|
385
|
+
Enable verbose logging in any environment by setting `DEBUG=xmind-mcp`.
|
|
386
|
+
|
|
387
|
+
## Development
|
|
388
|
+
|
|
389
|
+
### Project Structure
|
|
390
|
+
|
|
391
|
+
```
|
|
392
|
+
xmind-mcp/
|
|
393
|
+
├── src/
|
|
394
|
+
│ ├── index.ts # MCP server entry point (stdio transport)
|
|
395
|
+
│ ├── cli.ts # Standalone CLI for local/scripted use
|
|
396
|
+
│ ├── core/
|
|
397
|
+
│ │ ├── parser.ts # Unified parser interface
|
|
398
|
+
│ │ ├── zen-parser.ts # Zen (JSON) format handler
|
|
399
|
+
│ │ └── legacy-parser.ts # Legacy (XML) format handler
|
|
400
|
+
│ ├── tools/
|
|
401
|
+
│ │ ├── parse-tool.ts # parse_xmind implementation
|
|
402
|
+
│ │ ├── search-tool.ts # search_xmind_nodes implementation
|
|
403
|
+
│ │ └── branch-tool.ts # get_xmind_node_branch implementation
|
|
404
|
+
│ ├── formatters/
|
|
405
|
+
│ │ ├── markdown-formatter.ts # Markdown output formatting
|
|
406
|
+
│ │ └── json-formatter.ts # JSON output formatting
|
|
407
|
+
│ ├── model/
|
|
408
|
+
│ │ ├── types.ts # Core TypeScript types (XMindNode, XMindSheet, etc.)
|
|
409
|
+
│ │ └── schemas.ts # Zod schemas for input validation
|
|
410
|
+
│ └── utils/
|
|
411
|
+
│ ├── errors.ts # Error types and handling
|
|
412
|
+
│ ├── file-utils.ts # File path resolution and validation
|
|
413
|
+
│ └── logger.ts # Structured logging utilities
|
|
414
|
+
├── tests/ # Jest test suite
|
|
415
|
+
├── dist/ # Compiled JavaScript (generated)
|
|
416
|
+
├── package.json
|
|
417
|
+
├── tsconfig.json
|
|
418
|
+
└── jest.config.js
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### File Descriptions
|
|
422
|
+
|
|
423
|
+
#### Core Modules
|
|
424
|
+
|
|
425
|
+
- **parser.ts**: Unified interface for parsing both Zen and Legacy formats. Auto-detects format and delegates to appropriate parser.
|
|
426
|
+
- **zen-parser.ts**: Handles modern XMind Zen format (JSON-based). Extracts content.xml from .zip archive.
|
|
427
|
+
- **legacy-parser.ts**: Handles legacy XMind 8 format (XML-based). Parses workbook.xml structure.
|
|
428
|
+
|
|
429
|
+
#### Entry Points
|
|
430
|
+
|
|
431
|
+
- **index.ts**: MCP server. Listens on stdio and routes `parse_xmind` / `search_xmind_nodes` / `get_xmind_node_branch` calls.
|
|
432
|
+
- **cli.ts**: Standalone CLI (see [Command-Line Usage](#command-line-cli-usage)). Built into `dist/cli.js` and exposed as the `xmind-mcp` global command.
|
|
433
|
+
|
|
434
|
+
#### Tool Implementations
|
|
435
|
+
|
|
436
|
+
- **parse-tool.ts**: Full document parsing with format selection. Includes token estimation and optimization suggestions.
|
|
437
|
+
- **search-tool.ts**: Breadth-first search across all sheets with path tracking. Supports field filtering and case sensitivity.
|
|
438
|
+
- **branch-tool.ts**: Tree extraction with depth limiting. Useful for large documents.
|
|
439
|
+
|
|
440
|
+
#### Formatters
|
|
441
|
+
|
|
442
|
+
- **markdown-formatter.ts**: Converts AST to token-efficient Markdown outline. Escapes special characters and includes metadata.
|
|
443
|
+
- **json-formatter.ts**: Full-featured JSON output with structure summary. Useful for programmatic processing.
|
|
444
|
+
|
|
445
|
+
#### Model & Utilities
|
|
446
|
+
|
|
447
|
+
- **types.ts**: Core types: XMindNode, XMindSheet, XMindParsedResult, SearchResult, etc.
|
|
448
|
+
- **schemas.ts**: Zod validation schemas for all tool inputs.
|
|
449
|
+
- **errors.ts**: Custom error classes with error codes for specific failure modes.
|
|
450
|
+
- **file-utils.ts**: Path resolution, validation, and node ID verification.
|
|
451
|
+
- **logger.ts**: Structured logging with levels (debug, info, warn, error).
|
|
452
|
+
|
|
453
|
+
### Testing
|
|
454
|
+
|
|
455
|
+
Run the full test suite:
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
npm test
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
Run tests in watch mode:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
npm run test:watch
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
Tests are organized by layer under `tests/`:
|
|
468
|
+
|
|
469
|
+
```
|
|
470
|
+
tests/
|
|
471
|
+
├── core/ # Unit tests for individual parsers
|
|
472
|
+
│ ├── legacy-parser.test.ts # XMind 8 (XML) format
|
|
473
|
+
│ └── zen-parser.test.ts # XMind Zen (JSON) format
|
|
474
|
+
└── e2e/
|
|
475
|
+
└── mcp-integration.test.ts # End-to-end MCP protocol flow
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
The framework is Jest with `ts-jest` (TypeScript out of the box). All tests run from a clean repo without any external network access — `.xmind` fixtures are generated or committed locally.
|
|
479
|
+
|
|
480
|
+
### Building
|
|
481
|
+
|
|
482
|
+
Compile TypeScript to JavaScript:
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
npm run build
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
Type check without building:
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
npm run lint
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### Architecture Overview
|
|
495
|
+
|
|
496
|
+
**Unified AST Model**: Both Zen and Legacy formats are normalized to a single tree structure (XMindNode), simplifying downstream processing.
|
|
497
|
+
|
|
498
|
+
**Stateless Design**: All functions are pure and immutable. No server-side state is maintained between requests.
|
|
499
|
+
|
|
500
|
+
**Token-Aware Output**: Tools estimate token consumption and suggest optimizations (search/branch extraction for large documents).
|
|
501
|
+
|
|
502
|
+
**Error Guidance**: All errors include actionable messages helping users recover (invalid paths, missing nodes, etc.).
|
|
503
|
+
|
|
504
|
+
**Performance**: Lazy evaluation where possible, depth limiting in branch extraction, incremental search results.
|
|
505
|
+
|
|
506
|
+
## Limitations and Known Issues
|
|
507
|
+
|
|
508
|
+
### Current Limitations
|
|
509
|
+
|
|
510
|
+
1. **Hyperlinks**: Internal node references (href) are preserved but not resolved to actual node content
|
|
511
|
+
2. **Relationships/Connectors**: Cross-node relationships are parsed but not included in Markdown output (available in JSON format)
|
|
512
|
+
3. **Rich Text**: Multi-formatted text within notes is flattened to plain text
|
|
513
|
+
4. **Images & Media**: Embedded images and media are not extracted or referenced
|
|
514
|
+
5. **Styling**: Font colors, sizes, and other visual formatting are not preserved
|
|
515
|
+
6. **Comments**: XMind 2024 comment annotations are not extracted
|
|
516
|
+
|
|
517
|
+
### Token Limitations
|
|
518
|
+
|
|
519
|
+
- Large mind maps (>50K nodes) may exceed Claude's context window even with branch extraction
|
|
520
|
+
- Recommend using search to narrow scope for very large documents
|
|
521
|
+
- JSON format uses more tokens than Markdown format (use Markdown when possible)
|
|
522
|
+
|
|
523
|
+
### File Format Support
|
|
524
|
+
|
|
525
|
+
- **Supported**: XMind 2023 (Zen format), XMind 8 (Legacy format)
|
|
526
|
+
- **Experimental**: Earlier XMind versions may work but are untested
|
|
527
|
+
|
|
528
|
+
### Error Recovery
|
|
529
|
+
|
|
530
|
+
- Invalid file paths: Validates before parsing; suggests checking file permissions
|
|
531
|
+
- Corrupted archives: Returns detailed error if .zip is invalid
|
|
532
|
+
- Missing nodes: Returns friendly error suggesting search_xmind_nodes for available IDs
|
|
533
|
+
- Large files: Suggests using search or branch extraction for better performance
|
|
534
|
+
|
|
535
|
+
## Troubleshooting
|
|
536
|
+
|
|
537
|
+
| Symptom | Likely cause | Fix |
|
|
538
|
+
|---|---|---|
|
|
539
|
+
| `Error: Cannot find module '@modelcontextprotocol/sdk'` | You ran `node dist/index.js` before building | Run `npm install && npm run build` |
|
|
540
|
+
| Claude Desktop doesn't list the three tools | Config path is wrong or `node` isn't on PATH | Re-check `claude_desktop_config.json`; the server only registers after a successful `connect()` on stdio |
|
|
541
|
+
| `File not found: …` from the CLI | `~` not expanded on Windows shells | Pass an absolute path or use `path.resolve` upstream |
|
|
542
|
+
| `nodeId` returns "Node not found" | The id was from a different file or session | Re-run `search_xmind_nodes` against the same file — ids are file-scoped |
|
|
543
|
+
| Output blows past context window | Whole-document parse on a very large map | Use `search_xmind_nodes` first, then `get_xmind_node_branch` with a small `depth` |
|
|
544
|
+
| `Failed to start MCP server` on launch | Another process already bound the stdio | Close any duplicate launches; MCP over stdio is single-consumer |
|
|
545
|
+
| Corrupt archive errors | File isn't a real `.xmind` (renamed `.zip`, partial download) | Re-export from XMind; confirm `unzip -l file.xmind` lists `content.xml` or `manifest.json` |
|
|
546
|
+
|
|
547
|
+
For anything not covered above, please open an issue (next section).
|
|
548
|
+
|
|
549
|
+
## License
|
|
550
|
+
|
|
551
|
+
MIT License - See [LICENSE](LICENSE) file for details.
|
|
552
|
+
|
|
553
|
+
## Support
|
|
554
|
+
|
|
555
|
+
For issues, feature requests, or questions:
|
|
556
|
+
1. Check existing issues at <https://github.com/hhtczengjing/xmind-mcp/issues>
|
|
557
|
+
2. Enable debug logging by setting `DEBUG=xmind-mcp` environment variable
|
|
558
|
+
3. Run the test suite to verify your install: `npm test`
|
|
559
|
+
4. When filing a new issue, include:
|
|
560
|
+
- Output of `node --version` and `npm --version`
|
|
561
|
+
- Exact command / tool call that failed and the full error text
|
|
562
|
+
- A minimal `.xmind` sample (anonymized if it contains sensitive content)
|
|
563
|
+
|
|
564
|
+
## Changelog
|
|
565
|
+
|
|
566
|
+
### Version 1.0.0 (Initial Release)
|
|
567
|
+
|
|
568
|
+
- Full document parsing (Markdown and JSON formats)
|
|
569
|
+
- Node search with breadcrumb paths
|
|
570
|
+
- Branch extraction with depth limiting
|
|
571
|
+
- Support for Zen and Legacy XMind formats
|
|
572
|
+
- Token estimation and optimization suggestions
|
|
573
|
+
- Comprehensive error handling and logging
|
|
574
|
+
- MCP server integration for Claude and other clients
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|