excel_to_json_mcp_from_data
Convert Excel or CSV data strings to JSON format with configurable output options for structured data processing.
Instructions
Convert string format (1) tab separated Excel data or (2) comma separated CSV data to JSON. If you do not have a Pro Code, please pass only the data parameter, but not options parameter in the request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Tab separated Excel data or CSV data in string format | |
| options | No | If you do not have a Pro Code, please do not pass the options parameter in the request. |
Implementation Reference
- src/index.ts:32-46 (handler)The handler function for the 'excel_to_json_mcp_from_data' tool. It processes the input 'data' and optional 'options' by calling the imported 'processData' function, handles proCode from env if missing, manages errors by appending documentation URL, sets success message, and returns the result as a text content block with JSON string.async ({ data, options }) => { if (options && !options.proCode) { options.proCode = process.env.proCode || '' } let result = await processData(data, options) if (result.isError) { result['data'] = '' result['msg'] = result['msg'] + ' Refer to Documentation at ' + URLs.mcp } else { result['msg'] = 'success' } // 返回JSON格式的结果 return { content: [{ type: "text", text: JSON.stringify(result) }] }; }
- src/index.ts:18-30 (schema)The input schema for the tool, using Zod to validate 'data' as a non-empty string (Excel/CSV data) and optional 'options' object with parameters for JSON formatting, headers, delimiters, empty cells, booleans, overall format, single object handling, and proCode.inputSchema: { data: z.string().nonempty().describe("Tab separated Excel data or CSV data in string format"), options: z.object({ jsonMode: z.enum(['nested', 'flat']).optional().describe("Format mode for JSON output: 'nested' or 'flat'"), header: z.enum(['row', 'column']).optional().describe("Specifies which row/column to use as headers: 'row' (first row) or 'column' (first column)"), delimiter: z.enum(['.', '_', '__', '/']).optional().describe("Delimiter character for nested JSON keys when using nested jsonMode: '.', '_', '__', '/'"), emptyCell: z.enum(['emptyString', 'null', 'exclude']).optional().describe("Handling of empty cells: 'emptyString', 'null', or 'exclude'"), booleanFormat: z.enum(['trueFalse', '10', 'string']).optional().describe("Format for boolean values: 'trueFalse', '10', or 'string'"), jsonFormat: z.enum(['arrayOfObject', '2DArray']).optional().describe("Overall JSON output format: 'arrayOfObject' or '2DArray'"), singleObjectFormat: z.enum(['array', 'object']).optional().describe("Format when result has only one object: 'array' (keep as array) or 'object' (return as single object)"), proCode: z.string().optional().describe("Pro Code for Excel to JSON by WTSolutions, if you have one. If you do not have a Pro Code, please do not pass the options parameter in the request."), }).optional().describe("If you do not have a Pro Code, please do not pass the options parameter in the request."), }
- src/index.ts:13-47 (registration)The registration call for the 'excel_to_json_mcp_from_data' tool using McpServer.registerTool, including the tool name, metadata (title, description), inputSchema, and the handler function.server.registerTool( "excel_to_json_mcp_from_data", { title: "Excel to JSON MCP by WTSolutions - from data", description: "Convert string format (1) tab separated Excel data or (2) comma separated CSV data to JSON. If you do not have a Pro Code, please pass only the data parameter, but not options parameter in the request", inputSchema: { data: z.string().nonempty().describe("Tab separated Excel data or CSV data in string format"), options: z.object({ jsonMode: z.enum(['nested', 'flat']).optional().describe("Format mode for JSON output: 'nested' or 'flat'"), header: z.enum(['row', 'column']).optional().describe("Specifies which row/column to use as headers: 'row' (first row) or 'column' (first column)"), delimiter: z.enum(['.', '_', '__', '/']).optional().describe("Delimiter character for nested JSON keys when using nested jsonMode: '.', '_', '__', '/'"), emptyCell: z.enum(['emptyString', 'null', 'exclude']).optional().describe("Handling of empty cells: 'emptyString', 'null', or 'exclude'"), booleanFormat: z.enum(['trueFalse', '10', 'string']).optional().describe("Format for boolean values: 'trueFalse', '10', or 'string'"), jsonFormat: z.enum(['arrayOfObject', '2DArray']).optional().describe("Overall JSON output format: 'arrayOfObject' or '2DArray'"), singleObjectFormat: z.enum(['array', 'object']).optional().describe("Format when result has only one object: 'array' (keep as array) or 'object' (return as single object)"), proCode: z.string().optional().describe("Pro Code for Excel to JSON by WTSolutions, if you have one. If you do not have a Pro Code, please do not pass the options parameter in the request."), }).optional().describe("If you do not have a Pro Code, please do not pass the options parameter in the request."), } }, async ({ data, options }) => { if (options && !options.proCode) { options.proCode = process.env.proCode || '' } let result = await processData(data, options) if (result.isError) { result['data'] = '' result['msg'] = result['msg'] + ' Refer to Documentation at ' + URLs.mcp } else { result['msg'] = 'success' } // 返回JSON格式的结果 return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );