@mcp-consultant-tools/azure-sql 27.0.0 → 28.0.0-beta.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.
Files changed (71) hide show
  1. package/build/cli/commands/connection-commands.d.ts +7 -0
  2. package/build/cli/commands/connection-commands.d.ts.map +1 -0
  3. package/build/cli/commands/connection-commands.js +64 -0
  4. package/build/cli/commands/connection-commands.js.map +1 -0
  5. package/build/cli/commands/index.d.ts +9 -0
  6. package/build/cli/commands/index.d.ts.map +1 -0
  7. package/build/cli/commands/index.js +12 -0
  8. package/build/cli/commands/index.js.map +1 -0
  9. package/build/cli/commands/query-commands.d.ts +7 -0
  10. package/build/cli/commands/query-commands.d.ts.map +1 -0
  11. package/build/cli/commands/query-commands.js +149 -0
  12. package/build/cli/commands/query-commands.js.map +1 -0
  13. package/build/cli/output.d.ts +11 -0
  14. package/build/cli/output.d.ts.map +1 -0
  15. package/build/cli/output.js +10 -0
  16. package/build/cli/output.js.map +1 -0
  17. package/build/cli.d.ts +9 -0
  18. package/build/cli.d.ts.map +1 -0
  19. package/build/cli.js +27 -0
  20. package/build/cli.js.map +1 -0
  21. package/build/context-factory.d.ts +10 -0
  22. package/build/context-factory.d.ts.map +1 -0
  23. package/build/context-factory.js +61 -0
  24. package/build/context-factory.js.map +1 -0
  25. package/build/index.d.ts +15 -2
  26. package/build/index.d.ts.map +1 -1
  27. package/build/index.js +40 -491
  28. package/build/index.js.map +1 -1
  29. package/build/prompts/index.d.ts +4 -0
  30. package/build/prompts/index.d.ts.map +1 -0
  31. package/build/prompts/index.js +6 -0
  32. package/build/prompts/index.js.map +1 -0
  33. package/build/prompts/templates.d.ts +3 -0
  34. package/build/prompts/templates.d.ts.map +1 -0
  35. package/build/prompts/templates.js +81 -0
  36. package/build/prompts/templates.js.map +1 -0
  37. package/build/services/connection-service.d.ts +132 -0
  38. package/build/services/connection-service.d.ts.map +1 -0
  39. package/build/services/connection-service.js +350 -0
  40. package/build/services/connection-service.js.map +1 -0
  41. package/build/services/index.d.ts +5 -0
  42. package/build/services/index.d.ts.map +1 -0
  43. package/build/services/index.js +3 -0
  44. package/build/services/index.js.map +1 -0
  45. package/build/services/query-service.d.ts +119 -0
  46. package/build/services/query-service.d.ts.map +1 -0
  47. package/build/services/query-service.js +355 -0
  48. package/build/services/query-service.js.map +1 -0
  49. package/build/tool-examples.d.ts +22 -0
  50. package/build/tool-examples.d.ts.map +1 -0
  51. package/build/tool-examples.js +27 -0
  52. package/build/tool-examples.js.map +1 -0
  53. package/build/tools/connection-tools.d.ts +3 -0
  54. package/build/tools/connection-tools.d.ts.map +1 -0
  55. package/build/tools/connection-tools.js +132 -0
  56. package/build/tools/connection-tools.js.map +1 -0
  57. package/build/tools/index.d.ts +5 -0
  58. package/build/tools/index.d.ts.map +1 -0
  59. package/build/tools/index.js +9 -0
  60. package/build/tools/index.js.map +1 -0
  61. package/build/tools/query-tools.d.ts +3 -0
  62. package/build/tools/query-tools.d.ts.map +1 -0
  63. package/build/tools/query-tools.js +272 -0
  64. package/build/tools/query-tools.js.map +1 -0
  65. package/build/types.d.ts +11 -0
  66. package/build/types.d.ts.map +1 -0
  67. package/build/types.js +2 -0
  68. package/build/types.js.map +1 -0
  69. package/build/utils/sql-formatters.d.ts +2 -1
  70. package/build/utils/sql-formatters.d.ts.map +1 -1
  71. package/package.json +5 -3
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Connection CLI Commands - 4 commands mapping to connection MCP tools
3
+ */
4
+ import type { Command } from 'commander';
5
+ import type { ServiceContext } from '../../types.js';
6
+ export declare function registerConnectionCommands(program: Command, ctx: ServiceContext): void;
7
+ //# sourceMappingURL=connection-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-commands.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/connection-commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CA6DtF"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Connection CLI Commands - 4 commands mapping to connection MCP tools
3
+ */
4
+ import { getGlobalFlags, handleCliError } from '@mcp-consultant-tools/core';
5
+ import { outputResult } from '../output.js';
6
+ export function registerConnectionCommands(program, ctx) {
7
+ const conn = program.command('connection').description('Connection and server operations');
8
+ conn
9
+ .command('list-servers')
10
+ .description('List all configured SQL servers')
11
+ .action(async () => {
12
+ try {
13
+ const servers = await ctx.connection.listServers();
14
+ outputResult({ fileName: 'sql-servers', data: servers, summary: `Found ${servers.length} configured SQL server(s)` }, getGlobalFlags(program));
15
+ }
16
+ catch (error) {
17
+ handleCliError(error, 'list servers');
18
+ }
19
+ });
20
+ conn
21
+ .command('list-databases')
22
+ .description('List databases on a SQL server')
23
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
24
+ .action(async (opts) => {
25
+ try {
26
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
27
+ const databases = await ctx.connection.listDatabases(resolvedServerId);
28
+ outputResult({ fileName: `sql-databases-${resolvedServerId}`, data: databases, summary: `Found ${databases.length} database(s) on server '${resolvedServerId}'` }, getGlobalFlags(program));
29
+ }
30
+ catch (error) {
31
+ handleCliError(error, 'list databases');
32
+ }
33
+ });
34
+ conn
35
+ .command('get-defaults')
36
+ .description('Get the default server and database configuration')
37
+ .action(async () => {
38
+ try {
39
+ const defaults = ctx.connection.getDefaultConfiguration();
40
+ outputResult({ fileName: 'sql-defaults', data: defaults, summary: `Default: server='${defaults.defaultServerId}', database='${defaults.defaultDatabase}'` }, getGlobalFlags(program));
41
+ }
42
+ catch (error) {
43
+ handleCliError(error, 'get defaults');
44
+ }
45
+ });
46
+ conn
47
+ .command('test')
48
+ .description('Test SQL Server connectivity and return connection information')
49
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
50
+ .option('-d, --database <name>', 'Database name (omit for default)')
51
+ .action(async (opts) => {
52
+ try {
53
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
54
+ const resolvedDatabase = ctx.connection.resolveDatabase(resolvedServerId, opts.database);
55
+ const result = await ctx.connection.testConnection(resolvedServerId, resolvedDatabase);
56
+ const status = result.connected ? 'Connected' : 'Failed';
57
+ outputResult({ fileName: `sql-test-${resolvedServerId}`, data: result, summary: `Connection test: ${status} to ${result.server}/${result.database}` }, getGlobalFlags(program));
58
+ }
59
+ catch (error) {
60
+ handleCliError(error, 'test connection');
61
+ }
62
+ });
63
+ }
64
+ //# sourceMappingURL=connection-commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-commands.js","sourceRoot":"","sources":["../../../src/cli/commands/connection-commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,0BAA0B,CAAC,OAAgB,EAAE,GAAmB;IAC9E,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC,CAAC;IAE3F,IAAI;SACD,OAAO,CAAC,cAAc,CAAC;SACvB,WAAW,CAAC,iCAAiC,CAAC;SAC9C,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;YACnD,YAAY,CACV,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,OAAO,CAAC,MAAM,2BAA2B,EAAE,EACvG,cAAc,CAAC,OAAO,CAAC,CACxB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,E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AAC,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEL,IAAI;SACD,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,gEAAgE,CAAC;SAC7E,MAAM,CAAC,sBAAsB,EAAE,8BAA8B,CAAC;SAC9D,MAAM,CAAC,uBAAuB,EAAE,kCAAkC,CAAC;SACnE,MAAM,CAAC,KAAK,EAAE,IAAS,EAAE,EAAE;QAC1B,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvE,MAAM,gBAAgB,GAAG,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;YACvF,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;YACzD,YAAY,CACV,EAAE,QAAQ,EAAE,YAAY,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,MAAM,OAAO,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,EACxI,cAAc,CAAC,OAAO,CAAC,CACxB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAAC,cAAc,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;QAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * CLI Commands barrel export + combined registration
3
+ */
4
+ import type { Command } from 'commander';
5
+ import type { ServiceContext } from '../../types.js';
6
+ export declare function registerAllCommands(program: Command, ctx: ServiceContext): void;
7
+ export { registerQueryCommands } from './query-commands.js';
8
+ export { registerConnectionCommands } from './connection-commands.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIrD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAG/E;AAED,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * CLI Commands barrel export + combined registration
3
+ */
4
+ import { registerQueryCommands } from './query-commands.js';
5
+ import { registerConnectionCommands } from './connection-commands.js';
6
+ export function registerAllCommands(program, ctx) {
7
+ registerQueryCommands(program, ctx);
8
+ registerConnectionCommands(program, ctx);
9
+ }
10
+ export { registerQueryCommands } from './query-commands.js';
11
+ export { registerConnectionCommands } from './connection-commands.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,UAAU,mBAAmB,CAAC,OAAgB,EAAE,GAAmB;IACvE,qBAAqB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACpC,0BAA0B,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Query CLI Commands - 8 commands mapping to query MCP tools
3
+ */
4
+ import type { Command } from 'commander';
5
+ import type { ServiceContext } from '../../types.js';
6
+ export declare function registerQueryCommands(program: Command, ctx: ServiceContext): void;
7
+ //# sourceMappingURL=query-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-commands.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/query-commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAsJjF"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Query CLI Commands - 8 commands mapping to query MCP tools
3
+ */
4
+ import { getGlobalFlags, handleCliError } from '@mcp-consultant-tools/core';
5
+ import { outputResult } from '../output.js';
6
+ export function registerQueryCommands(program, ctx) {
7
+ const query = program.command('query').description('Query and schema operations');
8
+ query
9
+ .command('list-tables')
10
+ .description('List all user tables in the database with row counts and sizes')
11
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
12
+ .option('-d, --database <name>', 'Database name (omit for default)')
13
+ .action(async (opts) => {
14
+ try {
15
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
16
+ const resolvedDatabase = ctx.connection.resolveDatabase(resolvedServerId, opts.database);
17
+ const tables = await ctx.query.listTables(resolvedServerId, resolvedDatabase);
18
+ outputResult({ fileName: `sql-tables-${resolvedServerId}-${resolvedDatabase}`, data: tables, summary: `Found ${tables.length} table(s) in ${resolvedServerId}/${resolvedDatabase}` }, getGlobalFlags(program));
19
+ }
20
+ catch (error) {
21
+ handleCliError(error, 'list tables');
22
+ }
23
+ });
24
+ query
25
+ .command('list-views')
26
+ .description('List all views in the database')
27
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
28
+ .option('-d, --database <name>', 'Database name (omit for default)')
29
+ .action(async (opts) => {
30
+ try {
31
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
32
+ const resolvedDatabase = ctx.connection.resolveDatabase(resolvedServerId, opts.database);
33
+ const views = await ctx.query.listViews(resolvedServerId, resolvedDatabase);
34
+ outputResult({ fileName: `sql-views-${resolvedServerId}-${resolvedDatabase}`, data: views, summary: `Found ${views.length} view(s) in ${resolvedServerId}/${resolvedDatabase}` }, getGlobalFlags(program));
35
+ }
36
+ catch (error) {
37
+ handleCliError(error, 'list views');
38
+ }
39
+ });
40
+ query
41
+ .command('list-sprocs')
42
+ .description('List all stored procedures in the database')
43
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
44
+ .option('-d, --database <name>', 'Database name (omit for default)')
45
+ .action(async (opts) => {
46
+ try {
47
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
48
+ const resolvedDatabase = ctx.connection.resolveDatabase(resolvedServerId, opts.database);
49
+ const procedures = await ctx.query.listStoredProcedures(resolvedServerId, resolvedDatabase);
50
+ outputResult({ fileName: `sql-sprocs-${resolvedServerId}-${resolvedDatabase}`, data: procedures, summary: `Found ${procedures.length} stored procedure(s) in ${resolvedServerId}/${resolvedDatabase}` }, getGlobalFlags(program));
51
+ }
52
+ catch (error) {
53
+ handleCliError(error, 'list stored procedures');
54
+ }
55
+ });
56
+ query
57
+ .command('list-triggers')
58
+ .description('List all database triggers in the database')
59
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
60
+ .option('-d, --database <name>', 'Database name (omit for default)')
61
+ .action(async (opts) => {
62
+ try {
63
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
64
+ const resolvedDatabase = ctx.connection.resolveDatabase(resolvedServerId, opts.database);
65
+ const triggers = await ctx.query.listTriggers(resolvedServerId, resolvedDatabase);
66
+ outputResult({ fileName: `sql-triggers-${resolvedServerId}-${resolvedDatabase}`, data: triggers, summary: `Found ${triggers.length} trigger(s) in ${resolvedServerId}/${resolvedDatabase}` }, getGlobalFlags(program));
67
+ }
68
+ catch (error) {
69
+ handleCliError(error, 'list triggers');
70
+ }
71
+ });
72
+ query
73
+ .command('list-functions')
74
+ .description('List all user-defined functions in the database')
75
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
76
+ .option('-d, --database <name>', 'Database name (omit for default)')
77
+ .action(async (opts) => {
78
+ try {
79
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
80
+ const resolvedDatabase = ctx.connection.resolveDatabase(resolvedServerId, opts.database);
81
+ const functions = await ctx.query.listFunctions(resolvedServerId, resolvedDatabase);
82
+ outputResult({ fileName: `sql-functions-${resolvedServerId}-${resolvedDatabase}`, data: functions, summary: `Found ${functions.length} function(s) in ${resolvedServerId}/${resolvedDatabase}` }, getGlobalFlags(program));
83
+ }
84
+ catch (error) {
85
+ handleCliError(error, 'list functions');
86
+ }
87
+ });
88
+ query
89
+ .command('table-schema')
90
+ .description('Get detailed schema information for a table including columns, indexes, and foreign keys')
91
+ .argument('<schemaName>', "Schema name (e.g., 'dbo')")
92
+ .argument('<tableName>', "Table name (e.g., 'Users')")
93
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
94
+ .option('-d, --database <name>', 'Database name (omit for default)')
95
+ .action(async (schemaName, tableName, opts) => {
96
+ try {
97
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
98
+ const resolvedDatabase = ctx.connection.resolveDatabase(resolvedServerId, opts.database);
99
+ const schema = await ctx.query.getTableSchema(resolvedServerId, resolvedDatabase, schemaName, tableName);
100
+ outputResult({ fileName: `sql-schema-${schemaName}-${tableName}`, data: schema, summary: `Schema for ${schemaName}.${tableName}: ${schema.columns?.length ?? 0} column(s), ${schema.indexes?.length ?? 0} index(es), ${schema.foreignKeys?.length ?? 0} FK(s)` }, getGlobalFlags(program));
101
+ }
102
+ catch (error) {
103
+ handleCliError(error, 'get table schema');
104
+ }
105
+ });
106
+ query
107
+ .command('obj-def')
108
+ .description('Get the SQL definition for a view, stored procedure, function, or trigger')
109
+ .argument('<schemaName>', "Schema name (e.g., 'dbo')")
110
+ .argument('<objectName>', 'Object name')
111
+ .argument('<objectType>', 'Object type: VIEW, PROCEDURE, FUNCTION, or TRIGGER')
112
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
113
+ .option('-d, --database <name>', 'Database name (omit for default)')
114
+ .action(async (schemaName, objectName, objectType, opts) => {
115
+ try {
116
+ const validTypes = ['VIEW', 'PROCEDURE', 'FUNCTION', 'TRIGGER'];
117
+ const upperType = objectType.toUpperCase();
118
+ if (!validTypes.includes(upperType)) {
119
+ throw new Error(`Invalid object type '${objectType}'. Must be one of: ${validTypes.join(', ')}`);
120
+ }
121
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
122
+ const resolvedDatabase = ctx.connection.resolveDatabase(resolvedServerId, opts.database);
123
+ const definition = await ctx.query.getObjectDefinition(resolvedServerId, resolvedDatabase, schemaName, objectName, upperType);
124
+ outputResult({ fileName: `sql-def-${schemaName}-${objectName}`, data: definition, summary: `${upperType} definition for ${schemaName}.${objectName}` }, getGlobalFlags(program));
125
+ }
126
+ catch (error) {
127
+ handleCliError(error, 'get object definition');
128
+ }
129
+ });
130
+ query
131
+ .command('execute')
132
+ .description('Execute a SELECT query against Azure SQL Database')
133
+ .argument('<query>', 'SELECT query to execute')
134
+ .option('-s, --server-id <id>', 'Server ID (omit for default)')
135
+ .option('-d, --database <name>', 'Database name (omit for default)')
136
+ .action(async (queryStr, opts) => {
137
+ try {
138
+ const resolvedServerId = ctx.connection.resolveServerId(opts.serverId);
139
+ const resolvedDatabase = ctx.connection.resolveDatabase(resolvedServerId, opts.database);
140
+ const result = await ctx.query.executeSelectQuery(resolvedServerId, resolvedDatabase, queryStr);
141
+ const truncatedMsg = result.truncated ? ' (truncated)' : '';
142
+ outputResult({ fileName: 'sql-query-result', data: result, summary: `Query returned ${result.rowCount} row(s)${truncatedMsg}` }, getGlobalFlags(program));
143
+ }
144
+ catch (error) {
145
+ handleCliError(error, 'execute query');
146
+ }
147
+ });
148
+ }
149
+ //# sourceMappingURL=query-commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-commands.js","sourceRoot":"","sources":["../../../src/cli/commands/query-commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,qBAAqB,CAAC,OAAgB,EAAE,GAAmB;IACzE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAAC;IAElF,KAAK;SACF,OAAO,CAAC,aAAa,CAAC;SACtB,WAAW,CAAC,gEAAgE,CAAC;SAC7E,MAAM,CAAC,sBAAsB,EAAE,8BAA8B,CAAC;SAC9D,MAAM,CAAC,uBAAuB,EAAE,kCAAkC,CAAC;SACnE,MAAM,CAAC,KAAK,EAAE,IAAS,EAAE,EAAE;QAC1B,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvE,MAAM,gBAAgB,GAAG,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;YAC9E,YAAY,CACV,EAAE,QAAQ,EAAE,cAAc,gBAAgB,IAAI,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,CAAC,MAAM,gBAAgB,gBAAgB,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helper for azure-sql package.
3
+ * Thin wrapper setting the package-specific cache directory.
4
+ */
5
+ import { type GlobalFlags } from '@mcp-consultant-tools/core';
6
+ export declare function outputResult(opts: {
7
+ fileName: string;
8
+ data: unknown;
9
+ summary: string;
10
+ }, flags: GlobalFlags): void;
11
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAoC,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIhG,wBAAgB,YAAY,CAC1B,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC1D,KAAK,EAAE,WAAW,GACjB,IAAI,CAEN"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * CLI output helper for azure-sql package.
3
+ * Thin wrapper setting the package-specific cache directory.
4
+ */
5
+ import { outputResult as coreOutputResult } from '@mcp-consultant-tools/core';
6
+ const CACHE_DIR = '.mcp-sql-cache';
7
+ export function outputResult(opts, flags) {
8
+ coreOutputResult({ ...opts, cacheDir: CACHE_DIR }, flags);
9
+ }
10
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAEhG,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC,MAAM,UAAU,YAAY,CAC1B,IAA0D,EAC1D,KAAkB;IAElB,gBAAgB,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC"}
package/build/cli.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @mcp-consultant-tools/azure-sql CLI
4
+ *
5
+ * Command-line interface for Azure SQL Database operations.
6
+ * Reuses the same ServiceContext and services as the MCP server.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
package/build/cli.js ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @mcp-consultant-tools/azure-sql CLI
4
+ *
5
+ * Command-line interface for Azure SQL Database operations.
6
+ * Reuses the same ServiceContext and services as the MCP server.
7
+ */
8
+ import { createCliProgram, loadEnvForCli } from '@mcp-consultant-tools/core';
9
+ import { createServiceContext } from './context-factory.js';
10
+ import { registerAllCommands } from './cli/commands/index.js';
11
+ const program = createCliProgram({
12
+ name: 'mcp-sql-cli',
13
+ description: 'Azure SQL Database CLI - queries and schema exploration',
14
+ version: '28.0.0-beta.7',
15
+ });
16
+ // Load env before parsing (--env-file handled by commander hook)
17
+ program.hook('preAction', (thisCommand) => {
18
+ const opts = thisCommand.opts();
19
+ loadEnvForCli(opts.envFile);
20
+ });
21
+ const ctx = createServiceContext();
22
+ registerAllCommands(program, ctx);
23
+ program.parseAsync(process.argv).catch((error) => {
24
+ console.error('CLI error:', error.message);
25
+ process.exit(1);
26
+ });
27
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,OAAO,GAAG,gBAAgB,CAAC;IAC/B,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,yDAAyD;IACtE,OAAO,EAAE,eAAe;CACzB,CAAC,CAAC;AAEH,iEAAiE;AACjE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,WAAgB,EAAE,EAAE;IAC7C,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;IAChC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;AACnC,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAElC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAU,EAAE,EAAE;IACpD,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shared ServiceContext factory for Azure SQL.
3
+ * Used by both MCP server (index.ts) and CLI (cli.ts).
4
+ */
5
+ import type { ServiceContext } from './types.js';
6
+ /**
7
+ * Build a ServiceContext from environment variables (lazy service initialization).
8
+ */
9
+ export declare function createServiceContext(): ServiceContext;
10
+ //# sourceMappingURL=context-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-factory.d.ts","sourceRoot":"","sources":["../src/context-factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAqDrD"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Shared ServiceContext factory for Azure SQL.
3
+ * Used by both MCP server (index.ts) and CLI (cli.ts).
4
+ */
5
+ import { ConnectionService } from './services/connection-service.js';
6
+ import { QueryService } from './services/query-service.js';
7
+ /**
8
+ * Build a ServiceContext from environment variables (lazy service initialization).
9
+ */
10
+ export function createServiceContext() {
11
+ let connection = null;
12
+ let query = null;
13
+ function getConnection() {
14
+ if (!connection) {
15
+ const missingConfig = [];
16
+ let resources = [];
17
+ if (process.env.AZURE_SQL_SERVERS) {
18
+ try {
19
+ resources = JSON.parse(process.env.AZURE_SQL_SERVERS);
20
+ }
21
+ catch (error) {
22
+ throw new Error("Failed to parse AZURE_SQL_SERVERS JSON");
23
+ }
24
+ }
25
+ else if (process.env.AZURE_SQL_SERVER && process.env.AZURE_SQL_DATABASE) {
26
+ resources = [{
27
+ id: 'default',
28
+ name: 'Default SQL Server',
29
+ server: process.env.AZURE_SQL_SERVER,
30
+ port: parseInt(process.env.AZURE_SQL_PORT || "1433"),
31
+ active: true,
32
+ databases: [{
33
+ name: process.env.AZURE_SQL_DATABASE,
34
+ active: true,
35
+ }],
36
+ username: process.env.AZURE_SQL_USERNAME || '',
37
+ password: process.env.AZURE_SQL_PASSWORD || '',
38
+ }];
39
+ }
40
+ else {
41
+ missingConfig.push("AZURE_SQL_SERVERS or AZURE_SQL_SERVER/AZURE_SQL_DATABASE");
42
+ }
43
+ if (missingConfig.length > 0) {
44
+ throw new Error(`Missing Azure SQL configuration: ${missingConfig.join(", ")}`);
45
+ }
46
+ const config = {
47
+ resources,
48
+ queryTimeout: parseInt(process.env.AZURE_SQL_QUERY_TIMEOUT || "30000"),
49
+ maxResultRows: parseInt(process.env.AZURE_SQL_MAX_RESULT_ROWS || "1000"),
50
+ };
51
+ connection = new ConnectionService(config);
52
+ console.error("Azure SQL service initialized");
53
+ }
54
+ return connection;
55
+ }
56
+ return {
57
+ get connection() { return getConnection(); },
58
+ get query() { return query ??= new QueryService(getConnection()); },
59
+ };
60
+ }
61
+ //# sourceMappingURL=context-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-factory.js","sourceRoot":"","sources":["../src/context-factory.ts"],"names":[],"mappings":"AAAA;;;GAG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CAAC;iBAAM,CAAC;gBACN,aAAa,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;YACjF,CAAC;YAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CAAC,oCAAoC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClF,CAAC;YAED,MAAM,MAAM,GAAmB;gBAC7B,SAAS;gBACT,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,OAAO,CAAC;gBACtE,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,MAAM,CAAC;aACzE,CAAC;YAEF,UAAU,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAC3C,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO;QACL,IAAI,UAAU,KAAK,OAAO,aAAa,EAAE,CAAC,CAAC,CAAC;QAC5C,IAAI,KAAK,KAAK,OAAO,KAAK,KAAK,IAAI,YAAY,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC;KACpE,CAAC;AACJ,CAAC"}
package/build/index.d.ts CHANGED
@@ -1,4 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { AzureSqlService } from "./AzureSqlService.js";
3
- export declare function registerAzureSqlTools(server: any, azuresqlService?: AzureSqlService): void;
2
+ /**
3
+ * @mcp-consultant-tools/azure-sql
4
+ *
5
+ * MCP server for Azure SQL Database integration.
6
+ * Entry point: MCP server startup + backward-compatible registerAzureSqlTools().
7
+ */
8
+ /**
9
+ * Register Azure SQL tools and prompts to an MCP server.
10
+ * Backward-compatible API for the meta package.
11
+ */
12
+ export declare function registerAzureSqlTools(server: any): void;
13
+ export { ConnectionService } from './services/connection-service.js';
14
+ export { QueryService } from './services/query-service.js';
15
+ export type { AzureSqlConfig } from './services/connection-service.js';
16
+ export type { ServiceContext } from './types.js';
4
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,eAAe,QAmnBnF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAwEH;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAIvD;AAGD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,YAAY,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}