mcp-word-bridge 4.0.1 → 4.0.3
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.
|
@@ -20203,108 +20203,166 @@ function buildToolRegistry() {
|
|
|
20203
20203
|
// src/server/usage-guide.ts
|
|
20204
20204
|
var usageGuide = `# MCP Word Bridge \u2014 Usage Guide
|
|
20205
20205
|
|
|
20206
|
-
Controls a live Word document
|
|
20206
|
+
Controls a live Word document. All operations execute immediately.
|
|
20207
20207
|
|
|
20208
20208
|
## Quick Start
|
|
20209
20209
|
|
|
20210
|
-
1. **Read before writing** \u2014 call \`word_get_document_outline\` or \`word_get_paragraphs\` to understand
|
|
20211
|
-
2. **Use the right tool
|
|
20212
|
-
-
|
|
20213
|
-
-
|
|
20214
|
-
-
|
|
20210
|
+
1. **Read before writing** \u2014 call \`word_get_document_outline\` or \`word_get_paragraphs\` to understand structure
|
|
20211
|
+
2. **Use the right tool:**
|
|
20212
|
+
- Append content \u2192 \`word_insert_paragraph\` (Start/End)
|
|
20213
|
+
- Insert at position \u2192 \`word_insert_paragraph_at_index\` (Before/After by index)
|
|
20214
|
+
- Edit existing text \u2192 \`word_replace_paragraph_text\` (by index, preferred)
|
|
20215
20215
|
- Bulk find/replace \u2192 \`word_search_and_replace\` (all occurrences)
|
|
20216
|
-
-
|
|
20217
|
-
3. **Batch
|
|
20216
|
+
- Insert adjacent to text \u2192 \`word_insert_text_at_match\` (searches then inserts)
|
|
20217
|
+
3. **Batch operations** \u2014 use \`word_batch\` for multiple operations in one call (faster, fewer round-trips)
|
|
20218
20218
|
4. **Save explicitly** \u2014 call \`word_save\` after significant changes
|
|
20219
20219
|
|
|
20220
|
-
## Reading
|
|
20221
|
-
|
|
20222
|
-
- \`
|
|
20223
|
-
- \`
|
|
20220
|
+
## Reading
|
|
20221
|
+
|
|
20222
|
+
- \`word_get_document_outline\` \u2014 heading tree (fast structural overview)
|
|
20223
|
+
- \`word_get_paragraphs\` \u2014 paragraphs with text, style, alignment. Paginate with start/end.
|
|
20224
|
+
- \`word_get_paragraph_by_index\` \u2014 full details of one paragraph (font, spacing, indent)
|
|
20225
|
+
- \`word_get_text\` \u2014 plain-text dump (no structure)
|
|
20224
20226
|
- \`word_search\` \u2014 locate text before operating on it
|
|
20225
20227
|
|
|
20226
|
-
## Editing
|
|
20227
|
-
|
|
20228
|
+
## Editing
|
|
20229
|
+
|
|
20230
|
+
- \`word_replace_paragraph_text\` \u2014 replace by index (safe for collaboration, preserves style)
|
|
20228
20231
|
- \`word_search_and_replace\` \u2014 bulk find/replace across document
|
|
20229
|
-
- \`word_insert_text_at_match\` \u2014 insert before/after a search match
|
|
20230
|
-
- \`word_move_paragraph\` \u2014 reorder content (
|
|
20231
|
-
- \`word_copy_paragraph\` \u2014 duplicate content with full fidelity
|
|
20232
|
+
- \`word_insert_text_at_match\` \u2014 insert before/after a search match (use \`occurrence\` for Nth)
|
|
20233
|
+
- \`word_move_paragraph\` \u2014 reorder content (preserves footnotes, formatting, hyperlinks)
|
|
20234
|
+
- \`word_copy_paragraph\` \u2014 duplicate content with full fidelity
|
|
20235
|
+
- Verify edits with \`word_search\` or \`word_get_paragraphs\`
|
|
20236
|
+
|
|
20237
|
+
## Batch
|
|
20232
20238
|
|
|
20233
|
-
## Batch Operations
|
|
20234
|
-
\`word_batch\` executes multiple operations in a single MCP call:
|
|
20235
20239
|
\`\`\`json
|
|
20236
20240
|
{"operations": [
|
|
20237
20241
|
{"tool": "word_insert_paragraph", "args": {"text": "Hello", "style": "Heading 1"}},
|
|
20238
|
-
{"tool": "word_insert_paragraph", "args": {"text": "World"
|
|
20239
|
-
{"tool": "
|
|
20242
|
+
{"tool": "word_insert_paragraph", "args": {"text": "World"}},
|
|
20243
|
+
{"tool": "word_format_text", "args": {"text": "Hello", "bold": true}}
|
|
20240
20244
|
]}
|
|
20241
20245
|
\`\`\`
|
|
20242
|
-
|
|
20246
|
+
Runs sequentially. Stops on first error. Maximum 50 per batch. Prefer batching over individual calls.
|
|
20243
20247
|
|
|
20244
|
-
## Search
|
|
20245
|
-
- Case-insensitive by default. Pass \`matchCase: true\` for exact case match.
|
|
20246
|
-
- Query must be \u2264255 characters.
|
|
20247
|
-
- Affected tools: search, search_and_replace, insert_text_at_match, format_text, insert_footnote, add_comment, insert_hyperlink, insert_bookmark, insert_content_control, clear_formatting, get_font_info, insert_line_break, remove_hyperlink, insert_endnote, insert_equation (inline with anchor).
|
|
20248
|
+
## Search
|
|
20248
20249
|
|
|
20249
|
-
|
|
20250
|
-
|
|
20250
|
+
- Case-insensitive by default. Pass \`matchCase: true\` for exact case.
|
|
20251
|
+
- Text parameters must be \u2264255 characters.
|
|
20252
|
+
- Use \`occurrence\` (0-indexed) to target the Nth match when multiple exist.
|
|
20251
20253
|
|
|
20252
|
-
##
|
|
20253
|
-
- Call \`word_set_change_tracking({mode:"TrackAll"})\` BEFORE edits for tracked changes
|
|
20254
|
-
- \`search_and_replace\` with tracking may only expose the "Added" half
|
|
20254
|
+
## Comments \u2014 Important
|
|
20255
20255
|
|
|
20256
|
-
|
|
20257
|
-
-
|
|
20258
|
-
-
|
|
20259
|
-
- Safe pattern: get_comments \u2192 reply/resolve \u2192 then replace text
|
|
20256
|
+
- \`word_get_comments\` returns comments with their anchor text
|
|
20257
|
+
- **Replacing text that anchors a comment deletes the comment** \u2014 always check comments first
|
|
20258
|
+
- Safe pattern: \`word_get_comments\` \u2192 \`word_reply_to_comment\`/\`word_resolve_comment\` \u2192 then replace
|
|
20260
20259
|
|
|
20261
20260
|
## Tables
|
|
20261
|
+
|
|
20262
20262
|
- All indices 0-based: tableIndex, row, col
|
|
20263
|
-
- \`word_list_tables\` for metadata
|
|
20264
|
-
-
|
|
20263
|
+
- \`word_list_tables\` for metadata \u2192 \`word_get_table_data\` for cell values
|
|
20264
|
+
- Cannot insert page/section breaks inside table cells
|
|
20265
20265
|
|
|
20266
20266
|
## Footnotes & Endnotes
|
|
20267
|
-
|
|
20268
|
-
- \`
|
|
20267
|
+
|
|
20268
|
+
- \`word_insert_footnote\` \u2014 anchor to a text match
|
|
20269
|
+
- \`word_insert_footnote_at_index\` \u2014 anchor to a paragraph by index (no search needed)
|
|
20269
20270
|
|
|
20270
20271
|
## Page Layout
|
|
20272
|
+
|
|
20271
20273
|
- Margins in points (72 pt = 1 inch)
|
|
20272
|
-
- \`lineSpacing\` in points, not a multiplier (12pt font: 12=single, 18=1.5x, 24=double)
|
|
20274
|
+
- \`lineSpacing\` is in points, not a multiplier (12pt font: 12=single, 18=1.5x, 24=double)
|
|
20273
20275
|
|
|
20274
20276
|
## Content Controls
|
|
20275
|
-
- RichText/PlainText: wraps the anchor text (non-destructive)
|
|
20276
|
-
- CheckBox: REPLACES anchor text with a checkbox (cannot use set_content_control_text)
|
|
20277
20277
|
|
|
20278
|
-
|
|
20278
|
+
- RichText/PlainText: wraps anchor text (non-destructive)
|
|
20279
|
+
- CheckBox: REPLACES anchor text with a checkbox (cannot set text after)
|
|
20280
|
+
|
|
20281
|
+
## TOC
|
|
20282
|
+
|
|
20279
20283
|
After inserting a Table of Contents, heading text appears twice (in TOC and body). Search matches TOC entries first \u2014 use \`occurrence\` to target the body instance.
|
|
20280
20284
|
|
|
20281
20285
|
## Equations
|
|
20282
|
-
|
|
20283
|
-
- \`
|
|
20284
|
-
-
|
|
20286
|
+
|
|
20287
|
+
- \`word_insert_equation\` takes LaTeX, inserts a native editable Word equation
|
|
20288
|
+
- \`displayMode: true\` (default) = centered block equation
|
|
20289
|
+
- \`displayMode: false\` = inline; provide \`anchorText\` to position after a match
|
|
20285
20290
|
- Supports: fractions, roots, integrals, sums, matrices, Greek letters, AMS math
|
|
20291
|
+
- Examples: \`\\\\frac{a}{b}\`, \`\\\\int_0^\\\\infty e^{-x} dx\`, \`\\\\sum_{i=1}^n x_i\`
|
|
20286
20292
|
|
|
20287
|
-
##
|
|
20288
|
-
|
|
20289
|
-
-
|
|
20290
|
-
-
|
|
20293
|
+
## Change Tracking
|
|
20294
|
+
|
|
20295
|
+
- Call \`word_set_change_tracking({mode:"TrackAll"})\` BEFORE edits to track them
|
|
20296
|
+
- Tracked edits appear as revisions in Word (visible to collaborators)
|
|
20291
20297
|
|
|
20292
20298
|
## Best Practices
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
|
|
20296
|
-
|
|
20297
|
-
|
|
20298
|
-
|
|
20299
|
-
|
|
20300
|
-
|
|
20301
|
-
|
|
20299
|
+
|
|
20300
|
+
1. Read structure first (\`word_get_document_outline\`)
|
|
20301
|
+
2. Check comments before bulk replacements (\`word_get_comments\`)
|
|
20302
|
+
3. Batch multiple operations (\`word_batch\`)
|
|
20303
|
+
4. Prefer index-based tools over search-based in collaborative editing
|
|
20304
|
+
5. Use \`word_move_paragraph\` to reorder (not delete+insert)
|
|
20305
|
+
6. Use \`word_copy_paragraph\` to duplicate (preserves everything)
|
|
20306
|
+
7. Save explicitly after significant changes
|
|
20307
|
+
8. Resolve comments rather than deleting (preserves audit trail)
|
|
20302
20308
|
`;
|
|
20303
20309
|
|
|
20310
|
+
// package.json
|
|
20311
|
+
var package_default = {
|
|
20312
|
+
name: "mcp-word-bridge",
|
|
20313
|
+
version: "4.0.3",
|
|
20314
|
+
description: "MCP server for live Word document editing via Office Add-in",
|
|
20315
|
+
main: "dist/server.js",
|
|
20316
|
+
bin: {
|
|
20317
|
+
"mcp-word-bridge": "dist/server.js",
|
|
20318
|
+
"mcp-word-bridge-install": "scripts/install-manifest.js"
|
|
20319
|
+
},
|
|
20320
|
+
scripts: {
|
|
20321
|
+
build: "node scripts/build.mjs",
|
|
20322
|
+
start: "node dist/server.cjs",
|
|
20323
|
+
dev: "node scripts/build.mjs --watch",
|
|
20324
|
+
test: "vitest run",
|
|
20325
|
+
"test:ci": "vitest run --reporter=default",
|
|
20326
|
+
"test:live": "vitest run --config vitest.live.config.ts",
|
|
20327
|
+
lint: "eslint src/",
|
|
20328
|
+
typecheck: "tsc --noEmit",
|
|
20329
|
+
prepublishOnly: "npm run build"
|
|
20330
|
+
},
|
|
20331
|
+
keywords: ["mcp", "word", "office", "add-in", "document", "editing"],
|
|
20332
|
+
repository: {
|
|
20333
|
+
type: "git",
|
|
20334
|
+
url: "https://github.com/likelion/mcp-word-bridge.git"
|
|
20335
|
+
},
|
|
20336
|
+
author: "Leonid Mokrushin <likelion@gmail.com>",
|
|
20337
|
+
license: "MIT",
|
|
20338
|
+
dependencies: {
|
|
20339
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
20340
|
+
mathml2omml: "^0.5.0",
|
|
20341
|
+
temml: "^0.13.3",
|
|
20342
|
+
ws: "^8.16.0"
|
|
20343
|
+
},
|
|
20344
|
+
devDependencies: {
|
|
20345
|
+
"@types/node": "^22.0.0",
|
|
20346
|
+
"@types/ws": "^8.5.10",
|
|
20347
|
+
esbuild: "^0.25.0",
|
|
20348
|
+
eslint: "^10.4.1",
|
|
20349
|
+
typescript: "^5.7.0",
|
|
20350
|
+
"typescript-eslint": "^8.0.0",
|
|
20351
|
+
vitest: "^3.0.0"
|
|
20352
|
+
},
|
|
20353
|
+
files: [
|
|
20354
|
+
"dist/",
|
|
20355
|
+
"certs/cert.conf",
|
|
20356
|
+
"taskpane.html",
|
|
20357
|
+
"manifest.xml",
|
|
20358
|
+
"scripts/install-manifest.js"
|
|
20359
|
+
]
|
|
20360
|
+
};
|
|
20361
|
+
|
|
20304
20362
|
// src/server/mcp.ts
|
|
20305
20363
|
function createMcpServer(bridge2) {
|
|
20306
20364
|
const server = new import_server.Server(
|
|
20307
|
-
{ name: "mcp-word-bridge", version:
|
|
20365
|
+
{ name: "mcp-word-bridge", version: package_default.version },
|
|
20308
20366
|
{ capabilities: { tools: {}, resources: {} } }
|
|
20309
20367
|
);
|
|
20310
20368
|
const { tools, handlers } = buildToolRegistry();
|
|
@@ -20492,4 +20550,4 @@ main().catch((e) => {
|
|
|
20492
20550
|
process.stderr.write("[mcp-word-bridge] Fatal: " + e.message + "\n");
|
|
20493
20551
|
process.exit(1);
|
|
20494
20552
|
});
|
|
20495
|
-
//# sourceMappingURL=server.
|
|
20553
|
+
//# sourceMappingURL=server.js.map
|