@iflow-mcp/xexr_mcp-libsql 1.1.0
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/LICENSE +21 -0
- package/README.md +509 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +327 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/base-tool.d.ts +29 -0
- package/dist/lib/base-tool.d.ts.map +1 -0
- package/dist/lib/base-tool.js +175 -0
- package/dist/lib/base-tool.js.map +1 -0
- package/dist/lib/constants.d.ts +26 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +47 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/database.d.ts +39 -0
- package/dist/lib/database.d.ts.map +1 -0
- package/dist/lib/database.js +284 -0
- package/dist/lib/database.js.map +1 -0
- package/dist/lib/logger.d.ts +23 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +124 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/server-manager.d.ts +31 -0
- package/dist/lib/server-manager.d.ts.map +1 -0
- package/dist/lib/server-manager.js +283 -0
- package/dist/lib/server-manager.js.map +1 -0
- package/dist/schemas/alter-table.d.ts +23 -0
- package/dist/schemas/alter-table.d.ts.map +1 -0
- package/dist/schemas/alter-table.js +85 -0
- package/dist/schemas/alter-table.js.map +1 -0
- package/dist/schemas/create-table.d.ts +23 -0
- package/dist/schemas/create-table.d.ts.map +1 -0
- package/dist/schemas/create-table.js +81 -0
- package/dist/schemas/create-table.js.map +1 -0
- package/dist/schemas/describe-table.d.ts +26 -0
- package/dist/schemas/describe-table.d.ts.map +1 -0
- package/dist/schemas/describe-table.js +47 -0
- package/dist/schemas/describe-table.js.map +1 -0
- package/dist/schemas/list-tables.d.ts +29 -0
- package/dist/schemas/list-tables.d.ts.map +1 -0
- package/dist/schemas/list-tables.js +37 -0
- package/dist/schemas/list-tables.js.map +1 -0
- package/dist/schemas/read-query.d.ts +17 -0
- package/dist/schemas/read-query.d.ts.map +1 -0
- package/dist/schemas/read-query.js +66 -0
- package/dist/schemas/read-query.js.map +1 -0
- package/dist/schemas/write-query.d.ts +20 -0
- package/dist/schemas/write-query.d.ts.map +1 -0
- package/dist/schemas/write-query.js +58 -0
- package/dist/schemas/write-query.js.map +1 -0
- package/dist/tools/alter-table.d.ts +31 -0
- package/dist/tools/alter-table.d.ts.map +1 -0
- package/dist/tools/alter-table.js +139 -0
- package/dist/tools/alter-table.js.map +1 -0
- package/dist/tools/create-table.d.ts +31 -0
- package/dist/tools/create-table.d.ts.map +1 -0
- package/dist/tools/create-table.js +121 -0
- package/dist/tools/create-table.js.map +1 -0
- package/dist/tools/describe-table.d.ts +30 -0
- package/dist/tools/describe-table.d.ts.map +1 -0
- package/dist/tools/describe-table.js +165 -0
- package/dist/tools/describe-table.js.map +1 -0
- package/dist/tools/list-tables.d.ts +32 -0
- package/dist/tools/list-tables.d.ts.map +1 -0
- package/dist/tools/list-tables.js +210 -0
- package/dist/tools/list-tables.js.map +1 -0
- package/dist/tools/read-query.d.ts +17 -0
- package/dist/tools/read-query.d.ts.map +1 -0
- package/dist/tools/read-query.js +112 -0
- package/dist/tools/read-query.js.map +1 -0
- package/dist/tools/write-query.d.ts +20 -0
- package/dist/tools/write-query.d.ts.map +1 -0
- package/dist/tools/write-query.js +63 -0
- package/dist/tools/write-query.js.map +1 -0
- package/dist/types/index.d.ts +50 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/error-handler.d.ts +22 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +85 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/performance.d.ts +16 -0
- package/dist/utils/performance.d.ts.map +1 -0
- package/dist/utils/performance.js +40 -0
- package/dist/utils/performance.js.map +1 -0
- package/package.json +1 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { BaseTool } from '../lib/base-tool.js';
|
|
2
|
+
import { formatPerformanceMetrics } from '../utils/performance.js';
|
|
3
|
+
import { DescribeTableInputSchema } from '../schemas/describe-table.js';
|
|
4
|
+
export class DescribeTableTool extends BaseTool {
|
|
5
|
+
name = 'describe-table';
|
|
6
|
+
description = 'Get comprehensive schema information for a specific table including columns, indexes, foreign keys, and constraints. Supports both human-readable and JSON output formats.';
|
|
7
|
+
inputSchema = DescribeTableInputSchema;
|
|
8
|
+
async executeImpl(context) {
|
|
9
|
+
const { tableName, includeIndexes, includeForeignKeys, format } = context.arguments;
|
|
10
|
+
try {
|
|
11
|
+
const startTime = Date.now();
|
|
12
|
+
// Sanitize table name for PRAGMA queries
|
|
13
|
+
const sanitizedTableName = this.sanitizeTableName(tableName);
|
|
14
|
+
// First check if table exists
|
|
15
|
+
const tableExistsQuery = `
|
|
16
|
+
SELECT name, sql
|
|
17
|
+
FROM sqlite_master
|
|
18
|
+
WHERE type='table' AND name=?
|
|
19
|
+
`;
|
|
20
|
+
const tableExistsResult = await context.connection.execute(tableExistsQuery, [
|
|
21
|
+
sanitizedTableName
|
|
22
|
+
]);
|
|
23
|
+
if (tableExistsResult.rows.length === 0) {
|
|
24
|
+
return {
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: 'text',
|
|
28
|
+
text: `Error: Table '${tableName}' does not exist`
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
isError: true
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// Get table schema information
|
|
35
|
+
const schemaQuery = `PRAGMA table_info("${sanitizedTableName}")`;
|
|
36
|
+
const schemaResult = await context.connection.execute(schemaQuery);
|
|
37
|
+
const tableInfo = {
|
|
38
|
+
name: sanitizedTableName,
|
|
39
|
+
sql: tableExistsResult.rows[0].sql,
|
|
40
|
+
columns: schemaResult.rows,
|
|
41
|
+
indexes: [],
|
|
42
|
+
foreignKeys: []
|
|
43
|
+
};
|
|
44
|
+
// Get table indexes if requested
|
|
45
|
+
if (includeIndexes) {
|
|
46
|
+
const indexQuery = `PRAGMA index_list("${sanitizedTableName}")`;
|
|
47
|
+
const indexResult = await context.connection.execute(indexQuery);
|
|
48
|
+
for (const index of indexResult.rows) {
|
|
49
|
+
const indexInfoQuery = `PRAGMA index_info("${index.name}")`;
|
|
50
|
+
const indexInfoResult = await context.connection.execute(indexInfoQuery);
|
|
51
|
+
tableInfo.indexes.push({
|
|
52
|
+
name: index.name,
|
|
53
|
+
unique: index.unique,
|
|
54
|
+
origin: index.origin,
|
|
55
|
+
partial: index.partial,
|
|
56
|
+
columns: indexInfoResult.rows
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Get foreign keys if requested
|
|
61
|
+
if (includeForeignKeys) {
|
|
62
|
+
const foreignKeyQuery = `PRAGMA foreign_key_list("${sanitizedTableName}")`;
|
|
63
|
+
const foreignKeyResult = await context.connection.execute(foreignKeyQuery);
|
|
64
|
+
tableInfo.foreignKeys = foreignKeyResult.rows;
|
|
65
|
+
}
|
|
66
|
+
const executionTime = Date.now() - startTime;
|
|
67
|
+
const metrics = formatPerformanceMetrics({
|
|
68
|
+
executionTime
|
|
69
|
+
});
|
|
70
|
+
if (format === 'json') {
|
|
71
|
+
return {
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
type: 'text',
|
|
75
|
+
text: JSON.stringify({
|
|
76
|
+
table: tableInfo,
|
|
77
|
+
metadata: {
|
|
78
|
+
executionTime,
|
|
79
|
+
timestamp: new Date().toISOString()
|
|
80
|
+
}
|
|
81
|
+
}, null, 2)
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Format as human-readable table
|
|
87
|
+
let output = `Table: ${sanitizedTableName}\n\n`;
|
|
88
|
+
// Display CREATE statement if available
|
|
89
|
+
if (tableInfo.sql) {
|
|
90
|
+
output += 'CREATE Statement:\n';
|
|
91
|
+
output += `${tableInfo.sql}\n\n`;
|
|
92
|
+
}
|
|
93
|
+
// Display columns
|
|
94
|
+
output += 'Columns:\n';
|
|
95
|
+
output += '┌─────────────────┬─────────────────┬─────────┬─────────────┬─────────────┐\n';
|
|
96
|
+
output += '│ Name │ Type │ Not Null│ Default │ Primary Key │\n';
|
|
97
|
+
output += '├─────────────────┼─────────────────┼─────────┼─────────────┼─────────────┤\n';
|
|
98
|
+
for (const row of schemaResult.rows) {
|
|
99
|
+
const name = String(row.name || '').padEnd(15);
|
|
100
|
+
const type = String(row.type || '').padEnd(15);
|
|
101
|
+
const notNull = (row.notnull ? 'YES' : 'NO').padEnd(7);
|
|
102
|
+
const defaultValue = String(row.dflt_value || '').padEnd(11);
|
|
103
|
+
const primaryKey = (row.pk ? 'YES' : 'NO').padEnd(11);
|
|
104
|
+
output += `│ ${name} │ ${type} │ ${notNull} │ ${defaultValue} │ ${primaryKey} │\n`;
|
|
105
|
+
}
|
|
106
|
+
output += '└─────────────────┴─────────────────┴─────────┴─────────────┴─────────────┘\n\n';
|
|
107
|
+
// Display indexes if requested and available
|
|
108
|
+
if (includeIndexes && tableInfo.indexes.length > 0) {
|
|
109
|
+
output += 'Indexes:\n';
|
|
110
|
+
for (const index of tableInfo.indexes) {
|
|
111
|
+
const indexRecord = index;
|
|
112
|
+
const indexType = indexRecord['unique'] ? 'UNIQUE INDEX' : 'INDEX';
|
|
113
|
+
const columns = indexRecord['columns'];
|
|
114
|
+
const columnNames = columns.map(col => col['name']).join(', ');
|
|
115
|
+
output += `- ${indexRecord['name']} (${indexType}) on (${columnNames})\n`;
|
|
116
|
+
}
|
|
117
|
+
output += '\n';
|
|
118
|
+
}
|
|
119
|
+
else if (includeIndexes) {
|
|
120
|
+
output += 'No indexes found.\n\n';
|
|
121
|
+
}
|
|
122
|
+
// Display foreign keys if requested and available
|
|
123
|
+
if (includeForeignKeys && tableInfo.foreignKeys.length > 0) {
|
|
124
|
+
output += 'Foreign Keys:\n';
|
|
125
|
+
for (const fk of tableInfo.foreignKeys) {
|
|
126
|
+
const fkRecord = fk;
|
|
127
|
+
output += `- ${fkRecord['from']} → ${fkRecord['table']}.${fkRecord['to']} (${fkRecord['on_update']}/${fkRecord['on_delete']})\n`;
|
|
128
|
+
}
|
|
129
|
+
output += '\n';
|
|
130
|
+
}
|
|
131
|
+
else if (includeForeignKeys) {
|
|
132
|
+
output += 'No foreign keys found.\n\n';
|
|
133
|
+
}
|
|
134
|
+
output += `${metrics}`;
|
|
135
|
+
return {
|
|
136
|
+
content: [
|
|
137
|
+
{
|
|
138
|
+
type: 'text',
|
|
139
|
+
text: output
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
146
|
+
return {
|
|
147
|
+
content: [
|
|
148
|
+
{
|
|
149
|
+
type: 'text',
|
|
150
|
+
text: `Error describing table: ${errorMessage}`
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
isError: true
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Sanitize table name for safe use in PRAGMA queries
|
|
159
|
+
*/
|
|
160
|
+
sanitizeTableName(tableName) {
|
|
161
|
+
// Remove quotes if present and validate
|
|
162
|
+
return tableName.replace(/^["'`[]|["'`]]$/g, '');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=describe-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-table.js","sourceRoot":"","sources":["../../src/tools/describe-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuD,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAA2B,MAAM,8BAA8B,CAAC;AAEjG,MAAM,OAAO,iBAAkB,SAAQ,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AK,CAAC;gBACnI,CAAC;gBACD,MAAM,IAAI,IAAI,CAAC;YACjB,CAAC;iBAAM,IAAI,kBAAkB,EAAE,CAAC;gBAC9B,MAAM,IAAI,4BAA4B,CAAC;YACzC,CAAC;YAED,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;YAEvB,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,MAAM;qBACb;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,2BAA2B,YAAY,EAAE;qBAChD;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,SAAiB;QACzC,wCAAwC;QACxC,OAAO,SAAS,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseTool, type ToolExecutionContext, type ToolExecutionResult } from '../lib/base-tool.js';
|
|
2
|
+
export declare class ListTablesTool extends BaseTool {
|
|
3
|
+
readonly name = "list-tables";
|
|
4
|
+
readonly description = "List all tables, views, and indexes in the libSQL database with optional filtering and detailed information. Supports multiple output formats and pattern matching.";
|
|
5
|
+
readonly inputSchema: import("zod").ZodObject<{
|
|
6
|
+
includeSystemTables: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
|
|
7
|
+
includeViews: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
|
|
8
|
+
includeIndexes: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
|
|
9
|
+
includeDetails: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
|
|
10
|
+
pattern: import("zod").ZodOptional<import("zod").ZodString>;
|
|
11
|
+
format: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodEnum<["table", "json", "list"]>>>;
|
|
12
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
13
|
+
includeSystemTables: boolean;
|
|
14
|
+
includeViews: boolean;
|
|
15
|
+
includeIndexes: boolean;
|
|
16
|
+
includeDetails: boolean;
|
|
17
|
+
format: "table" | "json" | "list";
|
|
18
|
+
pattern?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
pattern?: string | undefined;
|
|
21
|
+
includeSystemTables?: boolean | undefined;
|
|
22
|
+
includeViews?: boolean | undefined;
|
|
23
|
+
includeIndexes?: boolean | undefined;
|
|
24
|
+
includeDetails?: boolean | undefined;
|
|
25
|
+
format?: "table" | "json" | "list" | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
protected executeImpl(context: ToolExecutionContext): Promise<ToolExecutionResult>;
|
|
28
|
+
private getSchemaObjects;
|
|
29
|
+
private formatAsTable;
|
|
30
|
+
private formatAsList;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=list-tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-tables.d.ts","sourceRoot":"","sources":["../../src/tools/list-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAIpG,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,yKACoJ;IACxK,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;OAAyB;cAE7B,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAqE1E,gBAAgB;IAwE9B,OAAO,CAAC,aAAa;IAyDrB,OAAO,CAAC,YAAY;CA2CrB"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { BaseTool } from '../lib/base-tool.js';
|
|
2
|
+
import { formatPerformanceMetrics } from '../utils/performance.js';
|
|
3
|
+
import { ListTablesInputSchema } from '../schemas/list-tables.js';
|
|
4
|
+
export class ListTablesTool extends BaseTool {
|
|
5
|
+
name = 'list-tables';
|
|
6
|
+
description = 'List all tables, views, and indexes in the libSQL database with optional filtering and detailed information. Supports multiple output formats and pattern matching.';
|
|
7
|
+
inputSchema = ListTablesInputSchema;
|
|
8
|
+
async executeImpl(context) {
|
|
9
|
+
const { includeSystemTables, includeViews, includeIndexes, includeDetails, pattern, format } = context.arguments;
|
|
10
|
+
try {
|
|
11
|
+
const startTime = Date.now();
|
|
12
|
+
// Build the query based on options
|
|
13
|
+
const objects = await this.getSchemaObjects(context, {
|
|
14
|
+
includeSystemTables,
|
|
15
|
+
includeViews,
|
|
16
|
+
includeIndexes,
|
|
17
|
+
...(pattern && { pattern })
|
|
18
|
+
});
|
|
19
|
+
const executionTime = Date.now() - startTime;
|
|
20
|
+
if (format === 'json') {
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: 'text',
|
|
25
|
+
text: JSON.stringify({
|
|
26
|
+
objects,
|
|
27
|
+
metadata: {
|
|
28
|
+
totalCount: objects.length,
|
|
29
|
+
executionTime,
|
|
30
|
+
timestamp: new Date().toISOString(),
|
|
31
|
+
filters: {
|
|
32
|
+
includeSystemTables,
|
|
33
|
+
includeViews,
|
|
34
|
+
includeIndexes,
|
|
35
|
+
pattern
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}, null, 2)
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const metrics = formatPerformanceMetrics({
|
|
44
|
+
executionTime,
|
|
45
|
+
rowsReturned: objects.length
|
|
46
|
+
});
|
|
47
|
+
if (format === 'table' || includeDetails) {
|
|
48
|
+
return this.formatAsTable(objects, metrics);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return this.formatAsList(objects, metrics);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
56
|
+
return {
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: 'text',
|
|
60
|
+
text: `Error listing database objects: ${errorMessage}`
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
isError: true
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async getSchemaObjects(context, options) {
|
|
68
|
+
const types = ['table'];
|
|
69
|
+
if (options.includeViews)
|
|
70
|
+
types.push('view');
|
|
71
|
+
if (options.includeIndexes)
|
|
72
|
+
types.push('index');
|
|
73
|
+
const whereConditions = [`type IN (${types.map(() => '?').join(', ')})`];
|
|
74
|
+
const params = [...types];
|
|
75
|
+
// System tables filter
|
|
76
|
+
if (!options.includeSystemTables) {
|
|
77
|
+
whereConditions.push("name NOT LIKE 'sqlite_%'");
|
|
78
|
+
}
|
|
79
|
+
// Pattern filter
|
|
80
|
+
if (options.pattern) {
|
|
81
|
+
whereConditions.push('name LIKE ?');
|
|
82
|
+
params.push(options.pattern);
|
|
83
|
+
}
|
|
84
|
+
const query = `
|
|
85
|
+
SELECT name, type, sql
|
|
86
|
+
FROM sqlite_master
|
|
87
|
+
WHERE ${whereConditions.join(' AND ')}
|
|
88
|
+
ORDER BY type, name
|
|
89
|
+
`;
|
|
90
|
+
const result = await context.connection.execute(query, params);
|
|
91
|
+
const objects = [];
|
|
92
|
+
for (const row of result.rows) {
|
|
93
|
+
const rowRecord = row;
|
|
94
|
+
const obj = {
|
|
95
|
+
name: rowRecord['name'],
|
|
96
|
+
type: rowRecord['type'],
|
|
97
|
+
sql: rowRecord['sql'],
|
|
98
|
+
rowCount: null,
|
|
99
|
+
columnCount: null
|
|
100
|
+
};
|
|
101
|
+
// Get additional details for tables if requested
|
|
102
|
+
if (rowRecord['type'] === 'table') {
|
|
103
|
+
try {
|
|
104
|
+
// Get row count
|
|
105
|
+
const countQuery = `SELECT COUNT(*) as count FROM "${rowRecord['name']}"`;
|
|
106
|
+
const countResult = await context.connection.execute(countQuery);
|
|
107
|
+
obj['rowCount'] = countResult.rows[0]?.['count'] || 0;
|
|
108
|
+
// Get column count
|
|
109
|
+
const columnsQuery = `PRAGMA table_info("${rowRecord['name']}")`;
|
|
110
|
+
const columnsResult = await context.connection.execute(columnsQuery);
|
|
111
|
+
obj['columnCount'] = columnsResult.rows.length;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// If we can't get details, continue without them
|
|
115
|
+
obj['rowCount'] = null;
|
|
116
|
+
obj['columnCount'] = null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
objects.push(obj);
|
|
120
|
+
}
|
|
121
|
+
return objects;
|
|
122
|
+
}
|
|
123
|
+
formatAsTable(objects, metrics) {
|
|
124
|
+
let output = 'Database Schema Objects:\n\n';
|
|
125
|
+
if (objects.length === 0) {
|
|
126
|
+
output += 'No objects found matching the criteria.\n';
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
output +=
|
|
130
|
+
'┌─────────────────────┬─────────┬───────┬─────────┬──────────────────────────────────────┐\n';
|
|
131
|
+
output +=
|
|
132
|
+
'│ Name │ Type │ Rows │ Columns │ Description │\n';
|
|
133
|
+
output +=
|
|
134
|
+
'├─────────────────────┼─────────┼───────┼─────────┼──────────────────────────────────────┤\n';
|
|
135
|
+
for (const obj of objects) {
|
|
136
|
+
const name = String(obj['name'] || '').padEnd(19);
|
|
137
|
+
const type = String(obj['type'] || '').padEnd(7);
|
|
138
|
+
const rowCount = obj['rowCount'] !== null ? String(obj['rowCount']).padEnd(5) : 'N/A'.padEnd(5);
|
|
139
|
+
const columnCount = obj['columnCount'] !== null ? String(obj['columnCount']).padEnd(7) : 'N/A'.padEnd(7);
|
|
140
|
+
// Extract a brief description from SQL
|
|
141
|
+
let description = '';
|
|
142
|
+
const sqlValue = obj['sql'];
|
|
143
|
+
if (sqlValue && typeof sqlValue === 'string') {
|
|
144
|
+
const match = sqlValue.match(/CREATE\s+(TABLE|VIEW|INDEX)\s+[^(]+(\([^)]*\))?/i);
|
|
145
|
+
if (match) {
|
|
146
|
+
description = match[0].replace(/\s+/g, ' ').substring(0, 36);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
description = description.padEnd(36);
|
|
150
|
+
output += `│ ${name} │ ${type} │ ${rowCount} │ ${columnCount} │ ${description} │\n`;
|
|
151
|
+
}
|
|
152
|
+
output +=
|
|
153
|
+
'└─────────────────────┴─────────┴───────┴─────────┴──────────────────────────────────────┘\n\n';
|
|
154
|
+
// Summary
|
|
155
|
+
const objectArray = objects;
|
|
156
|
+
const tableCount = objectArray.filter(o => o['type'] === 'table').length;
|
|
157
|
+
const viewCount = objectArray.filter(o => o['type'] === 'view').length;
|
|
158
|
+
const indexCount = objectArray.filter(o => o['type'] === 'index').length;
|
|
159
|
+
output += `Summary: ${tableCount} tables, ${viewCount} views, ${indexCount} indexes\n`;
|
|
160
|
+
}
|
|
161
|
+
output += `\n${metrics}`;
|
|
162
|
+
return {
|
|
163
|
+
content: [
|
|
164
|
+
{
|
|
165
|
+
type: 'text',
|
|
166
|
+
text: output
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
formatAsList(objects, metrics) {
|
|
172
|
+
let output = 'Database Objects:\n\n';
|
|
173
|
+
if (objects.length === 0) {
|
|
174
|
+
output += 'No objects found matching the criteria.\n';
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const groupedObjects = objects.reduce((acc, obj) => {
|
|
178
|
+
const type = String(obj['type']);
|
|
179
|
+
if (!acc[type])
|
|
180
|
+
acc[type] = [];
|
|
181
|
+
acc[type].push(obj);
|
|
182
|
+
return acc;
|
|
183
|
+
}, {});
|
|
184
|
+
for (const [type, items] of Object.entries(groupedObjects)) {
|
|
185
|
+
const typedItems = items;
|
|
186
|
+
// Handle proper pluralization
|
|
187
|
+
const pluralType = type === 'index' ? 'INDEXES' : `${type.toUpperCase()}S`;
|
|
188
|
+
output += `${pluralType} (${typedItems.length}):\n`;
|
|
189
|
+
for (const item of typedItems) {
|
|
190
|
+
output += `- ${item['name']}`;
|
|
191
|
+
if (item['rowCount'] !== null && item['rowCount'] !== undefined) {
|
|
192
|
+
output += ` (${item['rowCount']} rows)`;
|
|
193
|
+
}
|
|
194
|
+
output += '\n';
|
|
195
|
+
}
|
|
196
|
+
output += '\n';
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
output += `${metrics}`;
|
|
200
|
+
return {
|
|
201
|
+
content: [
|
|
202
|
+
{
|
|
203
|
+
type: 'text',
|
|
204
|
+
text: output
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=list-tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-tables.js","sourceRoot":"","sources":["../../src/tools/list-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuD,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAwB,MAAM,2BAA2B,CAAC;AAExF,MAAM,OAAO,cAAe,SAAQ,QAAQ;IACjC,IAAI,GAAG,aAAa,CAAC;IACrB,WAAW,GAClB,qKAAqK,CAAC;IAC/J,WAAW,GAAG,qBAAqB,CAAC;IAEnC,KAAK,CAAC,WAAW,CAAC,OAA6B;QACvD,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,E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,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM;iBACb;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseTool, type ToolExecutionContext, type ToolExecutionResult } from '../lib/base-tool.js';
|
|
2
|
+
export declare class ReadQueryTool extends BaseTool {
|
|
3
|
+
readonly name = "read-query";
|
|
4
|
+
readonly description = "Execute SELECT queries on the libSQL database";
|
|
5
|
+
readonly inputSchema: import("zod").ZodObject<{
|
|
6
|
+
query: import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, string, string>, string, string>, string, string>;
|
|
7
|
+
parameters: import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean, import("zod").ZodNull]>, "many">>>, (string | number | boolean | null)[], (string | number | boolean | null)[] | undefined>;
|
|
8
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
9
|
+
query: string;
|
|
10
|
+
parameters: (string | number | boolean | null)[];
|
|
11
|
+
}, {
|
|
12
|
+
query: string;
|
|
13
|
+
parameters?: (string | number | boolean | null)[] | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
protected executeImpl(context: ToolExecutionContext): Promise<ToolExecutionResult>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=read-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-query.d.ts","sourceRoot":"","sources":["../../src/tools/read-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAMpG,qBAAa,aAAc,SAAQ,QAAQ;IACzC,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,WAAW,mDAAmD;IACvE,QAAQ,CAAC,WAAW;;;;;;;;;OAAwB;cAE5B,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAwHzF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { BaseTool } from '../lib/base-tool.js';
|
|
2
|
+
import { formatPerformanceMetrics } from '../utils/performance.js';
|
|
3
|
+
import { ReadQueryInputSchema } from '../schemas/read-query.js';
|
|
4
|
+
import { DEFAULT_CONFIG } from '../lib/constants.js';
|
|
5
|
+
export class ReadQueryTool extends BaseTool {
|
|
6
|
+
name = 'read-query';
|
|
7
|
+
description = 'Execute SELECT queries on the libSQL database';
|
|
8
|
+
inputSchema = ReadQueryInputSchema;
|
|
9
|
+
async executeImpl(context) {
|
|
10
|
+
const { query, parameters } = context.arguments;
|
|
11
|
+
try {
|
|
12
|
+
const startTime = Date.now();
|
|
13
|
+
// Execute query with timeout handling
|
|
14
|
+
const result = await Promise.race([
|
|
15
|
+
parameters && parameters.length > 0
|
|
16
|
+
? context.connection.execute(query, parameters)
|
|
17
|
+
: context.connection.execute(query),
|
|
18
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`Query timeout after ${DEFAULT_CONFIG.queryTimeout}ms`)), DEFAULT_CONFIG.queryTimeout))
|
|
19
|
+
]);
|
|
20
|
+
const executionTime = Date.now() - startTime;
|
|
21
|
+
// Check result size limit
|
|
22
|
+
if (result.rows.length > DEFAULT_CONFIG.maxResultSize) {
|
|
23
|
+
return {
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: 'text',
|
|
27
|
+
text: `Error: Query result too large (${result.rows.length} rows, max ${DEFAULT_CONFIG.maxResultSize})`
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
isError: true
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const metrics = formatPerformanceMetrics({
|
|
34
|
+
executionTime,
|
|
35
|
+
rowsReturned: result.rows.length
|
|
36
|
+
});
|
|
37
|
+
// Format the results
|
|
38
|
+
let output = 'Query executed successfully\n\n';
|
|
39
|
+
if (result.rows.length === 0) {
|
|
40
|
+
output += 'No rows returned.\n';
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Format as a table
|
|
44
|
+
const columns = result.columns || [];
|
|
45
|
+
output += `Found ${result.rows.length} row(s):\n\n`;
|
|
46
|
+
if (columns.length > 0) {
|
|
47
|
+
// Calculate column widths for better formatting
|
|
48
|
+
const columnWidths = columns.map((col) => {
|
|
49
|
+
const headerWidth = col.length;
|
|
50
|
+
const maxDataWidth = Math.max(...result.rows.slice(0, 100).map((row) => {
|
|
51
|
+
const value = row[col];
|
|
52
|
+
return value === null ? 4 : String(value).length; // 4 for 'NULL'
|
|
53
|
+
}));
|
|
54
|
+
return Math.max(headerWidth, maxDataWidth, 3); // Minimum 3 chars
|
|
55
|
+
});
|
|
56
|
+
// Add column headers with proper spacing
|
|
57
|
+
const headerRow = columns.map((col, i) => col.padEnd(columnWidths[i] || 0)).join(' | ');
|
|
58
|
+
output += `${headerRow}\n`;
|
|
59
|
+
// Add separator
|
|
60
|
+
const separator = columnWidths.map((width) => '-'.repeat(width)).join('-+-');
|
|
61
|
+
output += `${separator}\n`;
|
|
62
|
+
// Add rows (limit to first 100 rows for display)
|
|
63
|
+
const displayRows = result.rows.slice(0, 100);
|
|
64
|
+
for (const row of displayRows) {
|
|
65
|
+
const rowValues = columns.map((col, i) => {
|
|
66
|
+
const value = row[col];
|
|
67
|
+
const displayValue = value === null ? 'NULL' : String(value);
|
|
68
|
+
return displayValue.padEnd(columnWidths[i] || 0);
|
|
69
|
+
});
|
|
70
|
+
output += `${rowValues.join(' | ')}\n`;
|
|
71
|
+
}
|
|
72
|
+
if (result.rows.length > 100) {
|
|
73
|
+
output += `\n... and ${result.rows.length - 100} more rows (use LIMIT clause to see more)\n`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// Fallback for queries without column metadata
|
|
78
|
+
output += JSON.stringify(result.rows.slice(0, 10), null, 2);
|
|
79
|
+
if (result.rows.length > 10) {
|
|
80
|
+
output += `\n... and ${result.rows.length - 10} more rows\n`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
output += `\nPerformance: ${metrics}`;
|
|
85
|
+
// Add query info if parameters were used
|
|
86
|
+
if (parameters && parameters.length > 0) {
|
|
87
|
+
output += `\nParameters: ${parameters.length} parameter(s) used`;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
content: [
|
|
91
|
+
{
|
|
92
|
+
type: 'text',
|
|
93
|
+
text: output
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
100
|
+
return {
|
|
101
|
+
content: [
|
|
102
|
+
{
|
|
103
|
+
type: 'text',
|
|
104
|
+
text: `Error executing query: ${errorMessage}`
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
isError: true
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=read-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-query.js","sourceRoot":"","sources":["../../src/tools/read-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuD,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAuB,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,MAAM,OAAO,aAAc,SAAQ,QAAQ;IAChC,IAAI,GAAG,YAAY,CAAC;IACpB,WAAW,GAAG,+CAA+C,CAAC;IAC9D,WAAW,GAAG,oBAAoB,CAAC;IAElC,KAAK,CAAC,WAAW,CAAC,OAA6B;QACvD,MAAM,EA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Ac,CAAC;oBAC/D,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,IAAI,kBAAkB,OAAO,EAAE,CAAC;YAEtC,yCAAyC;YACzC,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxC,MAAM,IAAI,iBAAiB,UAAU,CAAC,MAAM,oBAAoB,CAAC;YACnE,CAAC;YAED,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,MAAM;qBACb;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,0BAA0B,YAAY,EAAE;qBAC/C;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseTool, type ToolExecutionContext, type ToolExecutionResult } from '../lib/base-tool.js';
|
|
2
|
+
export declare class WriteQueryTool extends BaseTool {
|
|
3
|
+
readonly name = "write-query";
|
|
4
|
+
readonly description = "Execute INSERT, UPDATE, DELETE queries on the libSQL database. Returns affected row count and performance metrics. Supports parameterized queries for security.";
|
|
5
|
+
readonly inputSchema: import("zod").ZodObject<{
|
|
6
|
+
query: import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, string, string>, string, string>;
|
|
7
|
+
parameters: import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean, import("zod").ZodNull]>, "many">>>, (string | number | boolean | null)[], (string | number | boolean | null)[] | undefined>;
|
|
8
|
+
useTransaction: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
|
|
9
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
10
|
+
query: string;
|
|
11
|
+
parameters: (string | number | boolean | null)[];
|
|
12
|
+
useTransaction: boolean;
|
|
13
|
+
}, {
|
|
14
|
+
query: string;
|
|
15
|
+
parameters?: (string | number | boolean | null)[] | undefined;
|
|
16
|
+
useTransaction?: boolean | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
protected executeImpl(context: ToolExecutionContext): Promise<ToolExecutionResult>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=write-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-query.d.ts","sourceRoot":"","sources":["../../src/tools/write-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAIpG,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,qKACgJ;IACpK,QAAQ,CAAC,WAAW;;;;;;;;;;;;OAAyB;cAE7B,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA6DzF"}
|