@imenam/database-mcp 1.0.12 → 1.0.13

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.js CHANGED
@@ -95,19 +95,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
95
95
  if (!Array.isArray(rows)) {
96
96
  throw new Error('Query did not return tabular rows.');
97
97
  }
98
- const worksheet = XLSX.utils.json_to_sheet(rows);
99
- const workbook = XLSX.utils.book_new();
100
- XLSX.utils.book_append_sheet(workbook, worksheet, sheet_name ?? 'Results');
101
98
  const dir = path.dirname(output_path);
102
99
  if (dir && dir !== '.' && !fs.existsSync(dir)) {
103
100
  fs.mkdirSync(dir, { recursive: true });
104
101
  }
105
- XLSX.writeFile(workbook, output_path, { bookType: format });
102
+ if (format === 'raw') {
103
+ fs.writeFileSync(output_path, JSON.stringify(rows, null, 2), 'utf-8');
104
+ }
105
+ else {
106
+ const worksheet = XLSX.utils.json_to_sheet(rows);
107
+ const workbook = XLSX.utils.book_new();
108
+ XLSX.utils.book_append_sheet(workbook, worksheet, sheet_name ?? 'Results');
109
+ XLSX.writeFile(workbook, output_path, { bookType: format });
110
+ }
106
111
  return {
107
112
  content: [
108
113
  {
109
114
  type: 'text',
110
- text: `Successfully exported ${rows.length} rows to ${format.toUpperCase()} file at: ${path.resolve(output_path)}`,
115
+ text: `Successfully exported ${rows.length} rows to ${(format ?? 'xlsx').toUpperCase()} file at: ${path.resolve(output_path)}`,
111
116
  },
112
117
  ],
113
118
  };
package/dist/tools.js CHANGED
@@ -28,9 +28,9 @@ export const ExportToFileSchema = z.object({
28
28
  .min(1)
29
29
  .describe('The file path where the file should be saved (e.g., "./exports/users.xlsx").'),
30
30
  format: z
31
- .enum(['xlsx', 'csv'])
31
+ .enum(['xlsx', 'csv', 'raw'])
32
32
  .optional()
33
- .describe('Output file format. Defaults to "xlsx".'),
33
+ .describe('Output file format. Defaults to "xlsx". Use "raw" to write the result as plain JSON text — in that case, include the desired extension in output_path (e.g. "result.json", "result.txt").'),
34
34
  sheet_name: z
35
35
  .string()
36
36
  .min(1)
@@ -85,7 +85,7 @@ export const TOOLS = [
85
85
  },
86
86
  {
87
87
  name: 'export_to_file',
88
- description: 'Execute a read-only SQL SELECT query and export all results to a file on disk. Supports xlsx (default) and csv formats.',
88
+ description: 'Execute a read-only SQL SELECT query and export all results to a file on disk. Supports xlsx (default), csv, and raw (plain JSON text) formats. When using raw, specify the desired file extension directly in output_path (e.g. "result.json", "data.txt").',
89
89
  inputSchema: {
90
90
  type: 'object',
91
91
  properties: {
@@ -99,8 +99,8 @@ export const TOOLS = [
99
99
  },
100
100
  format: {
101
101
  type: 'string',
102
- enum: ['xlsx', 'csv'],
103
- description: 'Output file format (defaults to "xlsx").',
102
+ enum: ['xlsx', 'csv', 'raw'],
103
+ description: 'Output file format (defaults to "xlsx"). Use "raw" to write the result as plain JSON text — you must then include the desired extension in output_path (e.g. "result.json", "result.txt").',
104
104
  },
105
105
  sheet_name: {
106
106
  type: 'string',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imenam/database-mcp",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",