@eigenpal/docx-js-editor 0.0.17 → 0.0.19

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.
Files changed (176) hide show
  1. package/dist/ClipboardManager-D6dkOFg6.d.ts +436 -0
  2. package/dist/ClipboardManager-EZ0C6Onq.d.cts +436 -0
  3. package/dist/DocumentAgent-B0EC8lPC.d.cts +412 -0
  4. package/dist/DocumentAgent-BcCDg7i2.d.ts +412 -0
  5. package/dist/{FindReplaceDialog-MMDEJORP.js → FindReplaceDialog-AWQXKEUQ.js} +2 -2
  6. package/dist/{FindReplaceDialog-MMDEJORP.js.map → FindReplaceDialog-AWQXKEUQ.js.map} +1 -1
  7. package/dist/{FindReplaceDialog-K4GRE4JB.cjs → FindReplaceDialog-I4SZDSVP.cjs} +2 -2
  8. package/dist/{FindReplaceDialog-K4GRE4JB.cjs.map → FindReplaceDialog-I4SZDSVP.cjs.map} +1 -1
  9. package/dist/{FootnotePropertiesDialog-V3YOIJCV.cjs → FootnotePropertiesDialog-73VT2ZVZ.cjs} +2 -2
  10. package/dist/{FootnotePropertiesDialog-V3YOIJCV.cjs.map → FootnotePropertiesDialog-73VT2ZVZ.cjs.map} +1 -1
  11. package/dist/{FootnotePropertiesDialog-HG4267LR.js → FootnotePropertiesDialog-ZM3EF3EF.js} +2 -2
  12. package/dist/{FootnotePropertiesDialog-HG4267LR.js.map → FootnotePropertiesDialog-ZM3EF3EF.js.map} +1 -1
  13. package/dist/{HyperlinkDialog-SCSX4RP7.js → HyperlinkDialog-BA25XUT5.js} +2 -2
  14. package/dist/{HyperlinkDialog-SCSX4RP7.js.map → HyperlinkDialog-BA25XUT5.js.map} +1 -1
  15. package/dist/{HyperlinkDialog-YPKURBZK.cjs → HyperlinkDialog-V63LPOT2.cjs} +2 -2
  16. package/dist/{HyperlinkDialog-YPKURBZK.cjs.map → HyperlinkDialog-V63LPOT2.cjs.map} +1 -1
  17. package/dist/{ImagePositionDialog-CJYJ35PI.js → ImagePositionDialog-AIAMKPFK.js} +2 -2
  18. package/dist/{ImagePositionDialog-CJYJ35PI.js.map → ImagePositionDialog-AIAMKPFK.js.map} +1 -1
  19. package/dist/{ImagePositionDialog-IMVI7EXA.cjs → ImagePositionDialog-KMK7ROV2.cjs} +2 -2
  20. package/dist/{ImagePositionDialog-IMVI7EXA.cjs.map → ImagePositionDialog-KMK7ROV2.cjs.map} +1 -1
  21. package/dist/{ImagePropertiesDialog-P7WN2ALR.js → ImagePropertiesDialog-ERFCUVCW.js} +2 -2
  22. package/dist/{ImagePropertiesDialog-P7WN2ALR.js.map → ImagePropertiesDialog-ERFCUVCW.js.map} +1 -1
  23. package/dist/{ImagePropertiesDialog-YS4KJRN7.cjs → ImagePropertiesDialog-USMMRK6X.cjs} +2 -2
  24. package/dist/{ImagePropertiesDialog-YS4KJRN7.cjs.map → ImagePropertiesDialog-USMMRK6X.cjs.map} +1 -1
  25. package/dist/{TablePropertiesDialog-CUQXUBQN.cjs → TablePropertiesDialog-72CIUAZT.cjs} +2 -2
  26. package/dist/{TablePropertiesDialog-CUQXUBQN.cjs.map → TablePropertiesDialog-72CIUAZT.cjs.map} +1 -1
  27. package/dist/{TablePropertiesDialog-ZHAYVHPZ.js → TablePropertiesDialog-EMUEVYB3.js} +2 -2
  28. package/dist/{TablePropertiesDialog-ZHAYVHPZ.js.map → TablePropertiesDialog-EMUEVYB3.js.map} +1 -1
  29. package/dist/agentApi-BFVyKagE.d.cts +2227 -0
  30. package/dist/agentApi-BFVyKagE.d.ts +2227 -0
  31. package/dist/chunk-2CHPKB5A.cjs +112 -0
  32. package/dist/chunk-2CHPKB5A.cjs.map +1 -0
  33. package/dist/chunk-2QOEHCBX.js +2 -0
  34. package/dist/chunk-2QOEHCBX.js.map +1 -0
  35. package/dist/chunk-4QT5LPBA.cjs +24 -0
  36. package/dist/chunk-4QT5LPBA.cjs.map +1 -0
  37. package/dist/chunk-5DYSI4O4.cjs +60 -0
  38. package/dist/chunk-5DYSI4O4.cjs.map +1 -0
  39. package/dist/chunk-5FJXHXFV.cjs +2 -0
  40. package/dist/chunk-5FJXHXFV.cjs.map +1 -0
  41. package/dist/chunk-6FEWNF6B.js +4 -0
  42. package/dist/chunk-6FEWNF6B.js.map +1 -0
  43. package/dist/chunk-6LF5HZCV.js +10 -0
  44. package/dist/chunk-6LF5HZCV.js.map +1 -0
  45. package/dist/chunk-7JSPKVOW.js +2 -0
  46. package/dist/chunk-7JSPKVOW.js.map +1 -0
  47. package/dist/chunk-C33XDRDJ.cjs +28 -0
  48. package/dist/chunk-C33XDRDJ.cjs.map +1 -0
  49. package/dist/chunk-CV5WFE7K.js +24 -0
  50. package/dist/chunk-CV5WFE7K.js.map +1 -0
  51. package/dist/chunk-CXJRNISO.js +2 -0
  52. package/dist/chunk-CXJRNISO.js.map +1 -0
  53. package/dist/chunk-DP6Q75ZD.js +28 -0
  54. package/dist/chunk-DP6Q75ZD.js.map +1 -0
  55. package/dist/chunk-FDANI5P4.cjs +2 -0
  56. package/dist/chunk-FDANI5P4.cjs.map +1 -0
  57. package/dist/chunk-FGVGZLBL.js +2 -0
  58. package/dist/chunk-FGVGZLBL.js.map +1 -0
  59. package/dist/chunk-GJ4GKSDU.cjs +2 -0
  60. package/dist/chunk-GJ4GKSDU.cjs.map +1 -0
  61. package/dist/chunk-GWBTKVFD.cjs +2 -0
  62. package/dist/chunk-GWBTKVFD.cjs.map +1 -0
  63. package/dist/chunk-JOYPFQW2.js +2 -0
  64. package/dist/chunk-JOYPFQW2.js.map +1 -0
  65. package/dist/chunk-L54YNLSE.js +2 -0
  66. package/dist/chunk-L54YNLSE.js.map +1 -0
  67. package/dist/chunk-LPGMLJMO.js +259 -0
  68. package/dist/chunk-LPGMLJMO.js.map +1 -0
  69. package/dist/chunk-OHG7ROFC.js +11 -0
  70. package/dist/chunk-OHG7ROFC.js.map +1 -0
  71. package/dist/chunk-PANKMCFX.cjs +4 -0
  72. package/dist/chunk-PANKMCFX.cjs.map +1 -0
  73. package/dist/chunk-QDV75OJ4.js +112 -0
  74. package/dist/chunk-QDV75OJ4.js.map +1 -0
  75. package/dist/chunk-QEBO3EQP.cjs +2 -0
  76. package/dist/{chunk-V3MCDVZE.cjs.map → chunk-QEBO3EQP.cjs.map} +1 -1
  77. package/dist/chunk-QVIZ775M.cjs +259 -0
  78. package/dist/chunk-QVIZ775M.cjs.map +1 -0
  79. package/dist/chunk-RMUMR42R.cjs +10 -0
  80. package/dist/chunk-RMUMR42R.cjs.map +1 -0
  81. package/dist/chunk-T2HQYRA7.cjs +2 -0
  82. package/dist/chunk-T2HQYRA7.cjs.map +1 -0
  83. package/dist/chunk-ULXNEG66.js +60 -0
  84. package/dist/chunk-ULXNEG66.js.map +1 -0
  85. package/dist/chunk-WD2HTKRR.cjs +2 -0
  86. package/dist/chunk-WD2HTKRR.cjs.map +1 -0
  87. package/dist/chunk-XZNOV52K.cjs +11 -0
  88. package/dist/chunk-XZNOV52K.cjs.map +1 -0
  89. package/dist/chunk-Y6VCTLCJ.js +2 -0
  90. package/dist/{chunk-AL62KQYJ.js.map → chunk-Y6VCTLCJ.js.map} +1 -1
  91. package/dist/{TableToolbar-RHX9L4h9.d.ts → clipboard-CqE-UZ2d.d.cts} +125 -2
  92. package/dist/{TableToolbar-RHX9L4h9.d.cts → clipboard-beGtyabO.d.ts} +125 -2
  93. package/dist/colorResolver-B5YbO_a4.d.ts +618 -0
  94. package/dist/colorResolver-Cu46bSKr.d.cts +618 -0
  95. package/dist/core-plugins-reexport.cjs +1 -1
  96. package/dist/core-plugins-reexport.cjs.map +1 -1
  97. package/dist/core-plugins-reexport.d.cts +31 -1
  98. package/dist/core-plugins-reexport.d.ts +31 -1
  99. package/dist/core-plugins-reexport.js +1 -1
  100. package/dist/core-plugins-reexport.js.map +1 -1
  101. package/dist/core-reexport.cjs +1 -1
  102. package/dist/core-reexport.cjs.map +1 -1
  103. package/dist/core-reexport.d.cts +309 -4
  104. package/dist/core-reexport.d.ts +309 -4
  105. package/dist/core-reexport.js +1 -1
  106. package/dist/core-reexport.js.map +1 -1
  107. package/dist/executor-K5RXUTTR.js +2 -0
  108. package/dist/executor-K5RXUTTR.js.map +1 -0
  109. package/dist/executor-XIPIU3H4.cjs +2 -0
  110. package/dist/executor-XIPIU3H4.cjs.map +1 -0
  111. package/dist/fontLoader-CFKpg0Ri.d.ts +176 -0
  112. package/dist/fontLoader-HZYfILUm.d.cts +176 -0
  113. package/dist/headless-reexport.cjs +4 -1
  114. package/dist/headless-reexport.cjs.map +1 -1
  115. package/dist/headless-reexport.d.cts +195 -1
  116. package/dist/headless-reexport.d.ts +195 -1
  117. package/dist/headless-reexport.js +4 -1
  118. package/dist/headless-reexport.js.map +1 -1
  119. package/dist/index.cjs +9 -9
  120. package/dist/index.cjs.map +1 -1
  121. package/dist/index.css +2 -0
  122. package/dist/index.css.map +1 -0
  123. package/dist/index.d.cts +261 -30
  124. package/dist/index.d.ts +261 -30
  125. package/dist/index.js +9 -9
  126. package/dist/index.js.map +1 -1
  127. package/dist/mcp-reexport.cjs +16 -1
  128. package/dist/mcp-reexport.cjs.map +1 -1
  129. package/dist/mcp-reexport.d.cts +156 -1
  130. package/dist/mcp-reexport.d.ts +156 -1
  131. package/dist/mcp-reexport.js +16 -1
  132. package/dist/mcp-reexport.js.map +1 -1
  133. package/dist/processTemplate-G37IM66O.js +2 -0
  134. package/dist/processTemplate-G37IM66O.js.map +1 -0
  135. package/dist/processTemplate-RFBGVH7T.cjs +2 -0
  136. package/dist/processTemplate-RFBGVH7T.cjs.map +1 -0
  137. package/dist/react-BjOCdeTs.d.ts +1027 -0
  138. package/dist/react-UzAn4o7l.d.cts +1027 -0
  139. package/dist/react.cjs +1 -1
  140. package/dist/react.cjs.map +1 -1
  141. package/dist/react.css +2 -0
  142. package/dist/react.css.map +1 -0
  143. package/dist/react.d.cts +10 -860
  144. package/dist/react.d.ts +10 -860
  145. package/dist/react.js +1 -1
  146. package/dist/react.js.map +1 -1
  147. package/dist/registry-CV6nYWqP.d.ts +165 -0
  148. package/dist/registry-DjacfR6Q.d.cts +165 -0
  149. package/dist/selectionRects-6DU7HN7E.js +2 -0
  150. package/dist/selectionRects-6DU7HN7E.js.map +1 -0
  151. package/dist/selectionRects-YZSC24ZP.cjs +2 -0
  152. package/dist/selectionRects-YZSC24ZP.cjs.map +1 -0
  153. package/dist/styles.css +1 -1
  154. package/dist/types-Bnp8rvJn.d.cts +310 -0
  155. package/dist/types-DwZ3xysp.d.ts +310 -0
  156. package/dist/ui.cjs +1 -1
  157. package/dist/ui.d.cts +3 -5
  158. package/dist/ui.d.ts +3 -5
  159. package/dist/ui.js +1 -1
  160. package/dist/variableDetector-BaDeXz7D.d.ts +173 -0
  161. package/dist/variableDetector-CMhJtM96.d.cts +173 -0
  162. package/package.json +10 -3
  163. package/dist/chunk-7FEY3YWC.cjs +0 -3
  164. package/dist/chunk-7FEY3YWC.cjs.map +0 -1
  165. package/dist/chunk-AL62KQYJ.js +0 -2
  166. package/dist/chunk-MXGYESPA.cjs +0 -178
  167. package/dist/chunk-MXGYESPA.cjs.map +0 -1
  168. package/dist/chunk-NMYD4OJZ.js +0 -3
  169. package/dist/chunk-NMYD4OJZ.js.map +0 -1
  170. package/dist/chunk-OD33FUTO.js +0 -178
  171. package/dist/chunk-OD33FUTO.js.map +0 -1
  172. package/dist/chunk-V3MCDVZE.cjs +0 -2
  173. package/dist/chunk-VIEW4NAF.js +0 -112
  174. package/dist/chunk-VIEW4NAF.js.map +0 -1
  175. package/dist/chunk-ZX4CSEL3.cjs +0 -112
  176. package/dist/chunk-ZX4CSEL3.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"mcp-reexport.cjs","sourcesContent":[]}
1
+ {"version":3,"sources":["../../core/src/mcp/core-tools.ts","../../core/src/mcp/server.ts"],"names":["documentIdSchema","positionSchema","rangeSchema","loadDocumentTool","input","context","content","source","binaryString","bytes","i","buffer","document","parseDocx","docId","paragraphCount","b","error","saveDocumentTool","documentId","loaded","repackDocx","createDocx","binary","base64","closeDocumentTool","getDocumentInfoTool","doc","body","paragraphs","tables","wordCount","para","text","getParagraphText","w","getDocumentTextTool","maxLength","texts","block","truncated","insertTextTool","position","newDoc","executeCommand","replaceTextTool","range","deleteTextTool","formatTextTool","formatting","applyStyleTool","paragraphIndex","styleId","paragraph","item","getRunText","getHyperlinkText","run","c","hyperlink","child","coreMcpTools","createMcpServer","config","name","version","includeCoreTools","debug","additionalTools","tools","session","tool","pluginTools","pluginRegistry","log","message","data","handleToolCall","toolName","result","listTools","convertToJsonSchema","getInfo","handleJsonRpcRequest","server","request","id","method","params","t","args","startStdioServer","rl","line","response","schema"],"mappings":"yPAqBA,IAAMA,CAAAA,CAA+B,CACnC,IAAA,CAAM,QAAA,CACN,WAAA,CAAa,qCACf,CAAA,CAEMC,CAAAA,CAA6B,CACjC,IAAA,CAAM,QAAA,CACN,UAAA,CAAY,CACV,cAAA,CAAgB,CACd,IAAA,CAAM,QAAA,CACN,WAAA,CAAa,oCAAA,CACb,OAAA,CAAS,CACX,CAAA,CACA,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,WAAA,CAAa,uCAAA,CACb,OAAA,CAAS,CACX,CACF,CAAA,CACA,QAAA,CAAU,CAAC,gBAAA,CAAkB,QAAQ,CACvC,CAAA,CAEMC,CAAAA,CAA0B,CAC9B,IAAA,CAAM,QAAA,CACN,UAAA,CAAY,CACV,KAAA,CAAOD,CAAAA,CACP,GAAA,CAAKA,CACP,CAAA,CACA,QAAA,CAAU,CAAC,OAAA,CAAS,KAAK,CAC3B,CAAA,CASaE,CAAAA,CAAsC,CACjD,IAAA,CAAM,WAAA,CACN,WAAA,CAAa,CAAA;AAAA;AAAA,oDAAA,CAAA,CAIb,YAAa,CACX,IAAA,CAAM,SACN,UAAA,CAAY,CACV,QAAS,CACP,IAAA,CAAM,SACN,WAAA,CAAa,kCACf,EACA,MAAA,CAAQ,CACN,KAAM,QAAA,CACN,WAAA,CAAa,sDACf,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ACpB,eAAA,CAAgB,CAClC,MAAO,OAAA,CAAQ,KAAA,CACf,OAAQ,OAAA,CAAQ,MAAA,CAChB,SAAU,KACZ,CAAC,EAEGjF,CAAAA,CAAS,EAAA,CAEbiF,EAAG,EAAA,CAAG,MAAA,CAAQ,MAAOC,CAAAA,EAAS,CAC5BlF,GAAUkF,CAAAA,CAGV,GAAI,CACF,IAAMR,CAAAA,CAAU,KAAK,KAAA,CAAM1E,CAAM,EACjCA,CAAAA,CAAS,EAAA,CAET,IAAMmF,CAAAA,CAAW,MAAMX,EAAqBC,CAAAA,CAAQC,CAAO,EAG3D,OAAA,CAAQ,MAAA,CAAO,MAAM,IAAA,CAAK,SAAA,CAAUS,CAAQ,CAAA,CAAI;AAAA,CAAI,EACtD,MAAQ,CAER,CACF,CAAC,CAAA,CAEDF,CAAAA,CAAG,GAAG,OAAA,CAAS,IAAM,CACf7B,CAAAA,CAAO,KAAA,EACT,QAAQ,KAAA,CAAM,qBAAqB,EAErC,OAAA,CAAQ,IAAA,CAAK,CAAC,EAChB,CAAC,EACH,CASA,SAASkB,EAAoBc,CAAAA,CAA0C,CAErE,OACE,OAAOA,CAAAA,EAAW,UAClBA,CAAAA,GAAW,IAAA,GACV,SAAUA,CAAAA,EAAU,YAAA,GAAgBA,GAE9BA,CAAAA,CAKF,CACL,KAAM,QAAA,CACN,UAAA,CAAY,EACd,CACF","file":"mcp-reexport.cjs","sourcesContent":["/**\n * Core MCP Tools\n *\n * Built-in MCP tools for document operations that are always available.\n * These provide basic document manipulation without requiring plugins.\n */\n\nimport type {\n McpToolDefinition,\n McpToolContext,\n McpToolResult,\n JsonSchema,\n} from '../core-plugins/types';\nimport { parseDocx } from '../docx/parser';\nimport { repackDocx, createDocx } from '../docx/rezip';\nimport { executeCommand } from '../agent/executor';\n\n// ============================================================================\n// SCHEMAS\n// ============================================================================\n\nconst documentIdSchema: JsonSchema = {\n type: 'string',\n description: 'Document ID returned from docx_load',\n};\n\nconst positionSchema: JsonSchema = {\n type: 'object',\n properties: {\n paragraphIndex: {\n type: 'number',\n description: 'Index of the paragraph (0-indexed)',\n minimum: 0,\n },\n offset: {\n type: 'number',\n description: 'Character offset within the paragraph',\n minimum: 0,\n },\n },\n required: ['paragraphIndex', 'offset'],\n};\n\nconst rangeSchema: JsonSchema = {\n type: 'object',\n properties: {\n start: positionSchema,\n end: positionSchema,\n },\n required: ['start', 'end'],\n};\n\n// ============================================================================\n// DOCUMENT LOADING/SAVING\n// ============================================================================\n\n/**\n * Load a DOCX document from base64\n */\nexport const loadDocumentTool: McpToolDefinition = {\n name: 'docx_load',\n description: `Load a DOCX document from base64-encoded content.\nReturns a document ID that can be used with other tools.\nThe document remains in session memory until closed.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n content: {\n type: 'string',\n description: 'Base64-encoded DOCX file content',\n },\n source: {\n type: 'string',\n description: 'Optional source filename or identifier for reference',\n },\n },\n required: ['content'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { content, source } = input as { content: string; source?: string };\n\n try {\n // Decode base64 to ArrayBuffer\n const binaryString = atob(content);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n const buffer = bytes.buffer;\n\n // Parse the document\n const document = await parseDocx(buffer);\n\n // Generate document ID\n const docId = `doc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n\n // Store in session\n context.session.documents.set(docId, {\n id: docId,\n document,\n buffer,\n source,\n lastModified: Date.now(),\n });\n\n // Get basic info\n const paragraphCount = document.package.document.content.filter(\n (b) => b.type === 'paragraph'\n ).length;\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId: docId,\n source,\n paragraphCount,\n message: 'Document loaded successfully',\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to load document: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n/**\n * Save a document to base64\n */\nexport const saveDocumentTool: McpToolDefinition = {\n name: 'docx_save',\n description: `Export the document to base64-encoded DOCX format.\nReturns the document as a base64 string that can be saved to a file.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n },\n required: ['documentId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId } = input as { documentId: string };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n // Repack or create the DOCX\n let buffer: ArrayBuffer;\n if (loaded.buffer) {\n // Preserve original structure\n buffer = await repackDocx(loaded.document);\n } else {\n // Create from scratch\n buffer = await createDocx(loaded.document);\n }\n\n // Encode to base64\n const bytes = new Uint8Array(buffer);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n const base64 = btoa(binary);\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId,\n base64,\n size: buffer.byteLength,\n message: 'Document exported successfully',\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to save document: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: true,\n complexity: 'low',\n },\n};\n\n/**\n * Close a document\n */\nexport const closeDocumentTool: McpToolDefinition = {\n name: 'docx_close',\n description: `Close a document and free its memory.\nUse this when done working with a document.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n },\n required: ['documentId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId } = input as { documentId: string };\n\n if (!context.session.documents.has(documentId)) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n context.session.documents.delete(documentId);\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId,\n message: 'Document closed',\n }),\n },\n ],\n };\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n// ============================================================================\n// DOCUMENT INFORMATION\n// ============================================================================\n\n/**\n * Get document information\n */\nexport const getDocumentInfoTool: McpToolDefinition = {\n name: 'docx_get_info',\n description: `Get metadata and statistics about a document.\nReturns paragraph count, word count, table count, and other useful info.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n },\n required: ['documentId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId } = input as { documentId: string };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n const doc = loaded.document;\n const body = doc.package.document;\n\n const paragraphs = body.content.filter((b) => b.type === 'paragraph');\n const tables = body.content.filter((b) => b.type === 'table');\n\n // Count words\n let wordCount = 0;\n for (const para of paragraphs) {\n if (para.type === 'paragraph') {\n const text = getParagraphText(para);\n wordCount += text.split(/\\s+/).filter((w) => w.length > 0).length;\n }\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId,\n paragraphCount: paragraphs.length,\n tableCount: tables.length,\n wordCount,\n hasStyles: !!doc.package.styles,\n hasTheme: !!doc.package.theme,\n source: loaded.source,\n lastModified: loaded.lastModified,\n }),\n },\n ],\n };\n },\n\n annotations: {\n category: 'core',\n readOnly: true,\n complexity: 'low',\n },\n};\n\n/**\n * Get document plain text\n */\nexport const getDocumentTextTool: McpToolDefinition = {\n name: 'docx_get_text',\n description: `Get the plain text content of the document.\nReturns all text concatenated with paragraph breaks.\nUseful for understanding document content before making edits.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n maxLength: {\n type: 'number',\n description: 'Maximum characters to return (default: 10000)',\n default: 10000,\n },\n },\n required: ['documentId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, maxLength = 10000 } = input as {\n documentId: string;\n maxLength?: number;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n const body = loaded.document.package.document;\n const texts: string[] = [];\n\n for (const block of body.content) {\n if (block.type === 'paragraph') {\n texts.push(getParagraphText(block));\n } else if (block.type === 'table') {\n texts.push('[TABLE]');\n }\n }\n\n let text = texts.join('\\n');\n const truncated = text.length > maxLength;\n if (truncated) {\n text = text.slice(0, maxLength) + '...';\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId,\n text,\n truncated,\n totalLength: truncated ? texts.join('\\n').length : text.length,\n }),\n },\n ],\n };\n },\n\n annotations: {\n category: 'core',\n readOnly: true,\n complexity: 'low',\n },\n};\n\n// ============================================================================\n// TEXT MANIPULATION\n// ============================================================================\n\n/**\n * Insert text at a position\n */\nexport const insertTextTool: McpToolDefinition = {\n name: 'docx_insert_text',\n description: `Insert text at a specific position in the document.\nPosition is specified by paragraph index (0-indexed) and character offset.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n position: positionSchema,\n text: {\n type: 'string',\n description: 'Text to insert',\n },\n },\n required: ['documentId', 'position', 'text'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, position, text } = input as {\n documentId: string;\n position: { paragraphIndex: number; offset: number };\n text: string;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'insertText',\n position,\n text,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n insertedLength: text.length,\n position,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to insert text: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n/**\n * Replace text in a range\n */\nexport const replaceTextTool: McpToolDefinition = {\n name: 'docx_replace_text',\n description: `Replace text in a range with new text.\nSpecify start and end positions to define the range to replace.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n range: rangeSchema,\n text: {\n type: 'string',\n description: 'Replacement text',\n },\n },\n required: ['documentId', 'range', 'text'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, range, text } = input as {\n documentId: string;\n range: {\n start: { paragraphIndex: number; offset: number };\n end: { paragraphIndex: number; offset: number };\n };\n text: string;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'replaceText',\n range,\n text,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n replacedRange: range,\n newTextLength: text.length,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to replace text: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n/**\n * Delete text in a range\n */\nexport const deleteTextTool: McpToolDefinition = {\n name: 'docx_delete_text',\n description: `Delete text in a range.\nSpecify start and end positions to define the range to delete.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n range: rangeSchema,\n },\n required: ['documentId', 'range'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, range } = input as {\n documentId: string;\n range: {\n start: { paragraphIndex: number; offset: number };\n end: { paragraphIndex: number; offset: number };\n };\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'deleteText',\n range,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n deletedRange: range,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to delete text: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n// ============================================================================\n// FORMATTING\n// ============================================================================\n\n/**\n * Apply text formatting\n */\nexport const formatTextTool: McpToolDefinition = {\n name: 'docx_format_text',\n description: `Apply formatting to text in a range.\nSupports bold, italic, underline, font size, font family, color, and highlight.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n range: rangeSchema,\n formatting: {\n type: 'object',\n description: 'Formatting options to apply',\n properties: {\n bold: { type: 'boolean' },\n italic: { type: 'boolean' },\n underline: { type: 'boolean' },\n strikethrough: { type: 'boolean' },\n fontSize: { type: 'number', description: 'Font size in points' },\n fontFamily: { type: 'string' },\n color: { type: 'string', description: 'Hex color (e.g., \"#FF0000\")' },\n highlight: { type: 'string', description: 'Highlight color name' },\n },\n },\n },\n required: ['documentId', 'range', 'formatting'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, range, formatting } = input as {\n documentId: string;\n range: {\n start: { paragraphIndex: number; offset: number };\n end: { paragraphIndex: number; offset: number };\n };\n formatting: Record<string, unknown>;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'formatText',\n range,\n formatting,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n range,\n appliedFormatting: formatting,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to format text: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'medium',\n },\n};\n\n/**\n * Apply paragraph style\n */\nexport const applyStyleTool: McpToolDefinition = {\n name: 'docx_apply_style',\n description: `Apply a named style to a paragraph.\nUse document styles like \"Heading1\", \"Heading2\", \"Normal\", etc.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n paragraphIndex: {\n type: 'number',\n description: 'Index of the paragraph (0-indexed)',\n minimum: 0,\n },\n styleId: {\n type: 'string',\n description: 'Style ID (e.g., \"Heading1\", \"Normal\")',\n },\n },\n required: ['documentId', 'paragraphIndex', 'styleId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, paragraphIndex, styleId } = input as {\n documentId: string;\n paragraphIndex: number;\n styleId: string;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'applyStyle',\n paragraphIndex,\n styleId,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n paragraphIndex,\n styleId,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to apply style: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n// ============================================================================\n// HELPER FUNCTIONS\n// ============================================================================\n\nimport type { Paragraph, Run, Hyperlink } from '../types/document';\n\nfunction getParagraphText(paragraph: Paragraph): string {\n const texts: string[] = [];\n\n for (const item of paragraph.content) {\n if (item.type === 'run') {\n texts.push(getRunText(item));\n } else if (item.type === 'hyperlink') {\n texts.push(getHyperlinkText(item));\n }\n }\n\n return texts.join('');\n}\n\nfunction getRunText(run: Run): string {\n return run.content\n .filter((c) => c.type === 'text')\n .map((c) => (c as { type: 'text'; text: string }).text)\n .join('');\n}\n\nfunction getHyperlinkText(hyperlink: Hyperlink): string {\n const texts: string[] = [];\n for (const child of hyperlink.children) {\n if (child.type === 'run') {\n texts.push(getRunText(child));\n }\n }\n return texts.join('');\n}\n\n// ============================================================================\n// EXPORT ALL CORE TOOLS\n// ============================================================================\n\nexport const coreMcpTools: McpToolDefinition[] = [\n // Document loading/saving\n loadDocumentTool,\n saveDocumentTool,\n closeDocumentTool,\n\n // Document information\n getDocumentInfoTool,\n getDocumentTextTool,\n\n // Text manipulation\n insertTextTool,\n replaceTextTool,\n deleteTextTool,\n\n // Formatting\n formatTextTool,\n applyStyleTool,\n];\n","/**\n * MCP Server\n *\n * Model Context Protocol server that exposes document editing tools to AI clients.\n * Discovers and registers tools from the plugin system plus core built-in tools.\n *\n * @example\n * ```ts\n * import { createMcpServer, startStdioServer } from '@eigenpal/docx-editor/mcp';\n * import { pluginRegistry, docxtemplaterPlugin } from '@eigenpal/docx-editor/core-plugins';\n *\n * // Register plugins\n * pluginRegistry.register(docxtemplaterPlugin);\n *\n * // Start MCP server\n * startStdioServer();\n * ```\n */\n\nimport type {\n McpToolDefinition,\n McpToolContext,\n McpSession,\n LoadedDocument,\n JsonSchema,\n} from '../core-plugins/types';\nimport { pluginRegistry } from '../core-plugins/registry';\nimport { coreMcpTools } from './core-tools';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\n/**\n * MCP Server configuration\n */\nexport interface McpServerConfig {\n /** Server name */\n name?: string;\n\n /** Server version */\n version?: string;\n\n /** Include core tools (default: true) */\n includeCoreTools?: boolean;\n\n /** Enable debug logging */\n debug?: boolean;\n\n /** Custom tools to add */\n additionalTools?: McpToolDefinition[];\n}\n\n/**\n * MCP Server instance\n */\nexport interface McpServer {\n /** All registered tools */\n tools: Map<string, McpToolDefinition>;\n\n /** Active session */\n session: McpSession;\n\n /** Handle a tool call */\n handleToolCall(toolName: string, input: unknown): Promise<unknown>;\n\n /** List available tools */\n listTools(): McpToolInfo[];\n\n /** Get server info */\n getInfo(): { name: string; version: string; toolCount: number };\n}\n\n/**\n * Tool info for listing\n */\nexport interface McpToolInfo {\n name: string;\n description: string;\n inputSchema: JsonSchema;\n category?: string;\n}\n\n// ============================================================================\n// SERVER CREATION\n// ============================================================================\n\n/**\n * Create an MCP server instance\n *\n * @param config - Server configuration\n * @returns MCP server instance\n */\nexport function createMcpServer(config: McpServerConfig = {}): McpServer {\n const {\n name = 'docx-editor',\n version = '0.1.0',\n includeCoreTools = true,\n debug = false,\n additionalTools = [],\n } = config;\n\n const tools = new Map<string, McpToolDefinition>();\n\n // Create session\n const session: McpSession = {\n id: `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,\n documents: new Map<string, LoadedDocument>(),\n data: new Map<string, unknown>(),\n };\n\n // Register core tools\n if (includeCoreTools) {\n for (const tool of coreMcpTools) {\n tools.set(tool.name, tool);\n if (debug) {\n console.log(`[MCP] Registered core tool: ${tool.name}`);\n }\n }\n }\n\n // Register plugin tools\n const pluginTools = pluginRegistry.getMcpTools();\n for (const tool of pluginTools) {\n if (tools.has(tool.name)) {\n console.warn(`[MCP] Tool '${tool.name}' from plugin overrides existing tool`);\n }\n tools.set(tool.name, tool);\n if (debug) {\n console.log(`[MCP] Registered plugin tool: ${tool.name}`);\n }\n }\n\n // Register additional tools\n for (const tool of additionalTools) {\n tools.set(tool.name, tool);\n if (debug) {\n console.log(`[MCP] Registered additional tool: ${tool.name}`);\n }\n }\n\n // Create logger\n const log = debug\n ? (message: string, data?: unknown) => {\n console.log(`[MCP] ${message}`, data ?? '');\n }\n : () => {};\n\n // Handle tool call\n async function handleToolCall(toolName: string, input: unknown): Promise<unknown> {\n const tool = tools.get(toolName);\n if (!tool) {\n throw new Error(`Unknown tool: ${toolName}`);\n }\n\n log(`Calling tool: ${toolName}`, input);\n\n // Create context\n const context: McpToolContext = {\n session,\n log,\n };\n\n // Execute handler\n try {\n const result = await tool.handler(input, context);\n log(`Tool ${toolName} completed`, result);\n return result;\n } catch (error) {\n log(`Tool ${toolName} failed`, error);\n throw error;\n }\n }\n\n // List tools\n function listTools(): McpToolInfo[] {\n return Array.from(tools.values()).map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: convertToJsonSchema(tool.inputSchema),\n category: tool.annotations?.category,\n }));\n }\n\n // Get info\n function getInfo() {\n return {\n name,\n version,\n toolCount: tools.size,\n };\n }\n\n return {\n tools,\n session,\n handleToolCall,\n listTools,\n getInfo,\n };\n}\n\n// ============================================================================\n// JSON-RPC PROTOCOL\n// ============================================================================\n\n/**\n * JSON-RPC request\n */\ninterface JsonRpcRequest {\n jsonrpc: '2.0';\n id: string | number;\n method: string;\n params?: unknown;\n}\n\n/**\n * JSON-RPC response\n */\ninterface JsonRpcResponse {\n jsonrpc: '2.0';\n id: string | number;\n result?: unknown;\n error?: {\n code: number;\n message: string;\n data?: unknown;\n };\n}\n\n/**\n * Handle a JSON-RPC request\n */\nexport async function handleJsonRpcRequest(\n server: McpServer,\n request: JsonRpcRequest\n): Promise<JsonRpcResponse> {\n const { id, method, params } = request;\n\n try {\n switch (method) {\n case 'initialize': {\n return {\n jsonrpc: '2.0',\n id,\n result: {\n protocolVersion: '2024-11-05',\n capabilities: {\n tools: {},\n },\n serverInfo: server.getInfo(),\n },\n };\n }\n\n case 'tools/list': {\n const tools = server.listTools();\n return {\n jsonrpc: '2.0',\n id,\n result: {\n tools: tools.map((t) => ({\n name: t.name,\n description: t.description,\n inputSchema: t.inputSchema,\n })),\n },\n };\n }\n\n case 'tools/call': {\n const { name, arguments: args } = params as {\n name: string;\n arguments: unknown;\n };\n const result = await server.handleToolCall(name, args);\n return {\n jsonrpc: '2.0',\n id,\n result,\n };\n }\n\n default:\n return {\n jsonrpc: '2.0',\n id,\n error: {\n code: -32601,\n message: `Method not found: ${method}`,\n },\n };\n }\n } catch (error) {\n return {\n jsonrpc: '2.0',\n id,\n error: {\n code: -32000,\n message: (error as Error).message,\n },\n };\n }\n}\n\n// ============================================================================\n// STDIO TRANSPORT\n// ============================================================================\n\n/**\n * Start the MCP server with stdio transport\n *\n * Reads JSON-RPC requests from stdin, writes responses to stdout.\n * This is the standard way to run an MCP server for Claude Desktop.\n */\nexport async function startStdioServer(config: McpServerConfig = {}): Promise<void> {\n const server = createMcpServer(config);\n\n if (config.debug) {\n console.error(`[MCP] Server started: ${server.getInfo().name} v${server.getInfo().version}`);\n console.error(`[MCP] Tools registered: ${server.tools.size}`);\n }\n\n // Read from stdin\n const readline = await import('readline');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n });\n\n let buffer = '';\n\n rl.on('line', async (line) => {\n buffer += line;\n\n // Try to parse complete JSON\n try {\n const request = JSON.parse(buffer) as JsonRpcRequest;\n buffer = '';\n\n const response = await handleJsonRpcRequest(server, request);\n\n // Write response to stdout\n process.stdout.write(JSON.stringify(response) + '\\n');\n } catch {\n // Incomplete JSON, wait for more\n }\n });\n\n rl.on('close', () => {\n if (config.debug) {\n console.error('[MCP] Server closed');\n }\n process.exit(0);\n });\n}\n\n// ============================================================================\n// HELPER FUNCTIONS\n// ============================================================================\n\n/**\n * Convert schema to JSON Schema format\n */\nfunction convertToJsonSchema(schema: JsonSchema | unknown): JsonSchema {\n // If it's already a JSON Schema object, return it\n if (\n typeof schema === 'object' &&\n schema !== null &&\n ('type' in schema || 'properties' in schema)\n ) {\n return schema as JsonSchema;\n }\n\n // If it's a Zod-like schema, try to convert\n // For now, just return a basic object schema\n return {\n type: 'object',\n properties: {},\n };\n}\n\n// ============================================================================\n// EXPORTS\n// ============================================================================\n\nexport { coreMcpTools } from './core-tools';\n"]}
@@ -1 +1,156 @@
1
- export * from '@eigenpal/docx-core/mcp';
1
+ import { M as McpToolDefinition, e as McpSession, J as JsonSchema } from './types-Bnp8rvJn.cjs';
2
+ import './agentApi-BFVyKagE.cjs';
3
+
4
+ /**
5
+ * Core MCP Tools
6
+ *
7
+ * Built-in MCP tools for document operations that are always available.
8
+ * These provide basic document manipulation without requiring plugins.
9
+ */
10
+
11
+ /**
12
+ * Load a DOCX document from base64
13
+ */
14
+ declare const loadDocumentTool: McpToolDefinition;
15
+ /**
16
+ * Save a document to base64
17
+ */
18
+ declare const saveDocumentTool: McpToolDefinition;
19
+ /**
20
+ * Close a document
21
+ */
22
+ declare const closeDocumentTool: McpToolDefinition;
23
+ /**
24
+ * Get document information
25
+ */
26
+ declare const getDocumentInfoTool: McpToolDefinition;
27
+ /**
28
+ * Get document plain text
29
+ */
30
+ declare const getDocumentTextTool: McpToolDefinition;
31
+ /**
32
+ * Insert text at a position
33
+ */
34
+ declare const insertTextTool: McpToolDefinition;
35
+ /**
36
+ * Replace text in a range
37
+ */
38
+ declare const replaceTextTool: McpToolDefinition;
39
+ /**
40
+ * Delete text in a range
41
+ */
42
+ declare const deleteTextTool: McpToolDefinition;
43
+ /**
44
+ * Apply text formatting
45
+ */
46
+ declare const formatTextTool: McpToolDefinition;
47
+ /**
48
+ * Apply paragraph style
49
+ */
50
+ declare const applyStyleTool: McpToolDefinition;
51
+ declare const coreMcpTools: McpToolDefinition[];
52
+
53
+ /**
54
+ * MCP Server
55
+ *
56
+ * Model Context Protocol server that exposes document editing tools to AI clients.
57
+ * Discovers and registers tools from the plugin system plus core built-in tools.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { createMcpServer, startStdioServer } from '@eigenpal/docx-editor/mcp';
62
+ * import { pluginRegistry, docxtemplaterPlugin } from '@eigenpal/docx-editor/core-plugins';
63
+ *
64
+ * // Register plugins
65
+ * pluginRegistry.register(docxtemplaterPlugin);
66
+ *
67
+ * // Start MCP server
68
+ * startStdioServer();
69
+ * ```
70
+ */
71
+
72
+ /**
73
+ * MCP Server configuration
74
+ */
75
+ interface McpServerConfig {
76
+ /** Server name */
77
+ name?: string;
78
+ /** Server version */
79
+ version?: string;
80
+ /** Include core tools (default: true) */
81
+ includeCoreTools?: boolean;
82
+ /** Enable debug logging */
83
+ debug?: boolean;
84
+ /** Custom tools to add */
85
+ additionalTools?: McpToolDefinition[];
86
+ }
87
+ /**
88
+ * MCP Server instance
89
+ */
90
+ interface McpServer {
91
+ /** All registered tools */
92
+ tools: Map<string, McpToolDefinition>;
93
+ /** Active session */
94
+ session: McpSession;
95
+ /** Handle a tool call */
96
+ handleToolCall(toolName: string, input: unknown): Promise<unknown>;
97
+ /** List available tools */
98
+ listTools(): McpToolInfo[];
99
+ /** Get server info */
100
+ getInfo(): {
101
+ name: string;
102
+ version: string;
103
+ toolCount: number;
104
+ };
105
+ }
106
+ /**
107
+ * Tool info for listing
108
+ */
109
+ interface McpToolInfo {
110
+ name: string;
111
+ description: string;
112
+ inputSchema: JsonSchema;
113
+ category?: string;
114
+ }
115
+ /**
116
+ * Create an MCP server instance
117
+ *
118
+ * @param config - Server configuration
119
+ * @returns MCP server instance
120
+ */
121
+ declare function createMcpServer(config?: McpServerConfig): McpServer;
122
+ /**
123
+ * JSON-RPC request
124
+ */
125
+ interface JsonRpcRequest {
126
+ jsonrpc: '2.0';
127
+ id: string | number;
128
+ method: string;
129
+ params?: unknown;
130
+ }
131
+ /**
132
+ * JSON-RPC response
133
+ */
134
+ interface JsonRpcResponse {
135
+ jsonrpc: '2.0';
136
+ id: string | number;
137
+ result?: unknown;
138
+ error?: {
139
+ code: number;
140
+ message: string;
141
+ data?: unknown;
142
+ };
143
+ }
144
+ /**
145
+ * Handle a JSON-RPC request
146
+ */
147
+ declare function handleJsonRpcRequest(server: McpServer, request: JsonRpcRequest): Promise<JsonRpcResponse>;
148
+ /**
149
+ * Start the MCP server with stdio transport
150
+ *
151
+ * Reads JSON-RPC requests from stdin, writes responses to stdout.
152
+ * This is the standard way to run an MCP server for Claude Desktop.
153
+ */
154
+ declare function startStdioServer(config?: McpServerConfig): Promise<void>;
155
+
156
+ export { type McpServer, type McpServerConfig, type McpToolInfo, applyStyleTool, closeDocumentTool, coreMcpTools, createMcpServer, deleteTextTool, formatTextTool, getDocumentInfoTool, getDocumentTextTool, handleJsonRpcRequest, insertTextTool, loadDocumentTool, replaceTextTool, saveDocumentTool, startStdioServer };
@@ -1 +1,156 @@
1
- export * from '@eigenpal/docx-core/mcp';
1
+ import { M as McpToolDefinition, e as McpSession, J as JsonSchema } from './types-DwZ3xysp.js';
2
+ import './agentApi-BFVyKagE.js';
3
+
4
+ /**
5
+ * Core MCP Tools
6
+ *
7
+ * Built-in MCP tools for document operations that are always available.
8
+ * These provide basic document manipulation without requiring plugins.
9
+ */
10
+
11
+ /**
12
+ * Load a DOCX document from base64
13
+ */
14
+ declare const loadDocumentTool: McpToolDefinition;
15
+ /**
16
+ * Save a document to base64
17
+ */
18
+ declare const saveDocumentTool: McpToolDefinition;
19
+ /**
20
+ * Close a document
21
+ */
22
+ declare const closeDocumentTool: McpToolDefinition;
23
+ /**
24
+ * Get document information
25
+ */
26
+ declare const getDocumentInfoTool: McpToolDefinition;
27
+ /**
28
+ * Get document plain text
29
+ */
30
+ declare const getDocumentTextTool: McpToolDefinition;
31
+ /**
32
+ * Insert text at a position
33
+ */
34
+ declare const insertTextTool: McpToolDefinition;
35
+ /**
36
+ * Replace text in a range
37
+ */
38
+ declare const replaceTextTool: McpToolDefinition;
39
+ /**
40
+ * Delete text in a range
41
+ */
42
+ declare const deleteTextTool: McpToolDefinition;
43
+ /**
44
+ * Apply text formatting
45
+ */
46
+ declare const formatTextTool: McpToolDefinition;
47
+ /**
48
+ * Apply paragraph style
49
+ */
50
+ declare const applyStyleTool: McpToolDefinition;
51
+ declare const coreMcpTools: McpToolDefinition[];
52
+
53
+ /**
54
+ * MCP Server
55
+ *
56
+ * Model Context Protocol server that exposes document editing tools to AI clients.
57
+ * Discovers and registers tools from the plugin system plus core built-in tools.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { createMcpServer, startStdioServer } from '@eigenpal/docx-editor/mcp';
62
+ * import { pluginRegistry, docxtemplaterPlugin } from '@eigenpal/docx-editor/core-plugins';
63
+ *
64
+ * // Register plugins
65
+ * pluginRegistry.register(docxtemplaterPlugin);
66
+ *
67
+ * // Start MCP server
68
+ * startStdioServer();
69
+ * ```
70
+ */
71
+
72
+ /**
73
+ * MCP Server configuration
74
+ */
75
+ interface McpServerConfig {
76
+ /** Server name */
77
+ name?: string;
78
+ /** Server version */
79
+ version?: string;
80
+ /** Include core tools (default: true) */
81
+ includeCoreTools?: boolean;
82
+ /** Enable debug logging */
83
+ debug?: boolean;
84
+ /** Custom tools to add */
85
+ additionalTools?: McpToolDefinition[];
86
+ }
87
+ /**
88
+ * MCP Server instance
89
+ */
90
+ interface McpServer {
91
+ /** All registered tools */
92
+ tools: Map<string, McpToolDefinition>;
93
+ /** Active session */
94
+ session: McpSession;
95
+ /** Handle a tool call */
96
+ handleToolCall(toolName: string, input: unknown): Promise<unknown>;
97
+ /** List available tools */
98
+ listTools(): McpToolInfo[];
99
+ /** Get server info */
100
+ getInfo(): {
101
+ name: string;
102
+ version: string;
103
+ toolCount: number;
104
+ };
105
+ }
106
+ /**
107
+ * Tool info for listing
108
+ */
109
+ interface McpToolInfo {
110
+ name: string;
111
+ description: string;
112
+ inputSchema: JsonSchema;
113
+ category?: string;
114
+ }
115
+ /**
116
+ * Create an MCP server instance
117
+ *
118
+ * @param config - Server configuration
119
+ * @returns MCP server instance
120
+ */
121
+ declare function createMcpServer(config?: McpServerConfig): McpServer;
122
+ /**
123
+ * JSON-RPC request
124
+ */
125
+ interface JsonRpcRequest {
126
+ jsonrpc: '2.0';
127
+ id: string | number;
128
+ method: string;
129
+ params?: unknown;
130
+ }
131
+ /**
132
+ * JSON-RPC response
133
+ */
134
+ interface JsonRpcResponse {
135
+ jsonrpc: '2.0';
136
+ id: string | number;
137
+ result?: unknown;
138
+ error?: {
139
+ code: number;
140
+ message: string;
141
+ data?: unknown;
142
+ };
143
+ }
144
+ /**
145
+ * Handle a JSON-RPC request
146
+ */
147
+ declare function handleJsonRpcRequest(server: McpServer, request: JsonRpcRequest): Promise<JsonRpcResponse>;
148
+ /**
149
+ * Start the MCP server with stdio transport
150
+ *
151
+ * Reads JSON-RPC requests from stdin, writes responses to stdout.
152
+ * This is the standard way to run an MCP server for Claude Desktop.
153
+ */
154
+ declare function startStdioServer(config?: McpServerConfig): Promise<void>;
155
+
156
+ export { type McpServer, type McpServerConfig, type McpToolInfo, applyStyleTool, closeDocumentTool, coreMcpTools, createMcpServer, deleteTextTool, formatTextTool, getDocumentInfoTool, getDocumentTextTool, handleJsonRpcRequest, insertTextTool, loadDocumentTool, replaceTextTool, saveDocumentTool, startStdioServer };
@@ -1,2 +1,17 @@
1
- export*from'@eigenpal/docx-core/mcp';//# sourceMappingURL=mcp-reexport.js.map
1
+ import {d,e}from'./chunk-ULXNEG66.js';import {a}from'./chunk-JOYPFQW2.js';import {q as q$1}from'./chunk-DP6Q75ZD.js';import {b}from'./chunk-2QOEHCBX.js';import'./chunk-Y6VCTLCJ.js';var u={type:"string",description:"Document ID returned from docx_load"},h={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},T={type:"object",properties:{start:h,end:h},required:["start","end"]},D={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
2
+ Returns a document ID that can be used with other tools.
3
+ The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o=n.buffer,a=await q$1(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a,buffer:o,source:c,lastModified:Date.now()});let p=a.package.document.content.filter(l=>l.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:d,source:c,paragraphCount:p,message:"Document loaded successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to load document: ${t.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},C={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
4
+ Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e$1}=r,c=s.session.documents.get(e$1);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e$1}`}]};try{let t;c.buffer?t=await d(c.document):t=await e(c.document);let n=new Uint8Array(t),o="";for(let d=0;d<n.length;d++)o+=String.fromCharCode(n[d]);let a=btoa(o);return {content:[{type:"text",text:JSON.stringify({documentId:e$1,base64:a,size:t.byteLength,message:"Document exported successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to save document: ${t.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},R={name:"docx_close",description:`Close a document and free its memory.
5
+ Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r;return s.session.documents.has(e)?(s.session.documents.delete(e),{content:[{type:"text",text:JSON.stringify({documentId:e,message:"Document closed"})}]}):{isError:true,content:[{type:"text",text:`Document not found: ${e}`}]}},annotations:{category:"core",readOnly:false,complexity:"low"}},k={name:"docx_get_info",description:`Get metadata and statistics about a document.
6
+ Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(x=>x.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:e,paragraphCount:o.length,tableCount:a.length,wordCount:d,hasStyles:!!t.package.styles,hasTheme:!!t.package.theme,source:c.source,lastModified:c.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},$={name:"docx_get_text",description:`Get the plain text content of the document.
7
+ Returns all text concatenated with paragraph breaks.
8
+ Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:u,maxLength:{type:"number",description:"Maximum characters to return (default: 10000)",default:1e4}},required:["documentId"]},handler:async(r,s)=>{let{documentId:e,maxLength:c=1e4}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let n=t.document.package.document,o=[];for(let p of n.content)p.type==="paragraph"?o.push(P(p)):p.type==="table"&&o.push("[TABLE]");let a=o.join(`
9
+ `),d=a.length>c;return d&&(a=a.slice(0,c)+"..."),{content:[{type:"text",text:JSON.stringify({documentId:e,text:a,truncated:d,totalLength:d?o.join(`
10
+ `).length:a.length})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},J={name:"docx_insert_text",description:`Insert text at a specific position in the document.
11
+ Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:h,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(r,s)=>{let{documentId:e,position:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"insertText",position:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:t.length,position:c})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},v={name:"docx_replace_text",description:`Replace text in a range with new text.
12
+ Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:T,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(r,s)=>{let{documentId:e,range:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"replaceText",range:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:c,newTextLength:t.length})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},j={name:"docx_delete_text",description:`Delete text in a range.
13
+ Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:T},required:["documentId","range"]},handler:async(r,s)=>{let{documentId:e,range:c}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let n=a(t.document,{type:"deleteText",range:c});return t.document=n,t.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:c})}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${n.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},E={name:"docx_format_text",description:`Apply formatting to text in a range.
14
+ Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:T,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(r,s)=>{let{documentId:e,range:c,formatting:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"formatText",range:c,formatting:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:c,appliedFormatting:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to format text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},O={name:"docx_apply_style",description:`Apply a named style to a paragraph.
15
+ Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var y=[D,C,R,k,$,J,v,j,E,O];function q(r={}){let{name:s="docx-editor",version:e="0.1.0",includeCoreTools:c=true,debug:t=false,additionalTools:n=[]}=r,o=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(c)for(let i of y)o.set(i.name,i),t&&console.log(`[MCP] Registered core tool: ${i.name}`);let d=b.getMcpTools();for(let i of d)o.has(i.name)&&console.warn(`[MCP] Tool '${i.name}' from plugin overrides existing tool`),o.set(i.name,i),t&&console.log(`[MCP] Registered plugin tool: ${i.name}`);for(let i of n)o.set(i.name,i),t&&console.log(`[MCP] Registered additional tool: ${i.name}`);let p=t?(i,f)=>{console.log(`[MCP] ${i}`,f??"");}:()=>{};async function l(i,f){let M=o.get(i);if(!M)throw new Error(`Unknown tool: ${i}`);p(`Calling tool: ${i}`,f);let N={session:a,log:p};try{let g=await M.handler(f,N);return p(`Tool ${i} completed`,g),g}catch(g){throw p(`Tool ${i} failed`,g),g}}function x(){return Array.from(o.values()).map(i=>({name:i.name,description:i.description,inputSchema:z(i.inputSchema),category:i.annotations?.category}))}function L(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:x,getInfo:L}}async function F(r,s){let{id:e,method:c,params:t}=s;try{switch(c){case "initialize":return {jsonrpc:"2.0",id:e,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:r.getInfo()}};case "tools/list":{let n=r.listTools();return {jsonrpc:"2.0",id:e,result:{tools:n.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))}}}case "tools/call":{let{name:n,arguments:o}=t,a=await r.handleToolCall(n,o);return {jsonrpc:"2.0",id:e,result:a}}default:return {jsonrpc:"2.0",id:e,error:{code:-32601,message:`Method not found: ${c}`}}}}catch(n){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:n.message}}}}async function H(r={}){let s=q(r);r.debug&&(console.error(`[MCP] Server started: ${s.getInfo().name} v${s.getInfo().version}`),console.error(`[MCP] Tools registered: ${s.tools.size}`));let c=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),t="";c.on("line",async n=>{t+=n;try{let o=JSON.parse(t);t="";let a=await F(s,o);process.stdout.write(JSON.stringify(a)+`
16
+ `);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}export{O as applyStyleTool,R as closeDocumentTool,y as coreMcpTools,q as createMcpServer,j as deleteTextTool,E as formatTextTool,k as getDocumentInfoTool,$ as getDocumentTextTool,F as handleJsonRpcRequest,J as insertTextTool,D as loadDocumentTool,v as replaceTextTool,C as saveDocumentTool,H as startStdioServer};//# sourceMappingURL=mcp-reexport.js.map
2
17
  //# sourceMappingURL=mcp-reexport.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"mcp-reexport.js","sourcesContent":[]}
1
+ {"version":3,"sources":["../../core/src/mcp/core-tools.ts","../../core/src/mcp/server.ts"],"names":["documentIdSchema","positionSchema","rangeSchema","loadDocumentTool","input","context","content","source","binaryString","bytes","i","buffer","document","parseDocx","docId","paragraphCount","b","error","saveDocumentTool","documentId","loaded","repackDocx","createDocx","binary","base64","closeDocumentTool","getDocumentInfoTool","doc","body","paragraphs","tables","wordCount","para","text","getParagraphText","w","getDocumentTextTool","maxLength","texts","block","truncated","insertTextTool","position","newDoc","executeCommand","replaceTextTool","range","deleteTextTool","formatTextTool","formatting","applyStyleTool","paragraphIndex","styleId","paragraph","item","getRunText","getHyperlinkText","run","c","hyperlink","child","coreMcpTools","createMcpServer","config","name","version","includeCoreTools","debug","additionalTools","tools","session","tool","pluginTools","pluginRegistry","log","message","data","handleToolCall","toolName","result","listTools","convertToJsonSchema","getInfo","handleJsonRpcRequest","server","request","id","method","params","t","args","startStdioServer","rl","line","response","schema"],"mappings":"qLAqBA,IAAMA,CAAAA,CAA+B,CACnC,IAAA,CAAM,QAAA,CACN,WAAA,CAAa,qCACf,CAAA,CAEMC,CAAAA,CAA6B,CACjC,IAAA,CAAM,QAAA,CACN,UAAA,CAAY,CACV,cAAA,CAAgB,CACd,IAAA,CAAM,QAAA,CACN,WAAA,CAAa,oCAAA,CACb,OAAA,CAAS,CACX,CAAA,CACA,MAAA,CAAQ,CACN,IAAA,CAAM,QAAA,CACN,WAAA,CAAa,uCAAA,CACb,OAAA,CAAS,CACX,CACF,CAAA,CACA,QAAA,CAAU,CAAC,gBAAA,CAAkB,QAAQ,CACvC,CAAA,CAEMC,CAAAA,CAA0B,CAC9B,IAAA,CAAM,QAAA,CACN,UAAA,CAAY,CACV,KAAA,CAAOD,CAAAA,CACP,GAAA,CAAKA,CACP,CAAA,CACA,QAAA,CAAU,CAAC,O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A,CAAM,CAAA,sBAAA,EAAyBqB,EAAO,OAAA,EAAQ,CAAE,IAAI,CAAA,EAAA,EAAKA,CAAAA,CAAO,SAAQ,CAAE,OAAO,EAAE,CAAA,CAC3F,OAAA,CAAQ,MAAM,CAAA,wBAAA,EAA2BA,CAAAA,CAAO,MAAM,IAAI,CAAA,CAAE,GAK9D,IAAMQ,CAAAA,CAAAA,CADW,MAAM,OAAO,UAAU,GACpB,eAAA,CAAgB,CAClC,MAAO,OAAA,CAAQ,KAAA,CACf,OAAQ,OAAA,CAAQ,MAAA,CAChB,SAAU,KACZ,CAAC,EAEGjF,CAAAA,CAAS,EAAA,CAEbiF,EAAG,EAAA,CAAG,MAAA,CAAQ,MAAOC,CAAAA,EAAS,CAC5BlF,GAAUkF,CAAAA,CAGV,GAAI,CACF,IAAMR,CAAAA,CAAU,KAAK,KAAA,CAAM1E,CAAM,EACjCA,CAAAA,CAAS,EAAA,CAET,IAAMmF,CAAAA,CAAW,MAAMX,EAAqBC,CAAAA,CAAQC,CAAO,EAG3D,OAAA,CAAQ,MAAA,CAAO,MAAM,IAAA,CAAK,SAAA,CAAUS,CAAQ,CAAA,CAAI;AAAA,CAAI,EACtD,MAAQ,CAER,CACF,CAAC,CAAA,CAEDF,CAAAA,CAAG,GAAG,OAAA,CAAS,IAAM,CACf7B,CAAAA,CAAO,KAAA,EACT,QAAQ,KAAA,CAAM,qBAAqB,EAErC,OAAA,CAAQ,IAAA,CAAK,CAAC,EAChB,CAAC,EACH,CASA,SAASkB,EAAoBc,CAAAA,CAA0C,CAErE,OACE,OAAOA,CAAAA,EAAW,UAClBA,CAAAA,GAAW,IAAA,GACV,SAAUA,CAAAA,EAAU,YAAA,GAAgBA,GAE9BA,CAAAA,CAKF,CACL,KAAM,QAAA,CACN,UAAA,CAAY,EACd,CACF","file":"mcp-reexport.js","sourcesContent":["/**\n * Core MCP Tools\n *\n * Built-in MCP tools for document operations that are always available.\n * These provide basic document manipulation without requiring plugins.\n */\n\nimport type {\n McpToolDefinition,\n McpToolContext,\n McpToolResult,\n JsonSchema,\n} from '../core-plugins/types';\nimport { parseDocx } from '../docx/parser';\nimport { repackDocx, createDocx } from '../docx/rezip';\nimport { executeCommand } from '../agent/executor';\n\n// ============================================================================\n// SCHEMAS\n// ============================================================================\n\nconst documentIdSchema: JsonSchema = {\n type: 'string',\n description: 'Document ID returned from docx_load',\n};\n\nconst positionSchema: JsonSchema = {\n type: 'object',\n properties: {\n paragraphIndex: {\n type: 'number',\n description: 'Index of the paragraph (0-indexed)',\n minimum: 0,\n },\n offset: {\n type: 'number',\n description: 'Character offset within the paragraph',\n minimum: 0,\n },\n },\n required: ['paragraphIndex', 'offset'],\n};\n\nconst rangeSchema: JsonSchema = {\n type: 'object',\n properties: {\n start: positionSchema,\n end: positionSchema,\n },\n required: ['start', 'end'],\n};\n\n// ============================================================================\n// DOCUMENT LOADING/SAVING\n// ============================================================================\n\n/**\n * Load a DOCX document from base64\n */\nexport const loadDocumentTool: McpToolDefinition = {\n name: 'docx_load',\n description: `Load a DOCX document from base64-encoded content.\nReturns a document ID that can be used with other tools.\nThe document remains in session memory until closed.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n content: {\n type: 'string',\n description: 'Base64-encoded DOCX file content',\n },\n source: {\n type: 'string',\n description: 'Optional source filename or identifier for reference',\n },\n },\n required: ['content'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { content, source } = input as { content: string; source?: string };\n\n try {\n // Decode base64 to ArrayBuffer\n const binaryString = atob(content);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n const buffer = bytes.buffer;\n\n // Parse the document\n const document = await parseDocx(buffer);\n\n // Generate document ID\n const docId = `doc_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n\n // Store in session\n context.session.documents.set(docId, {\n id: docId,\n document,\n buffer,\n source,\n lastModified: Date.now(),\n });\n\n // Get basic info\n const paragraphCount = document.package.document.content.filter(\n (b) => b.type === 'paragraph'\n ).length;\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId: docId,\n source,\n paragraphCount,\n message: 'Document loaded successfully',\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to load document: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n/**\n * Save a document to base64\n */\nexport const saveDocumentTool: McpToolDefinition = {\n name: 'docx_save',\n description: `Export the document to base64-encoded DOCX format.\nReturns the document as a base64 string that can be saved to a file.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n },\n required: ['documentId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId } = input as { documentId: string };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n // Repack or create the DOCX\n let buffer: ArrayBuffer;\n if (loaded.buffer) {\n // Preserve original structure\n buffer = await repackDocx(loaded.document);\n } else {\n // Create from scratch\n buffer = await createDocx(loaded.document);\n }\n\n // Encode to base64\n const bytes = new Uint8Array(buffer);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n const base64 = btoa(binary);\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId,\n base64,\n size: buffer.byteLength,\n message: 'Document exported successfully',\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to save document: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: true,\n complexity: 'low',\n },\n};\n\n/**\n * Close a document\n */\nexport const closeDocumentTool: McpToolDefinition = {\n name: 'docx_close',\n description: `Close a document and free its memory.\nUse this when done working with a document.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n },\n required: ['documentId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId } = input as { documentId: string };\n\n if (!context.session.documents.has(documentId)) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n context.session.documents.delete(documentId);\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId,\n message: 'Document closed',\n }),\n },\n ],\n };\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n// ============================================================================\n// DOCUMENT INFORMATION\n// ============================================================================\n\n/**\n * Get document information\n */\nexport const getDocumentInfoTool: McpToolDefinition = {\n name: 'docx_get_info',\n description: `Get metadata and statistics about a document.\nReturns paragraph count, word count, table count, and other useful info.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n },\n required: ['documentId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId } = input as { documentId: string };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n const doc = loaded.document;\n const body = doc.package.document;\n\n const paragraphs = body.content.filter((b) => b.type === 'paragraph');\n const tables = body.content.filter((b) => b.type === 'table');\n\n // Count words\n let wordCount = 0;\n for (const para of paragraphs) {\n if (para.type === 'paragraph') {\n const text = getParagraphText(para);\n wordCount += text.split(/\\s+/).filter((w) => w.length > 0).length;\n }\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId,\n paragraphCount: paragraphs.length,\n tableCount: tables.length,\n wordCount,\n hasStyles: !!doc.package.styles,\n hasTheme: !!doc.package.theme,\n source: loaded.source,\n lastModified: loaded.lastModified,\n }),\n },\n ],\n };\n },\n\n annotations: {\n category: 'core',\n readOnly: true,\n complexity: 'low',\n },\n};\n\n/**\n * Get document plain text\n */\nexport const getDocumentTextTool: McpToolDefinition = {\n name: 'docx_get_text',\n description: `Get the plain text content of the document.\nReturns all text concatenated with paragraph breaks.\nUseful for understanding document content before making edits.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n maxLength: {\n type: 'number',\n description: 'Maximum characters to return (default: 10000)',\n default: 10000,\n },\n },\n required: ['documentId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, maxLength = 10000 } = input as {\n documentId: string;\n maxLength?: number;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n const body = loaded.document.package.document;\n const texts: string[] = [];\n\n for (const block of body.content) {\n if (block.type === 'paragraph') {\n texts.push(getParagraphText(block));\n } else if (block.type === 'table') {\n texts.push('[TABLE]');\n }\n }\n\n let text = texts.join('\\n');\n const truncated = text.length > maxLength;\n if (truncated) {\n text = text.slice(0, maxLength) + '...';\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n documentId,\n text,\n truncated,\n totalLength: truncated ? texts.join('\\n').length : text.length,\n }),\n },\n ],\n };\n },\n\n annotations: {\n category: 'core',\n readOnly: true,\n complexity: 'low',\n },\n};\n\n// ============================================================================\n// TEXT MANIPULATION\n// ============================================================================\n\n/**\n * Insert text at a position\n */\nexport const insertTextTool: McpToolDefinition = {\n name: 'docx_insert_text',\n description: `Insert text at a specific position in the document.\nPosition is specified by paragraph index (0-indexed) and character offset.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n position: positionSchema,\n text: {\n type: 'string',\n description: 'Text to insert',\n },\n },\n required: ['documentId', 'position', 'text'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, position, text } = input as {\n documentId: string;\n position: { paragraphIndex: number; offset: number };\n text: string;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'insertText',\n position,\n text,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n insertedLength: text.length,\n position,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to insert text: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n/**\n * Replace text in a range\n */\nexport const replaceTextTool: McpToolDefinition = {\n name: 'docx_replace_text',\n description: `Replace text in a range with new text.\nSpecify start and end positions to define the range to replace.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n range: rangeSchema,\n text: {\n type: 'string',\n description: 'Replacement text',\n },\n },\n required: ['documentId', 'range', 'text'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, range, text } = input as {\n documentId: string;\n range: {\n start: { paragraphIndex: number; offset: number };\n end: { paragraphIndex: number; offset: number };\n };\n text: string;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'replaceText',\n range,\n text,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n replacedRange: range,\n newTextLength: text.length,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to replace text: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n/**\n * Delete text in a range\n */\nexport const deleteTextTool: McpToolDefinition = {\n name: 'docx_delete_text',\n description: `Delete text in a range.\nSpecify start and end positions to define the range to delete.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n range: rangeSchema,\n },\n required: ['documentId', 'range'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, range } = input as {\n documentId: string;\n range: {\n start: { paragraphIndex: number; offset: number };\n end: { paragraphIndex: number; offset: number };\n };\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'deleteText',\n range,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n deletedRange: range,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to delete text: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n// ============================================================================\n// FORMATTING\n// ============================================================================\n\n/**\n * Apply text formatting\n */\nexport const formatTextTool: McpToolDefinition = {\n name: 'docx_format_text',\n description: `Apply formatting to text in a range.\nSupports bold, italic, underline, font size, font family, color, and highlight.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n range: rangeSchema,\n formatting: {\n type: 'object',\n description: 'Formatting options to apply',\n properties: {\n bold: { type: 'boolean' },\n italic: { type: 'boolean' },\n underline: { type: 'boolean' },\n strikethrough: { type: 'boolean' },\n fontSize: { type: 'number', description: 'Font size in points' },\n fontFamily: { type: 'string' },\n color: { type: 'string', description: 'Hex color (e.g., \"#FF0000\")' },\n highlight: { type: 'string', description: 'Highlight color name' },\n },\n },\n },\n required: ['documentId', 'range', 'formatting'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, range, formatting } = input as {\n documentId: string;\n range: {\n start: { paragraphIndex: number; offset: number };\n end: { paragraphIndex: number; offset: number };\n };\n formatting: Record<string, unknown>;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'formatText',\n range,\n formatting,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n range,\n appliedFormatting: formatting,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to format text: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'medium',\n },\n};\n\n/**\n * Apply paragraph style\n */\nexport const applyStyleTool: McpToolDefinition = {\n name: 'docx_apply_style',\n description: `Apply a named style to a paragraph.\nUse document styles like \"Heading1\", \"Heading2\", \"Normal\", etc.`,\n\n inputSchema: {\n type: 'object',\n properties: {\n documentId: documentIdSchema,\n paragraphIndex: {\n type: 'number',\n description: 'Index of the paragraph (0-indexed)',\n minimum: 0,\n },\n styleId: {\n type: 'string',\n description: 'Style ID (e.g., \"Heading1\", \"Normal\")',\n },\n },\n required: ['documentId', 'paragraphIndex', 'styleId'],\n },\n\n handler: async (input: unknown, context: McpToolContext): Promise<McpToolResult> => {\n const { documentId, paragraphIndex, styleId } = input as {\n documentId: string;\n paragraphIndex: number;\n styleId: string;\n };\n\n const loaded = context.session.documents.get(documentId);\n if (!loaded) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Document not found: ${documentId}` }],\n };\n }\n\n try {\n const newDoc = executeCommand(loaded.document, {\n type: 'applyStyle',\n paragraphIndex,\n styleId,\n });\n\n loaded.document = newDoc;\n loaded.lastModified = Date.now();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n success: true,\n paragraphIndex,\n styleId,\n }),\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [{ type: 'text', text: `Failed to apply style: ${(error as Error).message}` }],\n };\n }\n },\n\n annotations: {\n category: 'core',\n readOnly: false,\n complexity: 'low',\n },\n};\n\n// ============================================================================\n// HELPER FUNCTIONS\n// ============================================================================\n\nimport type { Paragraph, Run, Hyperlink } from '../types/document';\n\nfunction getParagraphText(paragraph: Paragraph): string {\n const texts: string[] = [];\n\n for (const item of paragraph.content) {\n if (item.type === 'run') {\n texts.push(getRunText(item));\n } else if (item.type === 'hyperlink') {\n texts.push(getHyperlinkText(item));\n }\n }\n\n return texts.join('');\n}\n\nfunction getRunText(run: Run): string {\n return run.content\n .filter((c) => c.type === 'text')\n .map((c) => (c as { type: 'text'; text: string }).text)\n .join('');\n}\n\nfunction getHyperlinkText(hyperlink: Hyperlink): string {\n const texts: string[] = [];\n for (const child of hyperlink.children) {\n if (child.type === 'run') {\n texts.push(getRunText(child));\n }\n }\n return texts.join('');\n}\n\n// ============================================================================\n// EXPORT ALL CORE TOOLS\n// ============================================================================\n\nexport const coreMcpTools: McpToolDefinition[] = [\n // Document loading/saving\n loadDocumentTool,\n saveDocumentTool,\n closeDocumentTool,\n\n // Document information\n getDocumentInfoTool,\n getDocumentTextTool,\n\n // Text manipulation\n insertTextTool,\n replaceTextTool,\n deleteTextTool,\n\n // Formatting\n formatTextTool,\n applyStyleTool,\n];\n","/**\n * MCP Server\n *\n * Model Context Protocol server that exposes document editing tools to AI clients.\n * Discovers and registers tools from the plugin system plus core built-in tools.\n *\n * @example\n * ```ts\n * import { createMcpServer, startStdioServer } from '@eigenpal/docx-editor/mcp';\n * import { pluginRegistry, docxtemplaterPlugin } from '@eigenpal/docx-editor/core-plugins';\n *\n * // Register plugins\n * pluginRegistry.register(docxtemplaterPlugin);\n *\n * // Start MCP server\n * startStdioServer();\n * ```\n */\n\nimport type {\n McpToolDefinition,\n McpToolContext,\n McpSession,\n LoadedDocument,\n JsonSchema,\n} from '../core-plugins/types';\nimport { pluginRegistry } from '../core-plugins/registry';\nimport { coreMcpTools } from './core-tools';\n\n// ============================================================================\n// TYPES\n// ============================================================================\n\n/**\n * MCP Server configuration\n */\nexport interface McpServerConfig {\n /** Server name */\n name?: string;\n\n /** Server version */\n version?: string;\n\n /** Include core tools (default: true) */\n includeCoreTools?: boolean;\n\n /** Enable debug logging */\n debug?: boolean;\n\n /** Custom tools to add */\n additionalTools?: McpToolDefinition[];\n}\n\n/**\n * MCP Server instance\n */\nexport interface McpServer {\n /** All registered tools */\n tools: Map<string, McpToolDefinition>;\n\n /** Active session */\n session: McpSession;\n\n /** Handle a tool call */\n handleToolCall(toolName: string, input: unknown): Promise<unknown>;\n\n /** List available tools */\n listTools(): McpToolInfo[];\n\n /** Get server info */\n getInfo(): { name: string; version: string; toolCount: number };\n}\n\n/**\n * Tool info for listing\n */\nexport interface McpToolInfo {\n name: string;\n description: string;\n inputSchema: JsonSchema;\n category?: string;\n}\n\n// ============================================================================\n// SERVER CREATION\n// ============================================================================\n\n/**\n * Create an MCP server instance\n *\n * @param config - Server configuration\n * @returns MCP server instance\n */\nexport function createMcpServer(config: McpServerConfig = {}): McpServer {\n const {\n name = 'docx-editor',\n version = '0.1.0',\n includeCoreTools = true,\n debug = false,\n additionalTools = [],\n } = config;\n\n const tools = new Map<string, McpToolDefinition>();\n\n // Create session\n const session: McpSession = {\n id: `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,\n documents: new Map<string, LoadedDocument>(),\n data: new Map<string, unknown>(),\n };\n\n // Register core tools\n if (includeCoreTools) {\n for (const tool of coreMcpTools) {\n tools.set(tool.name, tool);\n if (debug) {\n console.log(`[MCP] Registered core tool: ${tool.name}`);\n }\n }\n }\n\n // Register plugin tools\n const pluginTools = pluginRegistry.getMcpTools();\n for (const tool of pluginTools) {\n if (tools.has(tool.name)) {\n console.warn(`[MCP] Tool '${tool.name}' from plugin overrides existing tool`);\n }\n tools.set(tool.name, tool);\n if (debug) {\n console.log(`[MCP] Registered plugin tool: ${tool.name}`);\n }\n }\n\n // Register additional tools\n for (const tool of additionalTools) {\n tools.set(tool.name, tool);\n if (debug) {\n console.log(`[MCP] Registered additional tool: ${tool.name}`);\n }\n }\n\n // Create logger\n const log = debug\n ? (message: string, data?: unknown) => {\n console.log(`[MCP] ${message}`, data ?? '');\n }\n : () => {};\n\n // Handle tool call\n async function handleToolCall(toolName: string, input: unknown): Promise<unknown> {\n const tool = tools.get(toolName);\n if (!tool) {\n throw new Error(`Unknown tool: ${toolName}`);\n }\n\n log(`Calling tool: ${toolName}`, input);\n\n // Create context\n const context: McpToolContext = {\n session,\n log,\n };\n\n // Execute handler\n try {\n const result = await tool.handler(input, context);\n log(`Tool ${toolName} completed`, result);\n return result;\n } catch (error) {\n log(`Tool ${toolName} failed`, error);\n throw error;\n }\n }\n\n // List tools\n function listTools(): McpToolInfo[] {\n return Array.from(tools.values()).map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: convertToJsonSchema(tool.inputSchema),\n category: tool.annotations?.category,\n }));\n }\n\n // Get info\n function getInfo() {\n return {\n name,\n version,\n toolCount: tools.size,\n };\n }\n\n return {\n tools,\n session,\n handleToolCall,\n listTools,\n getInfo,\n };\n}\n\n// ============================================================================\n// JSON-RPC PROTOCOL\n// ============================================================================\n\n/**\n * JSON-RPC request\n */\ninterface JsonRpcRequest {\n jsonrpc: '2.0';\n id: string | number;\n method: string;\n params?: unknown;\n}\n\n/**\n * JSON-RPC response\n */\ninterface JsonRpcResponse {\n jsonrpc: '2.0';\n id: string | number;\n result?: unknown;\n error?: {\n code: number;\n message: string;\n data?: unknown;\n };\n}\n\n/**\n * Handle a JSON-RPC request\n */\nexport async function handleJsonRpcRequest(\n server: McpServer,\n request: JsonRpcRequest\n): Promise<JsonRpcResponse> {\n const { id, method, params } = request;\n\n try {\n switch (method) {\n case 'initialize': {\n return {\n jsonrpc: '2.0',\n id,\n result: {\n protocolVersion: '2024-11-05',\n capabilities: {\n tools: {},\n },\n serverInfo: server.getInfo(),\n },\n };\n }\n\n case 'tools/list': {\n const tools = server.listTools();\n return {\n jsonrpc: '2.0',\n id,\n result: {\n tools: tools.map((t) => ({\n name: t.name,\n description: t.description,\n inputSchema: t.inputSchema,\n })),\n },\n };\n }\n\n case 'tools/call': {\n const { name, arguments: args } = params as {\n name: string;\n arguments: unknown;\n };\n const result = await server.handleToolCall(name, args);\n return {\n jsonrpc: '2.0',\n id,\n result,\n };\n }\n\n default:\n return {\n jsonrpc: '2.0',\n id,\n error: {\n code: -32601,\n message: `Method not found: ${method}`,\n },\n };\n }\n } catch (error) {\n return {\n jsonrpc: '2.0',\n id,\n error: {\n code: -32000,\n message: (error as Error).message,\n },\n };\n }\n}\n\n// ============================================================================\n// STDIO TRANSPORT\n// ============================================================================\n\n/**\n * Start the MCP server with stdio transport\n *\n * Reads JSON-RPC requests from stdin, writes responses to stdout.\n * This is the standard way to run an MCP server for Claude Desktop.\n */\nexport async function startStdioServer(config: McpServerConfig = {}): Promise<void> {\n const server = createMcpServer(config);\n\n if (config.debug) {\n console.error(`[MCP] Server started: ${server.getInfo().name} v${server.getInfo().version}`);\n console.error(`[MCP] Tools registered: ${server.tools.size}`);\n }\n\n // Read from stdin\n const readline = await import('readline');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n });\n\n let buffer = '';\n\n rl.on('line', async (line) => {\n buffer += line;\n\n // Try to parse complete JSON\n try {\n const request = JSON.parse(buffer) as JsonRpcRequest;\n buffer = '';\n\n const response = await handleJsonRpcRequest(server, request);\n\n // Write response to stdout\n process.stdout.write(JSON.stringify(response) + '\\n');\n } catch {\n // Incomplete JSON, wait for more\n }\n });\n\n rl.on('close', () => {\n if (config.debug) {\n console.error('[MCP] Server closed');\n }\n process.exit(0);\n });\n}\n\n// ============================================================================\n// HELPER FUNCTIONS\n// ============================================================================\n\n/**\n * Convert schema to JSON Schema format\n */\nfunction convertToJsonSchema(schema: JsonSchema | unknown): JsonSchema {\n // If it's already a JSON Schema object, return it\n if (\n typeof schema === 'object' &&\n schema !== null &&\n ('type' in schema || 'properties' in schema)\n ) {\n return schema as JsonSchema;\n }\n\n // If it's a Zod-like schema, try to convert\n // For now, just return a basic object schema\n return {\n type: 'object',\n properties: {},\n };\n}\n\n// ============================================================================\n// EXPORTS\n// ============================================================================\n\nexport { coreMcpTools } from './core-tools';\n"]}
@@ -0,0 +1,2 @@
1
+ export{j as createTemplateProcessor,k as default,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,d as processTemplateAndDownload,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-CV5WFE7K.js';import'./chunk-Y6VCTLCJ.js';//# sourceMappingURL=processTemplate-G37IM66O.js.map
2
+ //# sourceMappingURL=processTemplate-G37IM66O.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"processTemplate-G37IM66O.js"}
@@ -0,0 +1,2 @@
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunk4QT5LPBA_cjs=require('./chunk-4QT5LPBA.cjs');require('./chunk-QEBO3EQP.cjs');Object.defineProperty(exports,"createTemplateProcessor",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.j}});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.k}});Object.defineProperty(exports,"getMissingVariables",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.g}});Object.defineProperty(exports,"getTemplateTags",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.e}});Object.defineProperty(exports,"previewTemplate",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.h}});Object.defineProperty(exports,"processTemplate",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.a}});Object.defineProperty(exports,"processTemplateAdvanced",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.i}});Object.defineProperty(exports,"processTemplateAndDownload",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.d}});Object.defineProperty(exports,"processTemplateAsBlob",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.c}});Object.defineProperty(exports,"processTemplateDetailed",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.b}});Object.defineProperty(exports,"validateTemplate",{enumerable:true,get:function(){return chunk4QT5LPBA_cjs.f}});//# sourceMappingURL=processTemplate-RFBGVH7T.cjs.map
2
+ //# sourceMappingURL=processTemplate-RFBGVH7T.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"processTemplate-RFBGVH7T.cjs"}