docsmith-mcp 0.0.1 → 0.0.2

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 CHANGED
@@ -602,7 +602,7 @@ server.setRequestHandler(__modelcontextprotocol_sdk_types_js.CallToolRequestSche
602
602
  if (fileType === "excel") {
603
603
  scriptName = "excel_handler.py";
604
604
  scriptArgs = ["read", params.file_path];
605
- if (params.sheet_name) scriptArgs.push(params.sheet_name);
605
+ scriptArgs.push(params.sheet_name || "");
606
606
  if (page) {
607
607
  scriptArgs.push(String(page));
608
608
  scriptArgs.push(String(pageSize));
@@ -1 +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,qBAAqB,UAAU,GAAG;AAClD,cAAY,QAAQ;CACrB;CAID,MAAMI,eAA6B;EACjC;EACA,kBAAkB;EAClB,YAAY;CACb;CACD,MAAM,SAAS,MAAM,uCAAM,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,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,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.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 // Always push sheet_name (even if undefined) to maintain arg positions\n 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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chema, async (request) => {
578
578
  if (fileType === "excel") {
579
579
  scriptName = "excel_handler.py";
580
580
  scriptArgs = ["read", params.file_path];
581
- if (params.sheet_name) scriptArgs.push(params.sheet_name);
581
+ scriptArgs.push(params.sheet_name || "");
582
582
  if (page) {
583
583
  scriptArgs.push(String(page));
584
584
  scriptArgs.push(String(pageSize));
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 // 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:\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SAAU;GAC9B,EAAC;AACF,UAAO;IACL,SAAS,CAAC;KACR,MAAM;KACN,MAAM,KAAK,UAAU,QAAQ,MAAM,EAAE;IACtC,CAAC;IACF,mBAAmB;GACpB;EACF;AAED,MAAI,SAAS,qBAAqB;GAChC,MAAM,SAAS,sBAAsB,MAAM,KAAK;GAEhD,MAAM,WAAW,OAAO,aAAa,eAAe,OAAO,UAAU;AAErE,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,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 // Always push sheet_name (even if undefined) to maintain arg positions\n 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,YAC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AAID;GACJ,IAAI,aAAa,CAAC,QAAQ,OAAO,SAAU;AAE3C,OAAI,aAAa,QACf,cAAa;YACJ,aAAa,OACtB,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docsmith-mcp",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Python-powered document processing MCP for Excel, Word, PDF",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,12 +35,14 @@ def read_excel(file_path: str, sheet_name: str = None, page: int = None, page_si
35
35
  for row in ws.iter_rows(values_only=True):
36
36
  data.append(row)
37
37
 
38
+ total_rows_data = len(data)
39
+
38
40
  # Handle pagination
39
41
  if page is not None:
42
+ total_pages = (total_rows_data + page_size - 1) // page_size if total_rows_data > 0 else 1
40
43
  start = (page - 1) * page_size
41
44
  end = start + page_size
42
45
  data = data[start:end]
43
- total_pages = (len(data) + page_size - 1) // page_size if data else 1
44
46
  else:
45
47
  total_pages = 1
46
48
 
@@ -94,8 +96,8 @@ if __name__ == "__main__":
94
96
  file_path = sys.argv[2]
95
97
 
96
98
  if command == "read":
97
- sheet = sys.argv[3] if len(sys.argv) > 3 else None
98
- page = int(sys.argv[4]) if len(sys.argv) > 4 else None
99
+ sheet = sys.argv[3] if len(sys.argv) > 3 and sys.argv[3] else None
100
+ page = int(sys.argv[4]) if len(sys.argv) > 4 and sys.argv[4] else None
99
101
  page_size = int(sys.argv[5]) if len(sys.argv) > 5 else 100
100
102
  result = read_excel(file_path, sheet, page, page_size)
101
103
  elif command == "info":