excel_to_json_mcp_from_data
Convert tab-separated Excel or comma-separated CSV data strings into JSON format with customizable output options including nested/flat structures and header handling.
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 MCP tool handler function that processes the input data by calling processData, handles proCode from env, manages errors, and returns the JSON result as text content.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)Zod-based input schema defining the 'data' parameter (required string) and optional 'options' object with various formatting configurations.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)Full registration of the 'excel_to_json_mcp_from_data' tool on the MCP server, including name, metadata with input schema, 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) }] }; } );