docsmith-mcp 0.0.1-beta.1 → 0.0.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +750 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.js +150 -103
- package/dist/index.js.map +1 -1
- package/package.json +24 -2
- package/python/pptx_handler.py +169 -0
- package/scripts/preload-packages.mjs +2 -0
- package/.github/workflows/test.yml +0 -35
- package/dist/python/excel_handler.py +0 -97
- package/dist/python/pdf_handler.py +0 -81
- package/dist/python/text_handler.py +0 -331
- package/dist/python/word_handler.py +0 -98
- package/examples/sample_data.csv +0 -6
- package/examples/sample_data.json +0 -9
- package/examples/sample_document.pdf +0 -80
- package/examples/sample_report.docx +0 -0
- package/examples/sample_sales_data.xlsx +0 -0
- package/examples/sample_text.txt +0 -10
- package/src/code-runner.ts +0 -136
- package/src/index.ts +0 -496
- package/src/utils.ts +0 -45
- package/tests/document-processing.test.ts +0 -230
- package/tsconfig.json +0 -20
- package/tsdown.config.ts +0 -21
- package/vitest.config.ts +0 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["__filename","__dirname","filePath: string","scriptPath: string","options: RunPythonFileOptions","runPyOptions: RunPyOptions","filePath: string","fileType: string","packages: Record<string, Record<string, string>>","Server","ListToolsRequestSchema","CallToolRequestSchema","scriptName: string","scriptArgs: string[]","StdioServerTransport"],"sources":["../src/code-runner.ts","../src/utils.ts","../src/index.ts"],"sourcesContent":["/**\n * Code runner client - uses @mcpc-tech/code-runner-mcp npm package\n */\nimport { runPy, type RunPyOptions } from \"@mcpc-tech/code-runner-mcp\";\nimport { readFileSync } from \"fs\";\nimport { fileURLToPath } from \"url\";\nimport { dirname, join, resolve } from \"path\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Options for running Python script files\n */\nexport interface RunPythonFileOptions {\n /** Command line arguments to pass to the script */\n args?: string[];\n /** Package name mappings (import_name -> pypi_name) */\n packages?: Record<string, string>;\n /** Base directory for the script (default: \"python\") */\n baseDir?: string;\n /** User file paths that need to be accessible (for file system mounting) */\n filePaths?: string[];\n}\n\n/**\n * Convert absolute file path to Pyodide virtual path\n * Determines the mount root and converts the path accordingly\n *\n * @param filePath - Absolute path to the file\n * @returns Object with mountRoot (host path) and virtualPath (Pyodide path)\n */\nfunction getFileSystemMapping(\n filePath: string,\n): { mountRoot: string; virtualPath: string } {\n const absolutePath = resolve(filePath);\n\n // Mount the parent directory of the file\n // This allows Python to access the file and its siblings\n const mountRoot = dirname(absolutePath);\n const virtualPath = absolutePath;\n\n return { mountRoot, virtualPath };\n}\n\n/**\n * Run a Python script file using code-runner-mcp\n *\n * @param scriptPath - Path to the Python script (relative to baseDir)\n * @param options - Execution options\n * @returns The execution result\n */\nexport async function runPythonFile(\n scriptPath: string,\n options: RunPythonFileOptions = {},\n): Promise<any> {\n const {\n args = [],\n packages = {},\n baseDir = \"python\",\n filePaths = [],\n } = options;\n\n // Read the Python script\n // Python files are in the python/ directory at project root\n // From dist/index.js, go up one level to reach python/\n const fullPath = join(__dirname, \"..\", baseDir, scriptPath);\n const scriptContent = readFileSync(fullPath, \"utf-8\");\n\n // Build wrapper code that sets sys.argv and executes the script\n const wrapperCode = `\nimport sys\nimport json\n\n# Set command line arguments\nsys.argv = ['${scriptPath}'] + ${JSON.stringify(args)}\n\n# Execute the script\n${scriptContent}\n`;\n\n // Determine mount root from the first file path\n // Default: parent directory of dist/ (project root when running from dist/index.js)\n let mountRoot = join(__dirname, \"..\");\n if (filePaths.length > 0) {\n const mapping = getFileSystemMapping(filePaths[0]);\n mountRoot = mapping.mountRoot;\n }\n\n // Execute via runPy with options\n // Mount point is the same as the mount root (Pyodide will see host paths directly)\n const runPyOptions: RunPyOptions = {\n packages,\n nodeFSMountPoint: mountRoot,\n nodeFSRoot: mountRoot,\n };\n const stream = await runPy(wrapperCode, runPyOptions);\n\n // Read the stream output\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n let stdout = \"\";\n let stderr = \"\";\n let error = \"\";\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value, { stream: true });\n if (chunk.startsWith(\"[stderr] \")) {\n stderr += chunk.slice(9);\n } else if (chunk.startsWith(\"[err]\")) {\n error += chunk;\n } else {\n stdout += chunk;\n }\n }\n } catch (streamError) {\n // Stream error means Python execution failed\n return { error: String(streamError) };\n }\n\n // Check for errors\n if (error) {\n return { error: error.replace(/\\[err\\]\\[py\\]\\s*/g, \"\").trim() };\n }\n\n // Parse the JSON output from the script (last line)\n const lines = stdout.trim().split(\"\\n\");\n const lastLine = lines[lines.length - 1];\n\n try {\n return JSON.parse(lastLine);\n } catch {\n return { stdout, stderr };\n }\n}\n","/**\n * Utility functions for document processing\n */\n\n/**\n * Detect file type from file extension\n */\nexport function detectFileType(\n filePath: string,\n): \"excel\" | \"word\" | \"pdf\" | \"pptx\" | \"text\" | null {\n const ext = filePath.toLowerCase().split(\".\").pop();\n if (ext === \"xlsx\" || ext === \"xls\") return \"excel\";\n if (ext === \"docx\") return \"word\";\n if (ext === \"pptx\" || ext === \"ppt\") return \"pptx\";\n if (ext === \"pdf\") return \"pdf\";\n if (\n ext === \"txt\" || ext === \"csv\" || ext === \"md\" || ext === \"json\" ||\n ext === \"yaml\" || ext === \"yml\"\n ) return \"text\";\n return null;\n}\n\n/**\n * Get required packages for each file type\n */\nexport function getPackages(fileType: string): Record<string, string> {\n const packages: Record<string, Record<string, string>> = {\n excel: { openpyxl: \"openpyxl\" },\n word: { docx: \"python-docx\" }, // Map docx import to python-docx package\n pptx: { pptx: \"python-pptx\" }, // Map pptx import to python-pptx package\n pdf: { PyPDF2: \"PyPDF2\" },\n text: {}, // No external packages needed for text files\n };\n return packages[fileType] || {};\n}\n\n/**\n * Get environment configuration\n */\nexport function getConfig() {\n return {\n rawFullRead: process.env.DOC_RAW_FULL_READ === \"true\",\n pageSize: parseInt(process.env.DOC_PAGE_SIZE || \"100\", 10),\n maxFileSize: parseInt(process.env.DOC_MAX_FILE_SIZE || \"50\", 10) * 1024 *\n 1024,\n };\n}\n","#!/usr/bin/env node\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\nimport { runPythonFile } from \"./code-runner.js\";\nimport { detectFileType, getConfig, getPackages } from \"./utils.js\";\n\n// Tool schemas\nconst ReadDocumentSchema = z.object({\n file_path: z.string().describe(\"Absolute path to the document file\"),\n file_type: z.enum([\"excel\", \"word\", \"pptx\", \"pdf\", \"text\"]).optional()\n .describe(\n \"Override file type detection. Use this to explicitly specify the format instead of relying on file extension\",\n ),\n mode: z.enum([\"raw\", \"paginated\"]).optional().describe(\n \"Read mode: 'raw' for full content, 'paginated' for chunked reading\",\n ),\n page: z.number().optional().describe(\n \"Page number for paginated mode (1-based)\",\n ),\n page_size: z.number().optional().describe(\n \"Items per page for paginated mode\",\n ),\n sheet_name: z.string().optional().describe(\"Sheet name for Excel files\"),\n});\n\nconst WriteDocumentSchema = z.object({\n file_path: z.string().describe(\"Absolute path to save the document\"),\n format: z.enum([\"excel\", \"word\", \"pptx\", \"text\"]).describe(\n \"Document format\",\n ),\n data: z.any().describe(\"Document data structure\"),\n});\n\nconst GetDocumentInfoSchema = z.object({\n file_path: z.string().describe(\"Absolute path to the document file\"),\n file_type: z.enum([\"excel\", \"word\", \"pptx\", \"pdf\", \"text\"]).optional()\n .describe(\n \"Override file type detection. Use this to explicitly specify the format instead of relying on file extension\",\n ),\n});\n\n// Server setup\nconst server = new Server(\n {\n name: \"docsmith-mcp\",\n version: \"0.1.0\",\n },\n {\n capabilities: {\n tools: {},\n },\n },\n);\n\n// Output schemas (reusable)\nconst BaseOutputSchema = {\n type: \"object\",\n properties: {\n success: { type: \"boolean\", description: \"Operation success status\" },\n error: { type: \"string\", description: \"Error message if failed\" },\n },\n} as const;\n\nconst PaginationSchema = {\n current_page: { type: \"number\", description: \"Current page number\" },\n page_size: { type: \"number\", description: \"Items per page\" },\n total_pages: { type: \"number\", description: \"Total number of pages\" },\n page: { type: \"number\", description: \"Current page number (alternative)\" },\n has_more: { type: \"boolean\", description: \"Whether more pages exist\" },\n} as const;\n\nconst ExcelReadOutputSchema = {\n type: \"object\",\n properties: {\n sheet_name: { type: \"string\", description: \"Active sheet name\" },\n sheets: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"All sheet names\",\n },\n total_rows: { type: \"number\", description: \"Total rows in sheet\" },\n total_cols: { type: \"number\", description: \"Total columns in sheet\" },\n data: {\n type: \"array\",\n items: { type: \"array\", items: {} },\n description: \"Sheet data as array of rows\",\n },\n ...PaginationSchema,\n },\n} as const;\n\nconst WordReadOutputSchema = {\n type: \"object\",\n properties: {\n paragraphs: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Document paragraphs\",\n },\n tables: {\n type: \"array\",\n items: {\n type: \"array\",\n items: { type: \"array\", items: { type: \"string\" } },\n },\n description: \"Tables data\",\n },\n total_paragraphs: { type: \"number\", description: \"Total paragraph count\" },\n total_tables: { type: \"number\", description: \"Total table count\" },\n ...PaginationSchema,\n },\n} as const;\n\nconst PDFReadOutputSchema = {\n type: \"object\",\n properties: {\n total_pages: { type: \"number\", description: \"Total pages in PDF\" },\n content: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n page_number: { type: \"number\" },\n text: { type: \"string\" },\n },\n },\n description: \"Page content array\",\n },\n current_page_group: { type: \"number\" },\n page_size: { type: \"number\" },\n },\n} as const;\n\nconst TextReadOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n content: { type: \"string\", description: \"Text content\" },\n total_lines: { type: \"number\", description: \"Total line count\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n ...PaginationSchema,\n },\n} as const;\n\nconst CSVReadOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n headers: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"CSV headers\",\n },\n data: {\n type: \"array\",\n items: { type: \"object\" },\n description: \"Structured data as array of objects\",\n },\n total_rows: { type: \"number\", description: \"Total data rows\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n ...PaginationSchema,\n },\n} as const;\n\nconst JSONReadOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n data: { type: \"object\", description: \"Parsed JSON data\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n },\n} as const;\n\nconst WriteOutputSchema = {\n type: \"object\",\n properties: {\n success: { type: \"boolean\", description: \"Write operation success\" },\n file_path: { type: \"string\", description: \"Written file path\" },\n message: { type: \"string\", description: \"Success message\" },\n error: { type: \"string\", description: \"Error message if failed\" },\n },\n} as const;\n\nconst ExcelInfoOutputSchema = {\n type: \"object\",\n properties: {\n sheets: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n rows: { type: \"number\" },\n cols: { type: \"number\" },\n },\n },\n description: \"Sheet information\",\n },\n file_size: { type: \"number\", description: \"File size in bytes\" },\n },\n} as const;\n\nconst WordInfoOutputSchema = {\n type: \"object\",\n properties: {\n paragraphs: { type: \"number\", description: \"Paragraph count\" },\n tables: { type: \"number\", description: \"Table count\" },\n file_size: { type: \"number\", description: \"File size in bytes\" },\n },\n} as const;\n\nconst PDFInfoOutputSchema = {\n type: \"object\",\n properties: {\n pages: { type: \"number\", description: \"Page count\" },\n file_size: { type: \"number\", description: \"File size in bytes\" },\n total_words: { type: \"number\", description: \"Total word count\" },\n },\n} as const;\n\nconst TextInfoOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n file_size: { type: \"number\", description: \"File size in bytes\" },\n line_count: { type: \"number\", description: \"Line count\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n file_type: { type: \"string\", description: \"File extension\" },\n // CSV specific\n headers: { type: \"array\", items: { type: \"string\" } },\n total_rows: { type: \"number\" },\n total_cols: { type: \"number\" },\n // JSON specific\n item_count: { type: \"number\" },\n key_count: { type: \"number\" },\n },\n} as const;\n\n// List available tools\nserver.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: \"read_document\",\n description:\n \"Read document content (Excel, Word, PowerPoint, PDF, TXT, CSV, Markdown, JSON, YAML). Supports raw full read or paginated mode.\",\n inputSchema: {\n type: \"object\",\n properties: {\n file_path: {\n type: \"string\",\n description: \"Absolute path to the document file\",\n },\n file_type: {\n type: \"string\",\n enum: [\"excel\", \"word\", \"pptx\", \"pdf\", \"text\"],\n description:\n \"Override file type detection (optional). Specify format explicitly instead of relying on extension\",\n },\n mode: {\n type: \"string\",\n enum: [\"raw\", \"paginated\"],\n description: \"Read mode\",\n },\n page: {\n type: \"number\",\n description: \"Page number for paginated mode\",\n },\n page_size: { type: \"number\", description: \"Items per page\" },\n sheet_name: {\n type: \"string\",\n description: \"Sheet name for Excel files\",\n },\n },\n required: [\"file_path\"],\n },\n outputSchema: {\n type: \"object\",\n description:\n \"Document content with format-specific structure. Common fields: success (boolean), error (string, on failure).\",\n properties: {\n // Common fields\n success: { type: \"boolean\" },\n error: { type: \"string\" },\n encoding: { type: \"string\" },\n\n // Excel-specific\n sheet_name: { type: \"string\" },\n sheets: { type: \"array\", items: { type: \"string\" } },\n total_rows: { type: \"number\" },\n total_cols: { type: \"number\" },\n current_page: { type: [\"number\", \"null\"] },\n total_pages: { type: \"number\" },\n\n // Word-specific\n paragraphs: { type: \"array\" },\n tables: { type: \"array\" },\n total_paragraphs: { type: \"number\" },\n total_tables: { type: \"number\" },\n\n // PowerPoint-specific\n total_slides: { type: \"number\" },\n slides: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n slide_number: { type: \"number\" },\n title: { type: \"string\" },\n content: { type: \"array\" },\n notes: { type: \"string\" },\n },\n },\n },\n\n // PDF-specific\n current_page_group: { type: [\"number\", \"null\"] },\n total_page_groups: { type: \"number\" },\n content: {}, // PDF: array of {page_number, text, words}, Text: string\n\n // Text/CSV-specific\n total_lines: { type: \"number\" },\n headers: { type: \"array\", items: { type: \"string\" } },\n\n // Data field (varies by format)\n data: {}, // Excel: array of arrays, CSV: array of objects, JSON: any\n\n // Pagination\n page: { type: \"number\" },\n page_size: { type: [\"number\", \"null\"] },\n has_more: { type: \"boolean\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"write_document\",\n description: \"Write document content (Excel, Word, PowerPoint, Text)\",\n inputSchema: {\n type: \"object\",\n properties: {\n file_path: {\n type: \"string\",\n description: \"Absolute path to save the document\",\n },\n format: {\n type: \"string\",\n enum: [\"excel\", \"word\", \"pptx\", \"text\"],\n description: \"Document format\",\n },\n data: {\n description:\n \"Document data structure. Excel: array of rows [[cell1, cell2], ...]. Word: {paragraphs: string[], tables?: [[[cell]]]}. Text/CSV/JSON: string or object\",\n },\n },\n required: [\"file_path\", \"format\", \"data\"],\n },\n outputSchema: WriteOutputSchema,\n },\n {\n name: \"get_document_info\",\n description:\n \"Get document metadata (page count, sheet count, slide count, file size, etc.)\",\n inputSchema: {\n type: \"object\",\n properties: {\n file_path: {\n type: \"string\",\n description: \"Absolute path to the document file\",\n },\n file_type: {\n type: \"string\",\n enum: [\"excel\", \"word\", \"pptx\", \"pdf\", \"text\"],\n description:\n \"Override file type detection (optional). Specify format explicitly instead of relying on extension\",\n },\n },\n required: [\"file_path\"],\n },\n outputSchema: {\n type: \"object\",\n description: \"Document metadata with format-specific fields\",\n properties: {\n success: { type: \"boolean\" },\n error: { type: \"string\" },\n file_size: { type: \"number\" },\n\n // Excel-specific\n sheets: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n rows: { type: \"number\" },\n cols: { type: \"number\" },\n },\n },\n },\n\n // Word-specific\n paragraphs: { type: \"number\" },\n tables: { type: \"number\" },\n\n // PowerPoint-specific\n slides: { type: \"number\" },\n\n // PDF-specific\n pages: { type: \"number\" },\n total_words: { type: \"number\" },\n metadata: { type: \"object\" },\n\n // Text/CSV/JSON-specific\n line_count: { type: \"number\" },\n encoding: { type: \"string\" },\n file_type: { type: \"string\" },\n headers: { type: \"array\", items: { type: \"string\" } },\n total_rows: { type: \"number\" },\n total_cols: { type: \"number\" },\n item_count: { type: \"number\" },\n key_count: { type: \"number\" },\n },\n additionalProperties: false,\n },\n },\n ],\n };\n});\n\n// Handle tool calls\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n if (name === \"read_document\") {\n const params = ReadDocumentSchema.parse(args);\n // Use explicit file_type if provided, otherwise detect from extension\n const fileType = params.file_type || detectFileType(params.file_path);\n\n if (!fileType) {\n throw new Error(`Unsupported file type: ${params.file_path}`);\n }\n\n // Determine read mode\n const config = getConfig();\n const mode = params.mode || (config.rawFullRead ? \"raw\" : \"paginated\");\n const page = mode === \"paginated\" ? (params.page || 1) : undefined;\n const pageSize = params.page_size || config.pageSize;\n\n let scriptName: string;\n let scriptArgs: string[];\n\n if (fileType === \"excel\") {\n scriptName = \"excel_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (params.sheet_name) scriptArgs.push(params.sheet_name);\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n } else if (fileType === \"word\") {\n scriptName = \"word_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n } else if (fileType === \"pptx\") {\n scriptName = \"pptx_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n } else if (fileType === \"pdf\") {\n scriptName = \"pdf_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(Math.min(pageSize, 10))); // PDF pages are larger\n }\n } else {\n // text files\n scriptName = \"text_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n }\n\n const result = await runPythonFile(scriptName, {\n args: scriptArgs,\n packages: getPackages(fileType),\n filePaths: [params.file_path],\n });\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n }],\n structuredContent: result,\n };\n }\n\n if (name === \"write_document\") {\n const params = WriteDocumentSchema.parse(args);\n\n let scriptName: string;\n let scriptArgs: string[];\n\n if (params.format === \"excel\") {\n scriptName = \"excel_handler.py\";\n scriptArgs = [\"write\", params.file_path, JSON.stringify(params.data)];\n } else if (params.format === \"word\") {\n scriptName = \"word_handler.py\";\n const paragraphs = params.data.paragraphs || [];\n const tables = params.data.tables || null;\n scriptArgs = [\"write\", params.file_path, JSON.stringify(paragraphs)];\n if (tables) scriptArgs.push(JSON.stringify(tables));\n } else if (params.format === \"pptx\") {\n scriptName = \"pptx_handler.py\";\n const slides = params.data.slides || params.data || [];\n scriptArgs = [\"write\", params.file_path, JSON.stringify(slides)];\n } else if (params.format === \"text\") {\n scriptName = \"text_handler.py\";\n const content = typeof params.data === \"string\"\n ? params.data\n : JSON.stringify(params.data);\n scriptArgs = [\"write\", params.file_path, content];\n } else {\n throw new Error(`Unsupported write format: ${params.format}`);\n }\n\n const result = await runPythonFile(scriptName, {\n args: scriptArgs,\n packages: getPackages(params.format),\n filePaths: [params.file_path],\n });\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n }],\n structuredContent: result,\n };\n }\n\n if (name === \"get_document_info\") {\n const params = GetDocumentInfoSchema.parse(args);\n // Use explicit file_type if provided, otherwise detect from extension\n const fileType = params.file_type || detectFileType(params.file_path);\n\n if (!fileType) {\n throw new Error(`Unsupported file type: ${params.file_path}`);\n }\n\n let scriptName: string;\n let scriptArgs = [\"info\", params.file_path];\n\n if (fileType === \"excel\") {\n scriptName = \"excel_handler.py\";\n } else if (fileType === \"word\") {\n scriptName = \"word_handler.py\";\n } else if (fileType === \"pptx\") {\n scriptName = \"pptx_handler.py\";\n } else if (fileType === \"pdf\") {\n scriptName = \"pdf_handler.py\";\n } else {\n scriptName = \"text_handler.py\";\n }\n\n const result = await runPythonFile(scriptName, {\n args: scriptArgs,\n packages: getPackages(fileType),\n filePaths: [params.file_path],\n });\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n }],\n structuredContent: result,\n };\n }\n\n throw new Error(`Unknown tool: ${name}`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\", text: `Error: ${errorMessage}` }],\n isError: true,\n };\n }\n});\n\n// Start server\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error(\"Docsmith MCP server running on stdio\");\n}\n\nmain().catch((error) => {\n console.error(\"Server error:\", error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAMA,eAAa,qEAA8B;AACjD,MAAMC,cAAY,kBAAQD,aAAW;;;;;;;;AAuBrC,SAAS,qBACPE,UAC4C;CAC5C,MAAM,eAAe,kBAAQ,SAAS;CAItC,MAAM,YAAY,kBAAQ,aAAa;CACvC,MAAM,cAAc;AAEpB,QAAO;EAAE;EAAW;CAAa;AAClC;;;;;;;;AASD,eAAsB,cACpBC,YACAC,UAAgC,CAAE,GACpB;CACd,MAAM,EACJ,OAAO,CAAE,GACT,WAAW,CAAE,GACb,UAAU,UACV,YAAY,CAAE,GACf,GAAG;CAKJ,MAAM,WAAW,eAAKH,aAAW,MAAM,SAAS,WAAW;CAC3D,MAAM,gBAAgB,qBAAa,UAAU,QAAQ;CAGrD,MAAM,eAAe;;;;;eAKR,WAAW,OAAO,KAAK,UAAU,KAAK,CAAC;;;EAGpD,cAAc;;CAKd,IAAI,YAAY,eAAKA,aAAW,KAAK;AACrC,KAAI,UAAU,SAAS,GAAG;EACxB,MAAM,UAAU,q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AAM,EAAE;IACtC,CAAC;IACF,mBAAmB;GACpB;EACF;AAED,QAAM,IAAI,OAAO,gBAAgB,KAAK;CACvC,SAAQ,OAAO;EACd,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAC3E,SAAO;GACL,SAAS,CAAC;IAAE,MAAM;IAAQ,OAAO,SAAS,aAAa;GAAG,CAAC;GAC3D,SAAS;EACV;CACF;AACF,EAAC;AAGF,eAAe,OAAO;CACpB,MAAM,YAAY,IAAIE;AACtB,OAAM,OAAO,QAAQ,UAAU;AAC/B,SAAQ,MAAM,uCAAuC;AACtD;AAED,MAAM,CAAC,MAAM,CAAC,UAAU;AACtB,SAAQ,MAAM,iBAAiB,MAAM;AACrC,SAAQ,KAAK,EAAE;AAChB,EAAC"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.js
CHANGED
|
@@ -101,6 +101,7 @@ function detectFileType(filePath) {
|
|
|
101
101
|
const ext = filePath.toLowerCase().split(".").pop();
|
|
102
102
|
if (ext === "xlsx" || ext === "xls") return "excel";
|
|
103
103
|
if (ext === "docx") return "word";
|
|
104
|
+
if (ext === "pptx" || ext === "ppt") return "pptx";
|
|
104
105
|
if (ext === "pdf") return "pdf";
|
|
105
106
|
if (ext === "txt" || ext === "csv" || ext === "md" || ext === "json" || ext === "yaml" || ext === "yml") return "text";
|
|
106
107
|
return null;
|
|
@@ -112,6 +113,7 @@ function getPackages(fileType) {
|
|
|
112
113
|
const packages = {
|
|
113
114
|
excel: { openpyxl: "openpyxl" },
|
|
114
115
|
word: { docx: "python-docx" },
|
|
116
|
+
pptx: { pptx: "python-pptx" },
|
|
115
117
|
pdf: { PyPDF2: "PyPDF2" },
|
|
116
118
|
text: {}
|
|
117
119
|
};
|
|
@@ -132,6 +134,13 @@ function getConfig() {
|
|
|
132
134
|
//#region src/index.ts
|
|
133
135
|
const ReadDocumentSchema = z.object({
|
|
134
136
|
file_path: z.string().describe("Absolute path to the document file"),
|
|
137
|
+
file_type: z.enum([
|
|
138
|
+
"excel",
|
|
139
|
+
"word",
|
|
140
|
+
"pptx",
|
|
141
|
+
"pdf",
|
|
142
|
+
"text"
|
|
143
|
+
]).optional().describe("Override file type detection. Use this to explicitly specify the format instead of relying on file extension"),
|
|
135
144
|
mode: z.enum(["raw", "paginated"]).optional().describe("Read mode: 'raw' for full content, 'paginated' for chunked reading"),
|
|
136
145
|
page: z.number().optional().describe("Page number for paginated mode (1-based)"),
|
|
137
146
|
page_size: z.number().optional().describe("Items per page for paginated mode"),
|
|
@@ -142,11 +151,21 @@ const WriteDocumentSchema = z.object({
|
|
|
142
151
|
format: z.enum([
|
|
143
152
|
"excel",
|
|
144
153
|
"word",
|
|
154
|
+
"pptx",
|
|
145
155
|
"text"
|
|
146
156
|
]).describe("Document format"),
|
|
147
157
|
data: z.any().describe("Document data structure")
|
|
148
158
|
});
|
|
149
|
-
const GetDocumentInfoSchema = z.object({
|
|
159
|
+
const GetDocumentInfoSchema = z.object({
|
|
160
|
+
file_path: z.string().describe("Absolute path to the document file"),
|
|
161
|
+
file_type: z.enum([
|
|
162
|
+
"excel",
|
|
163
|
+
"word",
|
|
164
|
+
"pptx",
|
|
165
|
+
"pdf",
|
|
166
|
+
"text"
|
|
167
|
+
]).optional().describe("Override file type detection. Use this to explicitly specify the format instead of relying on file extension")
|
|
168
|
+
});
|
|
150
169
|
const server = new Server({
|
|
151
170
|
name: "docsmith-mcp",
|
|
152
171
|
version: "0.1.0"
|
|
@@ -247,28 +266,6 @@ const WordReadOutputSchema = {
|
|
|
247
266
|
...PaginationSchema
|
|
248
267
|
}
|
|
249
268
|
};
|
|
250
|
-
const PDFReadOutputSchema = {
|
|
251
|
-
type: "object",
|
|
252
|
-
properties: {
|
|
253
|
-
total_pages: {
|
|
254
|
-
type: "number",
|
|
255
|
-
description: "Total pages in PDF"
|
|
256
|
-
},
|
|
257
|
-
content: {
|
|
258
|
-
type: "array",
|
|
259
|
-
items: {
|
|
260
|
-
type: "object",
|
|
261
|
-
properties: {
|
|
262
|
-
page_number: { type: "number" },
|
|
263
|
-
text: { type: "string" }
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
description: "Page content array"
|
|
267
|
-
},
|
|
268
|
-
current_page_group: { type: "number" },
|
|
269
|
-
page_size: { type: "number" }
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
269
|
const TextReadOutputSchema = {
|
|
273
270
|
type: "object",
|
|
274
271
|
properties: {
|
|
@@ -348,61 +345,6 @@ const WriteOutputSchema = {
|
|
|
348
345
|
}
|
|
349
346
|
}
|
|
350
347
|
};
|
|
351
|
-
const ExcelInfoOutputSchema = {
|
|
352
|
-
type: "object",
|
|
353
|
-
properties: {
|
|
354
|
-
sheets: {
|
|
355
|
-
type: "array",
|
|
356
|
-
items: {
|
|
357
|
-
type: "object",
|
|
358
|
-
properties: {
|
|
359
|
-
name: { type: "string" },
|
|
360
|
-
rows: { type: "number" },
|
|
361
|
-
cols: { type: "number" }
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
description: "Sheet information"
|
|
365
|
-
},
|
|
366
|
-
file_size: {
|
|
367
|
-
type: "number",
|
|
368
|
-
description: "File size in bytes"
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
const WordInfoOutputSchema = {
|
|
373
|
-
type: "object",
|
|
374
|
-
properties: {
|
|
375
|
-
paragraphs: {
|
|
376
|
-
type: "number",
|
|
377
|
-
description: "Paragraph count"
|
|
378
|
-
},
|
|
379
|
-
tables: {
|
|
380
|
-
type: "number",
|
|
381
|
-
description: "Table count"
|
|
382
|
-
},
|
|
383
|
-
file_size: {
|
|
384
|
-
type: "number",
|
|
385
|
-
description: "File size in bytes"
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
const PDFInfoOutputSchema = {
|
|
390
|
-
type: "object",
|
|
391
|
-
properties: {
|
|
392
|
-
pages: {
|
|
393
|
-
type: "number",
|
|
394
|
-
description: "Page count"
|
|
395
|
-
},
|
|
396
|
-
file_size: {
|
|
397
|
-
type: "number",
|
|
398
|
-
description: "File size in bytes"
|
|
399
|
-
},
|
|
400
|
-
total_words: {
|
|
401
|
-
type: "number",
|
|
402
|
-
description: "Total word count"
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
348
|
const TextInfoOutputSchema = {
|
|
407
349
|
type: "object",
|
|
408
350
|
properties: {
|
|
@@ -437,7 +379,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
437
379
|
return { tools: [
|
|
438
380
|
{
|
|
439
381
|
name: "read_document",
|
|
440
|
-
description: "Read document content (Excel, Word, PDF, TXT, CSV, Markdown, JSON, YAML). Supports raw full read or paginated mode.",
|
|
382
|
+
description: "Read document content (Excel, Word, PowerPoint, PDF, TXT, CSV, Markdown, JSON, YAML). Supports raw full read or paginated mode.",
|
|
441
383
|
inputSchema: {
|
|
442
384
|
type: "object",
|
|
443
385
|
properties: {
|
|
@@ -445,6 +387,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
445
387
|
type: "string",
|
|
446
388
|
description: "Absolute path to the document file"
|
|
447
389
|
},
|
|
390
|
+
file_type: {
|
|
391
|
+
type: "string",
|
|
392
|
+
enum: [
|
|
393
|
+
"excel",
|
|
394
|
+
"word",
|
|
395
|
+
"pptx",
|
|
396
|
+
"pdf",
|
|
397
|
+
"text"
|
|
398
|
+
],
|
|
399
|
+
description: "Override file type detection (optional). Specify format explicitly instead of relying on extension"
|
|
400
|
+
},
|
|
448
401
|
mode: {
|
|
449
402
|
type: "string",
|
|
450
403
|
enum: ["raw", "paginated"],
|
|
@@ -467,20 +420,56 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
467
420
|
},
|
|
468
421
|
outputSchema: {
|
|
469
422
|
type: "object",
|
|
470
|
-
description: "
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
423
|
+
description: "Document content with format-specific structure. Common fields: success (boolean), error (string, on failure).",
|
|
424
|
+
properties: {
|
|
425
|
+
success: { type: "boolean" },
|
|
426
|
+
error: { type: "string" },
|
|
427
|
+
encoding: { type: "string" },
|
|
428
|
+
sheet_name: { type: "string" },
|
|
429
|
+
sheets: {
|
|
430
|
+
type: "array",
|
|
431
|
+
items: { type: "string" }
|
|
432
|
+
},
|
|
433
|
+
total_rows: { type: "number" },
|
|
434
|
+
total_cols: { type: "number" },
|
|
435
|
+
current_page: { type: ["number", "null"] },
|
|
436
|
+
total_pages: { type: "number" },
|
|
437
|
+
paragraphs: { type: "array" },
|
|
438
|
+
tables: { type: "array" },
|
|
439
|
+
total_paragraphs: { type: "number" },
|
|
440
|
+
total_tables: { type: "number" },
|
|
441
|
+
total_slides: { type: "number" },
|
|
442
|
+
slides: {
|
|
443
|
+
type: "array",
|
|
444
|
+
items: {
|
|
445
|
+
type: "object",
|
|
446
|
+
properties: {
|
|
447
|
+
slide_number: { type: "number" },
|
|
448
|
+
title: { type: "string" },
|
|
449
|
+
content: { type: "array" },
|
|
450
|
+
notes: { type: "string" }
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
current_page_group: { type: ["number", "null"] },
|
|
455
|
+
total_page_groups: { type: "number" },
|
|
456
|
+
content: {},
|
|
457
|
+
total_lines: { type: "number" },
|
|
458
|
+
headers: {
|
|
459
|
+
type: "array",
|
|
460
|
+
items: { type: "string" }
|
|
461
|
+
},
|
|
462
|
+
data: {},
|
|
463
|
+
page: { type: "number" },
|
|
464
|
+
page_size: { type: ["number", "null"] },
|
|
465
|
+
has_more: { type: "boolean" }
|
|
466
|
+
},
|
|
467
|
+
additionalProperties: false
|
|
479
468
|
}
|
|
480
469
|
},
|
|
481
470
|
{
|
|
482
471
|
name: "write_document",
|
|
483
|
-
description: "Write document content (Excel, Word, Text)",
|
|
472
|
+
description: "Write document content (Excel, Word, PowerPoint, Text)",
|
|
484
473
|
inputSchema: {
|
|
485
474
|
type: "object",
|
|
486
475
|
properties: {
|
|
@@ -493,6 +482,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
493
482
|
enum: [
|
|
494
483
|
"excel",
|
|
495
484
|
"word",
|
|
485
|
+
"pptx",
|
|
496
486
|
"text"
|
|
497
487
|
],
|
|
498
488
|
description: "Document format"
|
|
@@ -509,24 +499,65 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
509
499
|
},
|
|
510
500
|
{
|
|
511
501
|
name: "get_document_info",
|
|
512
|
-
description: "Get document metadata (page count, sheet count, file size, etc.)",
|
|
502
|
+
description: "Get document metadata (page count, sheet count, slide count, file size, etc.)",
|
|
513
503
|
inputSchema: {
|
|
514
504
|
type: "object",
|
|
515
|
-
properties: {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
505
|
+
properties: {
|
|
506
|
+
file_path: {
|
|
507
|
+
type: "string",
|
|
508
|
+
description: "Absolute path to the document file"
|
|
509
|
+
},
|
|
510
|
+
file_type: {
|
|
511
|
+
type: "string",
|
|
512
|
+
enum: [
|
|
513
|
+
"excel",
|
|
514
|
+
"word",
|
|
515
|
+
"pptx",
|
|
516
|
+
"pdf",
|
|
517
|
+
"text"
|
|
518
|
+
],
|
|
519
|
+
description: "Override file type detection (optional). Specify format explicitly instead of relying on extension"
|
|
520
|
+
}
|
|
521
|
+
},
|
|
519
522
|
required: ["file_path"]
|
|
520
523
|
},
|
|
521
524
|
outputSchema: {
|
|
522
525
|
type: "object",
|
|
523
|
-
description: "
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
526
|
+
description: "Document metadata with format-specific fields",
|
|
527
|
+
properties: {
|
|
528
|
+
success: { type: "boolean" },
|
|
529
|
+
error: { type: "string" },
|
|
530
|
+
file_size: { type: "number" },
|
|
531
|
+
sheets: {
|
|
532
|
+
type: "array",
|
|
533
|
+
items: {
|
|
534
|
+
type: "object",
|
|
535
|
+
properties: {
|
|
536
|
+
name: { type: "string" },
|
|
537
|
+
rows: { type: "number" },
|
|
538
|
+
cols: { type: "number" }
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
paragraphs: { type: "number" },
|
|
543
|
+
tables: { type: "number" },
|
|
544
|
+
slides: { type: "number" },
|
|
545
|
+
pages: { type: "number" },
|
|
546
|
+
total_words: { type: "number" },
|
|
547
|
+
metadata: { type: "object" },
|
|
548
|
+
line_count: { type: "number" },
|
|
549
|
+
encoding: { type: "string" },
|
|
550
|
+
file_type: { type: "string" },
|
|
551
|
+
headers: {
|
|
552
|
+
type: "array",
|
|
553
|
+
items: { type: "string" }
|
|
554
|
+
},
|
|
555
|
+
total_rows: { type: "number" },
|
|
556
|
+
total_cols: { type: "number" },
|
|
557
|
+
item_count: { type: "number" },
|
|
558
|
+
key_count: { type: "number" }
|
|
559
|
+
},
|
|
560
|
+
additionalProperties: false
|
|
530
561
|
}
|
|
531
562
|
}
|
|
532
563
|
] };
|
|
@@ -536,7 +567,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
536
567
|
try {
|
|
537
568
|
if (name === "read_document") {
|
|
538
569
|
const params = ReadDocumentSchema.parse(args);
|
|
539
|
-
const fileType = detectFileType(params.file_path);
|
|
570
|
+
const fileType = params.file_type || detectFileType(params.file_path);
|
|
540
571
|
if (!fileType) throw new Error(`Unsupported file type: ${params.file_path}`);
|
|
541
572
|
const config = getConfig();
|
|
542
573
|
const mode = params.mode || (config.rawFullRead ? "raw" : "paginated");
|
|
@@ -559,6 +590,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
559
590
|
scriptArgs.push(String(page));
|
|
560
591
|
scriptArgs.push(String(pageSize));
|
|
561
592
|
}
|
|
593
|
+
} else if (fileType === "pptx") {
|
|
594
|
+
scriptName = "pptx_handler.py";
|
|
595
|
+
scriptArgs = ["read", params.file_path];
|
|
596
|
+
if (page) {
|
|
597
|
+
scriptArgs.push(String(page));
|
|
598
|
+
scriptArgs.push(String(pageSize));
|
|
599
|
+
}
|
|
562
600
|
} else if (fileType === "pdf") {
|
|
563
601
|
scriptName = "pdf_handler.py";
|
|
564
602
|
scriptArgs = ["read", params.file_path];
|
|
@@ -608,6 +646,14 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
608
646
|
JSON.stringify(paragraphs)
|
|
609
647
|
];
|
|
610
648
|
if (tables) scriptArgs.push(JSON.stringify(tables));
|
|
649
|
+
} else if (params.format === "pptx") {
|
|
650
|
+
scriptName = "pptx_handler.py";
|
|
651
|
+
const slides = params.data.slides || params.data || [];
|
|
652
|
+
scriptArgs = [
|
|
653
|
+
"write",
|
|
654
|
+
params.file_path,
|
|
655
|
+
JSON.stringify(slides)
|
|
656
|
+
];
|
|
611
657
|
} else if (params.format === "text") {
|
|
612
658
|
scriptName = "text_handler.py";
|
|
613
659
|
const content = typeof params.data === "string" ? params.data : JSON.stringify(params.data);
|
|
@@ -632,12 +678,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
632
678
|
}
|
|
633
679
|
if (name === "get_document_info") {
|
|
634
680
|
const params = GetDocumentInfoSchema.parse(args);
|
|
635
|
-
const fileType = detectFileType(params.file_path);
|
|
681
|
+
const fileType = params.file_type || detectFileType(params.file_path);
|
|
636
682
|
if (!fileType) throw new Error(`Unsupported file type: ${params.file_path}`);
|
|
637
683
|
let scriptName;
|
|
638
684
|
let scriptArgs = ["info", params.file_path];
|
|
639
685
|
if (fileType === "excel") scriptName = "excel_handler.py";
|
|
640
686
|
else if (fileType === "word") scriptName = "word_handler.py";
|
|
687
|
+
else if (fileType === "pptx") scriptName = "pptx_handler.py";
|
|
641
688
|
else if (fileType === "pdf") scriptName = "pdf_handler.py";
|
|
642
689
|
else scriptName = "text_handler.py";
|
|
643
690
|
const result = await runPythonFile(scriptName, {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["filePath: string","scriptPath: string","options: RunPythonFileOptions","runPyOptions: RunPyOptions","filePath: string","fileType: string","packages: Record<string, Record<string, string>>","scriptName: string","scriptArgs: string[]"],"sources":["../src/code-runner.ts","../src/utils.ts","../src/index.ts"],"sourcesContent":["/**\n * Code runner client - uses @mcpc-tech/code-runner-mcp npm package\n */\nimport { runPy, type RunPyOptions } from \"@mcpc-tech/code-runner-mcp\";\nimport { readFileSync } from \"fs\";\nimport { fileURLToPath } from \"url\";\nimport { dirname, join, resolve } from \"path\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Options for running Python script files\n */\nexport interface RunPythonFileOptions {\n /** Command line arguments to pass to the script */\n args?: string[];\n /** Package name mappings (import_name -> pypi_name) */\n packages?: Record<string, string>;\n /** Base directory for the script (default: \"python\") */\n baseDir?: string;\n /** User file paths that need to be accessible (for file system mounting) */\n filePaths?: string[];\n}\n\n/**\n * Convert absolute file path to Pyodide virtual path\n * Determines the mount root and converts the path accordingly\n *\n * @param filePath - Absolute path to the file\n * @returns Object with mountRoot (host path) and virtualPath (Pyodide path)\n */\nfunction getFileSystemMapping(\n filePath: string,\n): { mountRoot: string; virtualPath: string } {\n const absolutePath = resolve(filePath);\n\n // Mount the parent directory of the file\n // This allows Python to access the file and its siblings\n const mountRoot = dirname(absolutePath);\n const virtualPath = absolutePath;\n\n return { mountRoot, virtualPath };\n}\n\n/**\n * Run a Python script file using code-runner-mcp\n *\n * @param scriptPath - Path to the Python script (relative to baseDir)\n * @param options - Execution options\n * @returns The execution result\n */\nexport async function runPythonFile(\n scriptPath: string,\n options: RunPythonFileOptions = {},\n): Promise<any> {\n const {\n args = [],\n packages = {},\n baseDir = \"python\",\n filePaths = [],\n } = options;\n\n // Read the Python script\n const fullPath = join(__dirname, \"..\", baseDir, scriptPath);\n const scriptContent = readFileSync(fullPath, \"utf-8\");\n\n // Build wrapper code that sets sys.argv and executes the script\n const wrapperCode = `\nimport sys\nimport json\n\n# Set command line arguments\nsys.argv = ['${scriptPath}'] + ${JSON.stringify(args)}\n\n# Execute the script\n${scriptContent}\n`;\n\n // Determine mount root from the first file path\n let mountRoot = join(__dirname, \"..\"); // Default: project root\n if (filePaths.length > 0) {\n const mapping = getFileSystemMapping(filePaths[0]);\n mountRoot = mapping.mountRoot;\n }\n\n // Execute via runPy with options\n // Mount point is the same as the mount root (Pyodide will see host paths directly)\n const runPyOptions: RunPyOptions = {\n packages,\n nodeFSMountPoint: mountRoot,\n nodeFSRoot: mountRoot,\n };\n const stream = await runPy(wrapperCode, runPyOptions);\n\n // Read the stream output\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n let stdout = \"\";\n let stderr = \"\";\n let error = \"\";\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value, { stream: true });\n if (chunk.startsWith(\"[stderr] \")) {\n stderr += chunk.slice(9);\n } else if (chunk.startsWith(\"[err]\")) {\n error += chunk;\n } else {\n stdout += chunk;\n }\n }\n } catch (streamError) {\n // Stream error means Python execution failed\n return { error: String(streamError) };\n }\n\n // Check for errors\n if (error) {\n return { error: error.replace(/\\[err\\]\\[py\\]\\s*/g, \"\").trim() };\n }\n\n // Parse the JSON output from the script (last line)\n const lines = stdout.trim().split(\"\\n\");\n const lastLine = lines[lines.length - 1];\n\n try {\n return JSON.parse(lastLine);\n } catch {\n return { stdout, stderr };\n }\n}\n","/**\n * Utility functions for document processing\n */\n\n/**\n * Detect file type from file extension\n */\nexport function detectFileType(\n filePath: string,\n): \"excel\" | \"word\" | \"pdf\" | \"text\" | null {\n const ext = filePath.toLowerCase().split(\".\").pop();\n if (ext === \"xlsx\" || ext === \"xls\") return \"excel\";\n if (ext === \"docx\") return \"word\";\n if (ext === \"pdf\") return \"pdf\";\n if (\n ext === \"txt\" || ext === \"csv\" || ext === \"md\" || ext === \"json\" ||\n ext === \"yaml\" || ext === \"yml\"\n ) return \"text\";\n return null;\n}\n\n/**\n * Get required packages for each file type\n */\nexport function getPackages(fileType: string): Record<string, string> {\n const packages: Record<string, Record<string, string>> = {\n excel: { openpyxl: \"openpyxl\" },\n word: { docx: \"python-docx\" }, // Map docx import to python-docx package\n pdf: { PyPDF2: \"PyPDF2\" },\n text: {}, // No external packages needed for text files\n };\n return packages[fileType] || {};\n}\n\n/**\n * Get environment configuration\n */\nexport function getConfig() {\n return {\n rawFullRead: process.env.DOC_RAW_FULL_READ === \"true\",\n pageSize: parseInt(process.env.DOC_PAGE_SIZE || \"100\", 10),\n maxFileSize: parseInt(process.env.DOC_MAX_FILE_SIZE || \"50\", 10) * 1024 *\n 1024,\n };\n}\n","#!/usr/bin/env node\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\nimport { runPythonFile } from \"./code-runner.js\";\nimport { detectFileType, getConfig, getPackages } from \"./utils.js\";\n\n// Tool schemas\nconst ReadDocumentSchema = z.object({\n file_path: z.string().describe(\"Absolute path to the document file\"),\n mode: z.enum([\"raw\", \"paginated\"]).optional().describe(\n \"Read mode: 'raw' for full content, 'paginated' for chunked reading\",\n ),\n page: z.number().optional().describe(\n \"Page number for paginated mode (1-based)\",\n ),\n page_size: z.number().optional().describe(\n \"Items per page for paginated mode\",\n ),\n sheet_name: z.string().optional().describe(\"Sheet name for Excel files\"),\n});\n\nconst WriteDocumentSchema = z.object({\n file_path: z.string().describe(\"Absolute path to save the document\"),\n format: z.enum([\"excel\", \"word\", \"text\"]).describe(\"Document format\"),\n data: z.any().describe(\"Document data structure\"),\n});\n\nconst GetDocumentInfoSchema = z.object({\n file_path: z.string().describe(\"Absolute path to the document file\"),\n});\n\n// Server setup\nconst server = new Server(\n {\n name: \"docsmith-mcp\",\n version: \"0.1.0\",\n },\n {\n capabilities: {\n tools: {},\n },\n },\n);\n\n// Output schemas (reusable)\nconst BaseOutputSchema = {\n type: \"object\",\n properties: {\n success: { type: \"boolean\", description: \"Operation success status\" },\n error: { type: \"string\", description: \"Error message if failed\" },\n },\n} as const;\n\nconst PaginationSchema = {\n current_page: { type: \"number\", description: \"Current page number\" },\n page_size: { type: \"number\", description: \"Items per page\" },\n total_pages: { type: \"number\", description: \"Total number of pages\" },\n page: { type: \"number\", description: \"Current page number (alternative)\" },\n has_more: { type: \"boolean\", description: \"Whether more pages exist\" },\n} as const;\n\nconst ExcelReadOutputSchema = {\n type: \"object\",\n properties: {\n sheet_name: { type: \"string\", description: \"Active sheet name\" },\n sheets: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"All sheet names\",\n },\n total_rows: { type: \"number\", description: \"Total rows in sheet\" },\n total_cols: { type: \"number\", description: \"Total columns in sheet\" },\n data: {\n type: \"array\",\n items: { type: \"array\", items: {} },\n description: \"Sheet data as array of rows\",\n },\n ...PaginationSchema,\n },\n} as const;\n\nconst WordReadOutputSchema = {\n type: \"object\",\n properties: {\n paragraphs: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Document paragraphs\",\n },\n tables: {\n type: \"array\",\n items: {\n type: \"array\",\n items: { type: \"array\", items: { type: \"string\" } },\n },\n description: \"Tables data\",\n },\n total_paragraphs: { type: \"number\", description: \"Total paragraph count\" },\n total_tables: { type: \"number\", description: \"Total table count\" },\n ...PaginationSchema,\n },\n} as const;\n\nconst PDFReadOutputSchema = {\n type: \"object\",\n properties: {\n total_pages: { type: \"number\", description: \"Total pages in PDF\" },\n content: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n page_number: { type: \"number\" },\n text: { type: \"string\" },\n },\n },\n description: \"Page content array\",\n },\n current_page_group: { type: \"number\" },\n page_size: { type: \"number\" },\n },\n} as const;\n\nconst TextReadOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n content: { type: \"string\", description: \"Text content\" },\n total_lines: { type: \"number\", description: \"Total line count\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n ...PaginationSchema,\n },\n} as const;\n\nconst CSVReadOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n headers: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"CSV headers\",\n },\n data: {\n type: \"array\",\n items: { type: \"object\" },\n description: \"Structured data as array of objects\",\n },\n total_rows: { type: \"number\", description: \"Total data rows\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n ...PaginationSchema,\n },\n} as const;\n\nconst JSONReadOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n data: { type: \"object\", description: \"Parsed JSON data\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n },\n} as const;\n\nconst WriteOutputSchema = {\n type: \"object\",\n properties: {\n success: { type: \"boolean\", description: \"Write operation success\" },\n file_path: { type: \"string\", description: \"Written file path\" },\n message: { type: \"string\", description: \"Success message\" },\n error: { type: \"string\", description: \"Error message if failed\" },\n },\n} as const;\n\nconst ExcelInfoOutputSchema = {\n type: \"object\",\n properties: {\n sheets: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n rows: { type: \"number\" },\n cols: { type: \"number\" },\n },\n },\n description: \"Sheet information\",\n },\n file_size: { type: \"number\", description: \"File size in bytes\" },\n },\n} as const;\n\nconst WordInfoOutputSchema = {\n type: \"object\",\n properties: {\n paragraphs: { type: \"number\", description: \"Paragraph count\" },\n tables: { type: \"number\", description: \"Table count\" },\n file_size: { type: \"number\", description: \"File size in bytes\" },\n },\n} as const;\n\nconst PDFInfoOutputSchema = {\n type: \"object\",\n properties: {\n pages: { type: \"number\", description: \"Page count\" },\n file_size: { type: \"number\", description: \"File size in bytes\" },\n total_words: { type: \"number\", description: \"Total word count\" },\n },\n} as const;\n\nconst TextInfoOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n file_size: { type: \"number\", description: \"File size in bytes\" },\n line_count: { type: \"number\", description: \"Line count\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n file_type: { type: \"string\", description: \"File extension\" },\n // CSV specific\n headers: { type: \"array\", items: { type: \"string\" } },\n total_rows: { type: \"number\" },\n total_cols: { type: \"number\" },\n // JSON specific\n item_count: { type: \"number\" },\n key_count: { type: \"number\" },\n },\n} as const;\n\n// List available tools\nserver.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: \"read_document\",\n description:\n \"Read document content (Excel, Word, PDF, TXT, CSV, Markdown, JSON, YAML). Supports raw full read or paginated mode.\",\n inputSchema: {\n type: \"object\",\n properties: {\n file_path: {\n type: \"string\",\n description: \"Absolute path to the document file\",\n },\n mode: {\n type: \"string\",\n enum: [\"raw\", \"paginated\"],\n description: \"Read mode\",\n },\n page: {\n type: \"number\",\n description: \"Page number for paginated mode\",\n },\n page_size: { type: \"number\", description: \"Items per page\" },\n sheet_name: {\n type: \"string\",\n description: \"Sheet name for Excel files\",\n },\n },\n required: [\"file_path\"],\n },\n outputSchema: {\n type: \"object\",\n description:\n \"Returns different structures based on file type: Excel (sheet data), Word (paragraphs/tables), PDF (page content), Text (plain text), CSV (structured rows), JSON (parsed object)\",\n oneOf: [\n ExcelReadOutputSchema,\n WordReadOutputSchema,\n PDFReadOutputSchema,\n TextReadOutputSchema,\n CSVReadOutputSchema,\n JSONReadOutputSchema,\n ],\n },\n },\n {\n name: \"write_document\",\n description: \"Write document content (Excel, Word, Text)\",\n inputSchema: {\n type: \"object\",\n properties: {\n file_path: {\n type: \"string\",\n description: \"Absolute path to save the document\",\n },\n format: {\n type: \"string\",\n enum: [\"excel\", \"word\", \"text\"],\n description: \"Document format\",\n },\n data: {\n description:\n \"Document data structure. Excel: array of rows [[cell1, cell2], ...]. Word: {paragraphs: string[], tables?: [[[cell]]]}. Text/CSV/JSON: string or object\",\n },\n },\n required: [\"file_path\", \"format\", \"data\"],\n },\n outputSchema: WriteOutputSchema,\n },\n {\n name: \"get_document_info\",\n description:\n \"Get document metadata (page count, sheet count, file size, etc.)\",\n inputSchema: {\n type: \"object\",\n properties: {\n file_path: {\n type: \"string\",\n description: \"Absolute path to the document file\",\n },\n },\n required: [\"file_path\"],\n },\n outputSchema: {\n type: \"object\",\n description: \"Returns metadata based on file type\",\n oneOf: [\n ExcelInfoOutputSchema,\n WordInfoOutputSchema,\n PDFInfoOutputSchema,\n TextInfoOutputSchema,\n ],\n },\n },\n ],\n };\n});\n\n// Handle tool calls\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n if (name === \"read_document\") {\n const params = ReadDocumentSchema.parse(args);\n const fileType = detectFileType(params.file_path);\n\n if (!fileType) {\n throw new Error(`Unsupported file type: ${params.file_path}`);\n }\n\n // Determine read mode\n const config = getConfig();\n const mode = params.mode || (config.rawFullRead ? \"raw\" : \"paginated\");\n const page = mode === \"paginated\" ? (params.page || 1) : undefined;\n const pageSize = params.page_size || config.pageSize;\n\n let scriptName: string;\n let scriptArgs: string[];\n\n if (fileType === \"excel\") {\n scriptName = \"excel_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (params.sheet_name) scriptArgs.push(params.sheet_name);\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n } else if (fileType === \"word\") {\n scriptName = \"word_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n } else if (fileType === \"pdf\") {\n scriptName = \"pdf_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(Math.min(pageSize, 10))); // PDF pages are larger\n }\n } else {\n // text files\n scriptName = \"text_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n }\n\n const result = await runPythonFile(scriptName, {\n args: scriptArgs,\n packages: getPackages(fileType),\n filePaths: [params.file_path],\n });\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n }],\n structuredContent: result,\n };\n }\n\n if (name === \"write_document\") {\n const params = WriteDocumentSchema.parse(args);\n\n let scriptName: string;\n let scriptArgs: string[];\n\n if (params.format === \"excel\") {\n scriptName = \"excel_handler.py\";\n scriptArgs = [\"write\", params.file_path, JSON.stringify(params.data)];\n } else if (params.format === \"word\") {\n scriptName = \"word_handler.py\";\n const paragraphs = params.data.paragraphs || [];\n const tables = params.data.tables || null;\n scriptArgs = [\"write\", params.file_path, JSON.stringify(paragraphs)];\n if (tables) scriptArgs.push(JSON.stringify(tables));\n } else if (params.format === \"text\") {\n scriptName = \"text_handler.py\";\n const content = typeof params.data === \"string\"\n ? params.data\n : JSON.stringify(params.data);\n scriptArgs = [\"write\", params.file_path, content];\n } else {\n throw new Error(`Unsupported write format: ${params.format}`);\n }\n\n const result = await runPythonFile(scriptName, {\n args: scriptArgs,\n packages: getPackages(params.format),\n filePaths: [params.file_path],\n });\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n }],\n structuredContent: result,\n };\n }\n\n if (name === \"get_document_info\") {\n const params = GetDocumentInfoSchema.parse(args);\n const fileType = detectFileType(params.file_path);\n\n if (!fileType) {\n throw new Error(`Unsupported file type: ${params.file_path}`);\n }\n\n let scriptName: string;\n let scriptArgs = [\"info\", params.file_path];\n\n if (fileType === \"excel\") {\n scriptName = \"excel_handler.py\";\n } else if (fileType === \"word\") {\n scriptName = \"word_handler.py\";\n } else if (fileType === \"pdf\") {\n scriptName = \"pdf_handler.py\";\n } else {\n scriptName = \"text_handler.py\";\n }\n\n const result = await runPythonFile(scriptName, {\n args: scriptArgs,\n packages: getPackages(fileType),\n filePaths: [params.file_path],\n });\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n }],\n structuredContent: result,\n };\n }\n\n throw new Error(`Unknown tool: ${name}`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\", text: `Error: ${errorMessage}` }],\n isError: true,\n };\n }\n});\n\n// Start server\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error(\"Docsmith MCP server running on stdio\");\n}\n\nmain().catch((error) => {\n console.error(\"Server error:\", error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,aAAa,cAAc,OAAO,KAAK,IAAI;AACjD,MAAM,YAAY,QAAQ,WAAW;;;;;;;;AAuBrC,SAAS,qBACPA,UAC4C;CAC5C,MAAM,eAAe,QAAQ,SAAS;CAItC,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,cAAc;AAEpB,QAAO;EAAE;EAAW;CAAa;AAClC;;;;;;;;AASD,eAAsB,cACpBC,YACAC,UAAgC,CAAE,GACpB;CACd,MAAM,EACJ,OAAO,CAAE,GACT,WAAW,CAAE,GACb,UAAU,UACV,YAAY,CAAE,GACf,GAAG;CAGJ,MAAM,WAAW,KAAK,WAAW,MAAM,SAAS,WAAW;CAC3D,MAAM,gBAAgB,aAAa,UAAU,QAAQ;CAGrD,MAAM,eAAe;;;;;eAKR,WAAW,OAAO,KAAK,UAAU,KAAK,CAAC;;;EAGpD,cAAc;;CAId,IAAI,YAAY,KAAK,WAAW,KAAK;AACrC,KAAI,UAAU,SAAS,GAAG;EACxB,MAAM,UAAU,qBAAqB,UAAU,GAAG;AAClD,cAAY,QAAQ;CACrB;CAID,MAAMC,eAA6B;EACjC;EACA,kBAAkB;EAClB,YAAY;CACb;CACD,MAAM,SAAS,MAAM,MAAM,aAAa,aAAa;CAGrD,MAAM,SAAS,OAAO,WAAW;CACjC,MAAM,UAAU,IAAI;CACpB,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,QAAQ;AAEZ,KAAI;AACF,SAAO,MAAM;GACX,MAAM,EAAE,MAAM,OAAO,GAAG,MAAM,OAAO,MAAM;AAC3C,OAAI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B;GACpB;EACF;AAED,MAAI,SAAS,qBAAqB;GAChC,MAAM,SAAS,sBAAsB,MAAM,KAAK;GAChD,MAAM,WAAW,eAAe,OAAO,UAAU;AAEjD,QAAK,SACH,OAAM,IAAI,OAAO,yBAAyB,OAAO,UAAU;GAG7D,IAAID;GACJ,IAAI,aAAa,CAAC,QAAQ,OAAO,SAAU;AAE3C,OAAI,aAAa,QACf,cAAa;YACJ,aAAa,OACtB,cAAa;YACJ,aAAa,MACtB,cAAa;OAEb,cAAa;GAGf,MAAM,SAAS,MAAM,cAAc,YAAY;IAC7C,MAAM;IACN,UAAU,YAAY,SAAS;IAC/B,WAAW,CAAC,OAAO,SAAU;GAC9B,EAAC;AACF,UAAO;IACL,SAAS,CAAC;KACR,MAAM;KACN,MAAM,KAAK,UAAU,QAAQ,MAAM,EAAE;IACtC,CAAC;IACF,mBAAmB;GACpB;EACF;AAED,QAAM,IAAI,OAAO,gBAAgB,KAAK;CACvC,SAAQ,OAAO;EACd,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAC3E,SAAO;GACL,SAAS,CAAC;IAAE,MAAM;IAAQ,OAAO,SAAS,aAAa;GAAG,CAAC;GAC3D,SAAS;EACV;CACF;AACF,EAAC;AAGF,eAAe,OAAO;CACpB,MAAM,YAAY,IAAI;AACtB,OAAM,OAAO,QAAQ,UAAU;AAC/B,SAAQ,MAAM,uCAAuC;AACtD;AAED,MAAM,CAAC,MAAM,CAAC,UAAU;AACtB,SAAQ,MAAM,iBAAiB,MAAM;AACrC,SAAQ,KAAK,EAAE;AAChB,EAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["filePath: string","scriptPath: string","options: RunPythonFileOptions","runPyOptions: RunPyOptions","filePath: string","fileType: string","packages: Record<string, Record<string, string>>","scriptName: string","scriptArgs: string[]"],"sources":["../src/code-runner.ts","../src/utils.ts","../src/index.ts"],"sourcesContent":["/**\n * Code runner client - uses @mcpc-tech/code-runner-mcp npm package\n */\nimport { runPy, type RunPyOptions } from \"@mcpc-tech/code-runner-mcp\";\nimport { readFileSync } from \"fs\";\nimport { fileURLToPath } from \"url\";\nimport { dirname, join, resolve } from \"path\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Options for running Python script files\n */\nexport interface RunPythonFileOptions {\n /** Command line arguments to pass to the script */\n args?: string[];\n /** Package name mappings (import_name -> pypi_name) */\n packages?: Record<string, string>;\n /** Base directory for the script (default: \"python\") */\n baseDir?: string;\n /** User file paths that need to be accessible (for file system mounting) */\n filePaths?: string[];\n}\n\n/**\n * Convert absolute file path to Pyodide virtual path\n * Determines the mount root and converts the path accordingly\n *\n * @param filePath - Absolute path to the file\n * @returns Object with mountRoot (host path) and virtualPath (Pyodide path)\n */\nfunction getFileSystemMapping(\n filePath: string,\n): { mountRoot: string; virtualPath: string } {\n const absolutePath = resolve(filePath);\n\n // Mount the parent directory of the file\n // This allows Python to access the file and its siblings\n const mountRoot = dirname(absolutePath);\n const virtualPath = absolutePath;\n\n return { mountRoot, virtualPath };\n}\n\n/**\n * Run a Python script file using code-runner-mcp\n *\n * @param scriptPath - Path to the Python script (relative to baseDir)\n * @param options - Execution options\n * @returns The execution result\n */\nexport async function runPythonFile(\n scriptPath: string,\n options: RunPythonFileOptions = {},\n): Promise<any> {\n const {\n args = [],\n packages = {},\n baseDir = \"python\",\n filePaths = [],\n } = options;\n\n // Read the Python script\n // Python files are in the python/ directory at project root\n // From dist/index.js, go up one level to reach python/\n const fullPath = join(__dirname, \"..\", baseDir, scriptPath);\n const scriptContent = readFileSync(fullPath, \"utf-8\");\n\n // Build wrapper code that sets sys.argv and executes the script\n const wrapperCode = `\nimport sys\nimport json\n\n# Set command line arguments\nsys.argv = ['${scriptPath}'] + ${JSON.stringify(args)}\n\n# Execute the script\n${scriptContent}\n`;\n\n // Determine mount root from the first file path\n // Default: parent directory of dist/ (project root when running from dist/index.js)\n let mountRoot = join(__dirname, \"..\");\n if (filePaths.length > 0) {\n const mapping = getFileSystemMapping(filePaths[0]);\n mountRoot = mapping.mountRoot;\n }\n\n // Execute via runPy with options\n // Mount point is the same as the mount root (Pyodide will see host paths directly)\n const runPyOptions: RunPyOptions = {\n packages,\n nodeFSMountPoint: mountRoot,\n nodeFSRoot: mountRoot,\n };\n const stream = await runPy(wrapperCode, runPyOptions);\n\n // Read the stream output\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n let stdout = \"\";\n let stderr = \"\";\n let error = \"\";\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value, { stream: true });\n if (chunk.startsWith(\"[stderr] \")) {\n stderr += chunk.slice(9);\n } else if (chunk.startsWith(\"[err]\")) {\n error += chunk;\n } else {\n stdout += chunk;\n }\n }\n } catch (streamError) {\n // Stream error means Python execution failed\n return { error: String(streamError) };\n }\n\n // Check for errors\n if (error) {\n return { error: error.replace(/\\[err\\]\\[py\\]\\s*/g, \"\").trim() };\n }\n\n // Parse the JSON output from the script (last line)\n const lines = stdout.trim().split(\"\\n\");\n const lastLine = lines[lines.length - 1];\n\n try {\n return JSON.parse(lastLine);\n } catch {\n return { stdout, stderr };\n }\n}\n","/**\n * Utility functions for document processing\n */\n\n/**\n * Detect file type from file extension\n */\nexport function detectFileType(\n filePath: string,\n): \"excel\" | \"word\" | \"pdf\" | \"pptx\" | \"text\" | null {\n const ext = filePath.toLowerCase().split(\".\").pop();\n if (ext === \"xlsx\" || ext === \"xls\") return \"excel\";\n if (ext === \"docx\") return \"word\";\n if (ext === \"pptx\" || ext === \"ppt\") return \"pptx\";\n if (ext === \"pdf\") return \"pdf\";\n if (\n ext === \"txt\" || ext === \"csv\" || ext === \"md\" || ext === \"json\" ||\n ext === \"yaml\" || ext === \"yml\"\n ) return \"text\";\n return null;\n}\n\n/**\n * Get required packages for each file type\n */\nexport function getPackages(fileType: string): Record<string, string> {\n const packages: Record<string, Record<string, string>> = {\n excel: { openpyxl: \"openpyxl\" },\n word: { docx: \"python-docx\" }, // Map docx import to python-docx package\n pptx: { pptx: \"python-pptx\" }, // Map pptx import to python-pptx package\n pdf: { PyPDF2: \"PyPDF2\" },\n text: {}, // No external packages needed for text files\n };\n return packages[fileType] || {};\n}\n\n/**\n * Get environment configuration\n */\nexport function getConfig() {\n return {\n rawFullRead: process.env.DOC_RAW_FULL_READ === \"true\",\n pageSize: parseInt(process.env.DOC_PAGE_SIZE || \"100\", 10),\n maxFileSize: parseInt(process.env.DOC_MAX_FILE_SIZE || \"50\", 10) * 1024 *\n 1024,\n };\n}\n","#!/usr/bin/env node\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\nimport { runPythonFile } from \"./code-runner.js\";\nimport { detectFileType, getConfig, getPackages } from \"./utils.js\";\n\n// Tool schemas\nconst ReadDocumentSchema = z.object({\n file_path: z.string().describe(\"Absolute path to the document file\"),\n file_type: z.enum([\"excel\", \"word\", \"pptx\", \"pdf\", \"text\"]).optional()\n .describe(\n \"Override file type detection. Use this to explicitly specify the format instead of relying on file extension\",\n ),\n mode: z.enum([\"raw\", \"paginated\"]).optional().describe(\n \"Read mode: 'raw' for full content, 'paginated' for chunked reading\",\n ),\n page: z.number().optional().describe(\n \"Page number for paginated mode (1-based)\",\n ),\n page_size: z.number().optional().describe(\n \"Items per page for paginated mode\",\n ),\n sheet_name: z.string().optional().describe(\"Sheet name for Excel files\"),\n});\n\nconst WriteDocumentSchema = z.object({\n file_path: z.string().describe(\"Absolute path to save the document\"),\n format: z.enum([\"excel\", \"word\", \"pptx\", \"text\"]).describe(\n \"Document format\",\n ),\n data: z.any().describe(\"Document data structure\"),\n});\n\nconst GetDocumentInfoSchema = z.object({\n file_path: z.string().describe(\"Absolute path to the document file\"),\n file_type: z.enum([\"excel\", \"word\", \"pptx\", \"pdf\", \"text\"]).optional()\n .describe(\n \"Override file type detection. Use this to explicitly specify the format instead of relying on file extension\",\n ),\n});\n\n// Server setup\nconst server = new Server(\n {\n name: \"docsmith-mcp\",\n version: \"0.1.0\",\n },\n {\n capabilities: {\n tools: {},\n },\n },\n);\n\n// Output schemas (reusable)\nconst BaseOutputSchema = {\n type: \"object\",\n properties: {\n success: { type: \"boolean\", description: \"Operation success status\" },\n error: { type: \"string\", description: \"Error message if failed\" },\n },\n} as const;\n\nconst PaginationSchema = {\n current_page: { type: \"number\", description: \"Current page number\" },\n page_size: { type: \"number\", description: \"Items per page\" },\n total_pages: { type: \"number\", description: \"Total number of pages\" },\n page: { type: \"number\", description: \"Current page number (alternative)\" },\n has_more: { type: \"boolean\", description: \"Whether more pages exist\" },\n} as const;\n\nconst ExcelReadOutputSchema = {\n type: \"object\",\n properties: {\n sheet_name: { type: \"string\", description: \"Active sheet name\" },\n sheets: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"All sheet names\",\n },\n total_rows: { type: \"number\", description: \"Total rows in sheet\" },\n total_cols: { type: \"number\", description: \"Total columns in sheet\" },\n data: {\n type: \"array\",\n items: { type: \"array\", items: {} },\n description: \"Sheet data as array of rows\",\n },\n ...PaginationSchema,\n },\n} as const;\n\nconst WordReadOutputSchema = {\n type: \"object\",\n properties: {\n paragraphs: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Document paragraphs\",\n },\n tables: {\n type: \"array\",\n items: {\n type: \"array\",\n items: { type: \"array\", items: { type: \"string\" } },\n },\n description: \"Tables data\",\n },\n total_paragraphs: { type: \"number\", description: \"Total paragraph count\" },\n total_tables: { type: \"number\", description: \"Total table count\" },\n ...PaginationSchema,\n },\n} as const;\n\nconst PDFReadOutputSchema = {\n type: \"object\",\n properties: {\n total_pages: { type: \"number\", description: \"Total pages in PDF\" },\n content: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n page_number: { type: \"number\" },\n text: { type: \"string\" },\n },\n },\n description: \"Page content array\",\n },\n current_page_group: { type: \"number\" },\n page_size: { type: \"number\" },\n },\n} as const;\n\nconst TextReadOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n content: { type: \"string\", description: \"Text content\" },\n total_lines: { type: \"number\", description: \"Total line count\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n ...PaginationSchema,\n },\n} as const;\n\nconst CSVReadOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n headers: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"CSV headers\",\n },\n data: {\n type: \"array\",\n items: { type: \"object\" },\n description: \"Structured data as array of objects\",\n },\n total_rows: { type: \"number\", description: \"Total data rows\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n ...PaginationSchema,\n },\n} as const;\n\nconst JSONReadOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n data: { type: \"object\", description: \"Parsed JSON data\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n },\n} as const;\n\nconst WriteOutputSchema = {\n type: \"object\",\n properties: {\n success: { type: \"boolean\", description: \"Write operation success\" },\n file_path: { type: \"string\", description: \"Written file path\" },\n message: { type: \"string\", description: \"Success message\" },\n error: { type: \"string\", description: \"Error message if failed\" },\n },\n} as const;\n\nconst ExcelInfoOutputSchema = {\n type: \"object\",\n properties: {\n sheets: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n rows: { type: \"number\" },\n cols: { type: \"number\" },\n },\n },\n description: \"Sheet information\",\n },\n file_size: { type: \"number\", description: \"File size in bytes\" },\n },\n} as const;\n\nconst WordInfoOutputSchema = {\n type: \"object\",\n properties: {\n paragraphs: { type: \"number\", description: \"Paragraph count\" },\n tables: { type: \"number\", description: \"Table count\" },\n file_size: { type: \"number\", description: \"File size in bytes\" },\n },\n} as const;\n\nconst PDFInfoOutputSchema = {\n type: \"object\",\n properties: {\n pages: { type: \"number\", description: \"Page count\" },\n file_size: { type: \"number\", description: \"File size in bytes\" },\n total_words: { type: \"number\", description: \"Total word count\" },\n },\n} as const;\n\nconst TextInfoOutputSchema = {\n type: \"object\",\n properties: {\n ...BaseOutputSchema.properties,\n file_size: { type: \"number\", description: \"File size in bytes\" },\n line_count: { type: \"number\", description: \"Line count\" },\n encoding: { type: \"string\", description: \"File encoding\" },\n file_type: { type: \"string\", description: \"File extension\" },\n // CSV specific\n headers: { type: \"array\", items: { type: \"string\" } },\n total_rows: { type: \"number\" },\n total_cols: { type: \"number\" },\n // JSON specific\n item_count: { type: \"number\" },\n key_count: { type: \"number\" },\n },\n} as const;\n\n// List available tools\nserver.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: \"read_document\",\n description:\n \"Read document content (Excel, Word, PowerPoint, PDF, TXT, CSV, Markdown, JSON, YAML). Supports raw full read or paginated mode.\",\n inputSchema: {\n type: \"object\",\n properties: {\n file_path: {\n type: \"string\",\n description: \"Absolute path to the document file\",\n },\n file_type: {\n type: \"string\",\n enum: [\"excel\", \"word\", \"pptx\", \"pdf\", \"text\"],\n description:\n \"Override file type detection (optional). Specify format explicitly instead of relying on extension\",\n },\n mode: {\n type: \"string\",\n enum: [\"raw\", \"paginated\"],\n description: \"Read mode\",\n },\n page: {\n type: \"number\",\n description: \"Page number for paginated mode\",\n },\n page_size: { type: \"number\", description: \"Items per page\" },\n sheet_name: {\n type: \"string\",\n description: \"Sheet name for Excel files\",\n },\n },\n required: [\"file_path\"],\n },\n outputSchema: {\n type: \"object\",\n description:\n \"Document content with format-specific structure. Common fields: success (boolean), error (string, on failure).\",\n properties: {\n // Common fields\n success: { type: \"boolean\" },\n error: { type: \"string\" },\n encoding: { type: \"string\" },\n\n // Excel-specific\n sheet_name: { type: \"string\" },\n sheets: { type: \"array\", items: { type: \"string\" } },\n total_rows: { type: \"number\" },\n total_cols: { type: \"number\" },\n current_page: { type: [\"number\", \"null\"] },\n total_pages: { type: \"number\" },\n\n // Word-specific\n paragraphs: { type: \"array\" },\n tables: { type: \"array\" },\n total_paragraphs: { type: \"number\" },\n total_tables: { type: \"number\" },\n\n // PowerPoint-specific\n total_slides: { type: \"number\" },\n slides: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n slide_number: { type: \"number\" },\n title: { type: \"string\" },\n content: { type: \"array\" },\n notes: { type: \"string\" },\n },\n },\n },\n\n // PDF-specific\n current_page_group: { type: [\"number\", \"null\"] },\n total_page_groups: { type: \"number\" },\n content: {}, // PDF: array of {page_number, text, words}, Text: string\n\n // Text/CSV-specific\n total_lines: { type: \"number\" },\n headers: { type: \"array\", items: { type: \"string\" } },\n\n // Data field (varies by format)\n data: {}, // Excel: array of arrays, CSV: array of objects, JSON: any\n\n // Pagination\n page: { type: \"number\" },\n page_size: { type: [\"number\", \"null\"] },\n has_more: { type: \"boolean\" },\n },\n additionalProperties: false,\n },\n },\n {\n name: \"write_document\",\n description: \"Write document content (Excel, Word, PowerPoint, Text)\",\n inputSchema: {\n type: \"object\",\n properties: {\n file_path: {\n type: \"string\",\n description: \"Absolute path to save the document\",\n },\n format: {\n type: \"string\",\n enum: [\"excel\", \"word\", \"pptx\", \"text\"],\n description: \"Document format\",\n },\n data: {\n description:\n \"Document data structure. Excel: array of rows [[cell1, cell2], ...]. Word: {paragraphs: string[], tables?: [[[cell]]]}. Text/CSV/JSON: string or object\",\n },\n },\n required: [\"file_path\", \"format\", \"data\"],\n },\n outputSchema: WriteOutputSchema,\n },\n {\n name: \"get_document_info\",\n description:\n \"Get document metadata (page count, sheet count, slide count, file size, etc.)\",\n inputSchema: {\n type: \"object\",\n properties: {\n file_path: {\n type: \"string\",\n description: \"Absolute path to the document file\",\n },\n file_type: {\n type: \"string\",\n enum: [\"excel\", \"word\", \"pptx\", \"pdf\", \"text\"],\n description:\n \"Override file type detection (optional). Specify format explicitly instead of relying on extension\",\n },\n },\n required: [\"file_path\"],\n },\n outputSchema: {\n type: \"object\",\n description: \"Document metadata with format-specific fields\",\n properties: {\n success: { type: \"boolean\" },\n error: { type: \"string\" },\n file_size: { type: \"number\" },\n\n // Excel-specific\n sheets: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n rows: { type: \"number\" },\n cols: { type: \"number\" },\n },\n },\n },\n\n // Word-specific\n paragraphs: { type: \"number\" },\n tables: { type: \"number\" },\n\n // PowerPoint-specific\n slides: { type: \"number\" },\n\n // PDF-specific\n pages: { type: \"number\" },\n total_words: { type: \"number\" },\n metadata: { type: \"object\" },\n\n // Text/CSV/JSON-specific\n line_count: { type: \"number\" },\n encoding: { type: \"string\" },\n file_type: { type: \"string\" },\n headers: { type: \"array\", items: { type: \"string\" } },\n total_rows: { type: \"number\" },\n total_cols: { type: \"number\" },\n item_count: { type: \"number\" },\n key_count: { type: \"number\" },\n },\n additionalProperties: false,\n },\n },\n ],\n };\n});\n\n// Handle tool calls\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n if (name === \"read_document\") {\n const params = ReadDocumentSchema.parse(args);\n // Use explicit file_type if provided, otherwise detect from extension\n const fileType = params.file_type || detectFileType(params.file_path);\n\n if (!fileType) {\n throw new Error(`Unsupported file type: ${params.file_path}`);\n }\n\n // Determine read mode\n const config = getConfig();\n const mode = params.mode || (config.rawFullRead ? \"raw\" : \"paginated\");\n const page = mode === \"paginated\" ? (params.page || 1) : undefined;\n const pageSize = params.page_size || config.pageSize;\n\n let scriptName: string;\n let scriptArgs: string[];\n\n if (fileType === \"excel\") {\n scriptName = \"excel_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (params.sheet_name) scriptArgs.push(params.sheet_name);\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n } else if (fileType === \"word\") {\n scriptName = \"word_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n } else if (fileType === \"pptx\") {\n scriptName = \"pptx_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n } else if (fileType === \"pdf\") {\n scriptName = \"pdf_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(Math.min(pageSize, 10))); // PDF pages are larger\n }\n } else {\n // text files\n scriptName = \"text_handler.py\";\n scriptArgs = [\"read\", params.file_path];\n if (page) {\n scriptArgs.push(String(page));\n scriptArgs.push(String(pageSize));\n }\n }\n\n const result = await runPythonFile(scriptName, {\n args: scriptArgs,\n packages: getPackages(fileType),\n filePaths: [params.file_path],\n });\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n }],\n structuredContent: result,\n };\n }\n\n if (name === \"write_document\") {\n const params = WriteDocumentSchema.parse(args);\n\n let scriptName: string;\n let scriptArgs: string[];\n\n if (params.format === \"excel\") {\n scriptName = \"excel_handler.py\";\n scriptArgs = [\"write\", params.file_path, JSON.stringify(params.data)];\n } else if (params.format === \"word\") {\n scriptName = \"word_handler.py\";\n const paragraphs = params.data.paragraphs || [];\n const tables = params.data.tables || null;\n scriptArgs = [\"write\", params.file_path, JSON.stringify(paragraphs)];\n if (tables) scriptArgs.push(JSON.stringify(tables));\n } else if (params.format === \"pptx\") {\n scriptName = \"pptx_handler.py\";\n const slides = params.data.slides || params.data || [];\n scriptArgs = [\"write\", params.file_path, JSON.stringify(slides)];\n } else if (params.format === \"text\") {\n scriptName = \"text_handler.py\";\n const content = typeof params.data === \"string\"\n ? params.data\n : JSON.stringify(params.data);\n scriptArgs = [\"write\", params.file_path, content];\n } else {\n throw new Error(`Unsupported write format: ${params.format}`);\n }\n\n const result = await runPythonFile(scriptName, {\n args: scriptArgs,\n packages: getPackages(params.format),\n filePaths: [params.file_path],\n });\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n }],\n structuredContent: result,\n };\n }\n\n if (name === \"get_document_info\") {\n const params = GetDocumentInfoSchema.parse(args);\n // Use explicit file_type if provided, otherwise detect from extension\n const fileType = params.file_type || detectFileType(params.file_path);\n\n if (!fileType) {\n throw new Error(`Unsupported file type: ${params.file_path}`);\n }\n\n let scriptName: string;\n let scriptArgs = [\"info\", params.file_path];\n\n if (fileType === \"excel\") {\n scriptName = \"excel_handler.py\";\n } else if (fileType === \"word\") {\n scriptName = \"word_handler.py\";\n } else if (fileType === \"pptx\") {\n scriptName = \"pptx_handler.py\";\n } else if (fileType === \"pdf\") {\n scriptName = \"pdf_handler.py\";\n } else {\n scriptName = \"text_handler.py\";\n }\n\n const result = await runPythonFile(scriptName, {\n args: scriptArgs,\n packages: getPackages(fileType),\n filePaths: [params.file_path],\n });\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n }],\n structuredContent: result,\n };\n }\n\n throw new Error(`Unknown tool: ${name}`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\", text: `Error: ${errorMessage}` }],\n isError: true,\n };\n }\n});\n\n// Start server\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error(\"Docsmith MCP server running on stdio\");\n}\n\nmain().catch((error) => {\n console.error(\"Server error:\", error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,aAAa,cAAc,OAAO,KAAK,IAAI;AACjD,MAAM,YAAY,QAAQ,WAAW;;;;;;;;AAuBrC,SAAS,qBACPA,UAC4C;CAC5C,MAAM,eAAe,QAAQ,SAAS;CAItC,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,cAAc;AAEpB,QAAO;EAAE;EAAW;CAAa;AAClC;;;;;;;;AASD,eAAsB,cACpBC,YACAC,UAAgC,CAAE,GACpB;CACd,MAAM,EACJ,OAAO,CAAE,GACT,WAAW,CAAE,GACb,UAAU,UACV,YAAY,CAAE,GACf,GAAG;CAKJ,MAAM,WAAW,KAAK,WAAW,MAAM,SAAS,WAAW;CAC3D,MAAM,gBAAg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