fms-odata-mcp 0.1.2

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +154 -0
  3. package/dist/config.d.ts +104 -0
  4. package/dist/config.d.ts.map +1 -0
  5. package/dist/config.js +248 -0
  6. package/dist/config.js.map +1 -0
  7. package/dist/connection.d.ts +49 -0
  8. package/dist/connection.d.ts.map +1 -0
  9. package/dist/connection.js +126 -0
  10. package/dist/connection.js.map +1 -0
  11. package/dist/index.d.ts +7 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +90 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/logger.d.ts +15 -0
  16. package/dist/logger.d.ts.map +1 -0
  17. package/dist/logger.js +57 -0
  18. package/dist/logger.js.map +1 -0
  19. package/dist/odata-client.d.ts +102 -0
  20. package/dist/odata-client.d.ts.map +1 -0
  21. package/dist/odata-client.js +226 -0
  22. package/dist/odata-client.js.map +1 -0
  23. package/dist/odata-parser.d.ts +64 -0
  24. package/dist/odata-parser.d.ts.map +1 -0
  25. package/dist/odata-parser.js +126 -0
  26. package/dist/odata-parser.js.map +1 -0
  27. package/dist/tools/configuration.d.ts +69 -0
  28. package/dist/tools/configuration.d.ts.map +1 -0
  29. package/dist/tools/configuration.js +221 -0
  30. package/dist/tools/configuration.js.map +1 -0
  31. package/dist/tools/connection.d.ts +66 -0
  32. package/dist/tools/connection.d.ts.map +1 -0
  33. package/dist/tools/connection.js +230 -0
  34. package/dist/tools/connection.js.map +1 -0
  35. package/dist/tools/index.d.ts +319 -0
  36. package/dist/tools/index.d.ts.map +1 -0
  37. package/dist/tools/index.js +48 -0
  38. package/dist/tools/index.js.map +1 -0
  39. package/dist/tools/odata.d.ts +233 -0
  40. package/dist/tools/odata.d.ts.map +1 -0
  41. package/dist/tools/odata.js +404 -0
  42. package/dist/tools/odata.js.map +1 -0
  43. package/dist/transport.d.ts +18 -0
  44. package/dist/transport.d.ts.map +1 -0
  45. package/dist/transport.js +138 -0
  46. package/dist/transport.js.map +1 -0
  47. package/package.json +72 -0
@@ -0,0 +1,64 @@
1
+ import { ODataResponse } from "./odata-client.js";
2
+ /**
3
+ * OData Response Parser
4
+ * Formats OData responses for MCP tools
5
+ */
6
+ export declare class ODataParser {
7
+ /**
8
+ * Format OData response for MCP tool output
9
+ */
10
+ static formatResponse(data: any, pretty?: boolean): string;
11
+ /**
12
+ * Format query response with count information
13
+ */
14
+ static formatQueryResponse<T>(response: ODataResponse<T>, includeContext?: boolean): string;
15
+ /**
16
+ * Format single record response
17
+ */
18
+ static formatRecordResponse(record: any): string;
19
+ /**
20
+ * Format metadata response
21
+ */
22
+ static formatMetadata(metadata: string): string;
23
+ /**
24
+ * Format service document
25
+ */
26
+ static formatServiceDocument(serviceDoc: any): string;
27
+ /**
28
+ * Format error for MCP tool
29
+ */
30
+ static formatError(error: Error): string;
31
+ /**
32
+ * Parse OData $metadata XML to extract table information
33
+ */
34
+ static parseMetadataForTables(metadataXml: string): string[];
35
+ /**
36
+ * Parse OData $metadata XML to extract field information for a table
37
+ */
38
+ static parseMetadataForFields(metadataXml: string, tableName: string): FieldInfo[];
39
+ /**
40
+ * Create a summary of query results
41
+ */
42
+ static createQuerySummary(response: ODataResponse): string;
43
+ /**
44
+ * Extract field names from a record
45
+ */
46
+ static extractFieldNames(record: any): string[];
47
+ /**
48
+ * Format batch operation results
49
+ */
50
+ static formatBatchResults(results: BatchResult[]): string;
51
+ }
52
+ export interface FieldInfo {
53
+ name: string;
54
+ type: string;
55
+ nullable: boolean;
56
+ maxLength?: number;
57
+ }
58
+ export interface BatchResult {
59
+ success: boolean;
60
+ status: number;
61
+ data?: any;
62
+ error?: string;
63
+ }
64
+ //# sourceMappingURL=odata-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"odata-parser.d.ts","sourceRoot":"","sources":["../src/odata-parser.ts"],"names":[],"mappings":"AAAA,OAAO,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,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * OData Response Parser
3
+ * Formats OData responses for MCP tools
4
+ */
5
+ export class ODataParser {
6
+ /**
7
+ * Format OData response for MCP tool output
8
+ */
9
+ static formatResponse(data, pretty = true) {
10
+ if (pretty) {
11
+ return JSON.stringify(data, null, 2);
12
+ }
13
+ return JSON.stringify(data);
14
+ }
15
+ /**
16
+ * Format query response with count information
17
+ */
18
+ static formatQueryResponse(response, includeContext = false) {
19
+ const result = {
20
+ count: response["@odata.count"],
21
+ records: response.value,
22
+ };
23
+ if (includeContext) {
24
+ result.context = response["@odata.context"];
25
+ }
26
+ return this.formatResponse(result);
27
+ }
28
+ /**
29
+ * Format single record response
30
+ */
31
+ static formatRecordResponse(record) {
32
+ return this.formatResponse(record);
33
+ }
34
+ /**
35
+ * Format metadata response
36
+ */
37
+ static formatMetadata(metadata) {
38
+ // For XML metadata, we can add formatting hints
39
+ return metadata;
40
+ }
41
+ /**
42
+ * Format service document
43
+ */
44
+ static formatServiceDocument(serviceDoc) {
45
+ return this.formatResponse(serviceDoc);
46
+ }
47
+ /**
48
+ * Format error for MCP tool
49
+ */
50
+ static formatError(error) {
51
+ return `Error: ${error.message}`;
52
+ }
53
+ /**
54
+ * Parse OData $metadata XML to extract table information
55
+ */
56
+ static parseMetadataForTables(metadataXml) {
57
+ const tables = [];
58
+ // Simple regex to extract EntitySet names from metadata
59
+ const entitySetRegex = /<EntitySet\s+Name="([^"]+)"/g;
60
+ let match;
61
+ while ((match = entitySetRegex.exec(metadataXml)) !== null) {
62
+ tables.push(match[1]);
63
+ }
64
+ return tables;
65
+ }
66
+ /**
67
+ * Parse OData $metadata XML to extract field information for a table
68
+ */
69
+ static parseMetadataForFields(metadataXml, tableName) {
70
+ const fields = [];
71
+ // Find the EntityType definition for this table
72
+ const entityTypeRegex = new RegExp(`<EntityType\\s+Name="${tableName}"[^>]*>([\\s\\S]*?)</EntityType>`, "i");
73
+ const entityTypeMatch = metadataXml.match(entityTypeRegex);
74
+ if (entityTypeMatch) {
75
+ const entityTypeContent = entityTypeMatch[1];
76
+ // Extract properties
77
+ const propertyRegex = /<Property\s+Name="([^"]+)"\s+Type="([^"]+)"([^>]*?)\/>/g;
78
+ let match;
79
+ while ((match = propertyRegex.exec(entityTypeContent)) !== null) {
80
+ const name = match[1];
81
+ const type = match[2];
82
+ const attributes = match[3];
83
+ const nullable = !attributes.includes('Nullable="false"');
84
+ const maxLength = attributes.match(/MaxLength="(\d+)"/)?.[1];
85
+ fields.push({
86
+ name,
87
+ type,
88
+ nullable,
89
+ maxLength: maxLength ? parseInt(maxLength) : undefined,
90
+ });
91
+ }
92
+ }
93
+ return fields;
94
+ }
95
+ /**
96
+ * Create a summary of query results
97
+ */
98
+ static createQuerySummary(response) {
99
+ const count = response["@odata.count"];
100
+ const recordsReturned = response.value.length;
101
+ let summary = `Returned ${recordsReturned} record(s)`;
102
+ if (count !== undefined && count !== recordsReturned) {
103
+ summary += ` (${count} total matching records)`;
104
+ }
105
+ return summary;
106
+ }
107
+ /**
108
+ * Extract field names from a record
109
+ */
110
+ static extractFieldNames(record) {
111
+ return Object.keys(record).filter((key) => !key.startsWith("@odata"));
112
+ }
113
+ /**
114
+ * Format batch operation results
115
+ */
116
+ static formatBatchResults(results) {
117
+ const summary = {
118
+ total: results.length,
119
+ successful: results.filter((r) => r.success).length,
120
+ failed: results.filter((r) => !r.success).length,
121
+ results: results,
122
+ };
123
+ return this.formatResponse(summary);
124
+ }
125
+ }
126
+ //# sourceMappingURL=odata-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"odata-parser.js","sourceRoot":"","sources":["../src/odata-parser.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,WAAW;IACtB;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,I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ACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,QAAuB;QAC/C,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;QACvC,MAAM,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;QAE9C,IAAI,OAAO,GAAG,YAAY,eAAe,YAAY,CAAC;QAEtD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,eAAe,EAAE,CAAC;YACrD,OAAO,IAAI,KAAK,KAAK,0BAA0B,CAAC;QAClD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,MAAW;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAC/B,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CACnC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,OAAsB;QAC9C,MAAM,OAAO,GAAG;YACd,KAAK,EAAE,OAAO,CAAC,MAAM;YACrB,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;YACnD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;YAChD,OAAO,EAAE,OAAO;SACjB,CAAC;QAEF,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Configuration Tool Definitions
3
+ */
4
+ export declare const configurationTools: ({
5
+ name: string;
6
+ description: string;
7
+ inputSchema: {
8
+ type: string;
9
+ properties: {
10
+ name: {
11
+ type: string;
12
+ description: string;
13
+ };
14
+ server: {
15
+ type: string;
16
+ description: string;
17
+ };
18
+ database: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ user: {
23
+ type: string;
24
+ description: string;
25
+ };
26
+ password: {
27
+ type: string;
28
+ description: string;
29
+ };
30
+ };
31
+ required: string[];
32
+ };
33
+ } | {
34
+ name: string;
35
+ description: string;
36
+ inputSchema: {
37
+ type: string;
38
+ properties: {
39
+ name: {
40
+ type: string;
41
+ description: string;
42
+ };
43
+ server?: undefined;
44
+ database?: undefined;
45
+ user?: undefined;
46
+ password?: undefined;
47
+ };
48
+ required: string[];
49
+ };
50
+ } | {
51
+ name: string;
52
+ description: string;
53
+ inputSchema: {
54
+ type: string;
55
+ properties: {
56
+ name?: undefined;
57
+ server?: undefined;
58
+ database?: undefined;
59
+ user?: undefined;
60
+ password?: undefined;
61
+ };
62
+ required: never[];
63
+ };
64
+ })[];
65
+ /**
66
+ * Configuration Tool Handlers
67
+ */
68
+ export declare function handleConfigurationTool(name: string, args: any): Promise<any>;
69
+ //# sourceMappingURL=configuration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/tools/configuration.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkF9B,CAAC;AAEF;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CA2CnF"}
@@ -0,0 +1,221 @@
1
+ import { addConnection, removeConnection, listConnections, getConnection, setDefaultConnection, getDefaultConnectionName, } from "../config.js";
2
+ import { logger } from "../logger.js";
3
+ /**
4
+ * Configuration Tool Definitions
5
+ */
6
+ export const configurationTools = [
7
+ {
8
+ name: "fm_odata_config_add_connection",
9
+ description: "Add a new connection configuration (saved permanently)",
10
+ inputSchema: {
11
+ type: "object",
12
+ properties: {
13
+ name: {
14
+ type: "string",
15
+ description: "Connection name (e.g., 'production', 'staging', 'local')",
16
+ },
17
+ server: {
18
+ type: "string",
19
+ description: "FileMaker Server URL (e.g., 'http://192.168.0.24')",
20
+ },
21
+ database: {
22
+ type: "string",
23
+ description: "Database name",
24
+ },
25
+ user: {
26
+ type: "string",
27
+ description: "Username",
28
+ },
29
+ password: {
30
+ type: "string",
31
+ description: "Password",
32
+ },
33
+ },
34
+ required: ["name", "server", "database", "user", "password"],
35
+ },
36
+ },
37
+ {
38
+ name: "fm_odata_config_remove_connection",
39
+ description: "Remove a saved connection configuration",
40
+ inputSchema: {
41
+ type: "object",
42
+ properties: {
43
+ name: {
44
+ type: "string",
45
+ description: "Connection name to remove",
46
+ },
47
+ },
48
+ required: ["name"],
49
+ },
50
+ },
51
+ {
52
+ name: "fm_odata_config_list_connections",
53
+ description: "List all saved connection configurations (passwords masked)",
54
+ inputSchema: {
55
+ type: "object",
56
+ properties: {},
57
+ required: [],
58
+ },
59
+ },
60
+ {
61
+ name: "fm_odata_config_get_connection",
62
+ description: "Get details of a specific saved connection (password masked)",
63
+ inputSchema: {
64
+ type: "object",
65
+ properties: {
66
+ name: {
67
+ type: "string",
68
+ description: "Connection name",
69
+ },
70
+ },
71
+ required: ["name"],
72
+ },
73
+ },
74
+ {
75
+ name: "fm_odata_config_set_default_connection",
76
+ description: "Set the default connection to use",
77
+ inputSchema: {
78
+ type: "object",
79
+ properties: {
80
+ name: {
81
+ type: "string",
82
+ description: "Connection name to set as default",
83
+ },
84
+ },
85
+ required: ["name"],
86
+ },
87
+ },
88
+ ];
89
+ /**
90
+ * Configuration Tool Handlers
91
+ */
92
+ export async function handleConfigurationTool(name, args) {
93
+ try {
94
+ logger.debug(`Handling configuration tool: ${name}`, args);
95
+ switch (name) {
96
+ case "fm_odata_config_add_connection":
97
+ return await handleAddConnection(args);
98
+ case "fm_odata_config_remove_connection":
99
+ return await handleRemoveConnection(args);
100
+ case "fm_odata_config_list_connections":
101
+ return await handleListConnections();
102
+ case "fm_odata_config_get_connection":
103
+ return await handleGetConnection(args);
104
+ case "fm_odata_config_set_default_connection":
105
+ return await handleSetDefaultConnection(args);
106
+ default:
107
+ return {
108
+ content: [
109
+ {
110
+ type: "text",
111
+ text: `Unknown configuration tool: ${name}`,
112
+ },
113
+ ],
114
+ isError: true,
115
+ };
116
+ }
117
+ }
118
+ catch (error) {
119
+ logger.error(`Error in ${name}:`, error);
120
+ return {
121
+ content: [
122
+ {
123
+ type: "text",
124
+ text: `Error: ${error.message}`,
125
+ },
126
+ ],
127
+ isError: true,
128
+ };
129
+ }
130
+ }
131
+ // Configuration Tool Handlers
132
+ async function handleAddConnection(args) {
133
+ addConnection(args.name, {
134
+ server: args.server,
135
+ database: args.database,
136
+ user: args.user,
137
+ password: args.password,
138
+ });
139
+ return {
140
+ content: [
141
+ {
142
+ type: "text",
143
+ text: `Connection "${args.name}" added successfully.\nServer: ${args.server}\nDatabase: ${args.database}\nUser: ${args.user}`,
144
+ },
145
+ ],
146
+ };
147
+ }
148
+ async function handleRemoveConnection(args) {
149
+ removeConnection(args.name);
150
+ return {
151
+ content: [
152
+ {
153
+ type: "text",
154
+ text: `Connection "${args.name}" removed successfully.`,
155
+ },
156
+ ],
157
+ };
158
+ }
159
+ async function handleListConnections() {
160
+ const connections = listConnections();
161
+ if (connections.length === 0) {
162
+ return {
163
+ content: [
164
+ {
165
+ type: "text",
166
+ text: "No saved connections found. Use fm_odata_config_add_connection to add a connection.",
167
+ },
168
+ ],
169
+ };
170
+ }
171
+ const defaultName = getDefaultConnectionName();
172
+ const list = connections
173
+ .map((conn) => {
174
+ const isDefault = conn.name === defaultName ? " (default)" : "";
175
+ return `- ${conn.name}${isDefault}: ${conn.server}/${conn.database} (user: ${conn.user})`;
176
+ })
177
+ .join("\n");
178
+ return {
179
+ content: [
180
+ {
181
+ type: "text",
182
+ text: `Saved connections:\n${list}`,
183
+ },
184
+ ],
185
+ };
186
+ }
187
+ async function handleGetConnection(args) {
188
+ const connection = getConnection(args.name);
189
+ if (!connection) {
190
+ return {
191
+ content: [
192
+ {
193
+ type: "text",
194
+ text: `Connection "${args.name}" not found.`,
195
+ },
196
+ ],
197
+ isError: true,
198
+ };
199
+ }
200
+ const isDefault = connection.name === getDefaultConnectionName() ? " (default)" : "";
201
+ return {
202
+ content: [
203
+ {
204
+ type: "text",
205
+ text: `Connection: ${connection.name}${isDefault}\nServer: ${connection.server}\nDatabase: ${connection.database}\nUser: ${connection.user}\nPassword: ******`,
206
+ },
207
+ ],
208
+ };
209
+ }
210
+ async function handleSetDefaultConnection(args) {
211
+ setDefaultConnection(args.name);
212
+ return {
213
+ content: [
214
+ {
215
+ type: "text",
216
+ text: `Default connection set to: ${args.name}`,
217
+ },
218
+ ],
219
+ };
220
+ }
221
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/tools/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC;QACE,IAAI,EAAE,gCAAgC;QACtC,WAAW,EAAE,wDAAwD;QACrE,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0DAA0D;iBACxE;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,oDAAoD;iBAClE;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,eAAe;iBAC7B;gBACD,IAAI,EAAE;oBACJ,IAAI,EA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U,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE5C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,eAAe,IAAI,CAAC,IAAI,cAAc;iBAC7C;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,KAAK,wBAAwB,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAErF,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,eAAe,UAAU,CAAC,IAAI,GAAG,SAAS,aAAa,UAAU,CAAC,MAAM,eAAe,UAAU,CAAC,QAAQ,WAAW,UAAU,CAAC,IAAI,oBAAoB;aAC/J;SACF;KACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,0BAA0B,CAAC,IAAS;IACjD,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhC,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,8BAA8B,IAAI,CAAC,IAAI,EAAE;aAChD;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Connection Tool Definitions
3
+ */
4
+ export declare const connectionTools: ({
5
+ name: string;
6
+ description: string;
7
+ inputSchema: {
8
+ type: string;
9
+ properties: {
10
+ server: {
11
+ type: string;
12
+ description: string;
13
+ };
14
+ database: {
15
+ type: string;
16
+ description: string;
17
+ };
18
+ user: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ password: {
23
+ type: string;
24
+ description: string;
25
+ };
26
+ name?: undefined;
27
+ };
28
+ required: string[];
29
+ };
30
+ } | {
31
+ name: string;
32
+ description: string;
33
+ inputSchema: {
34
+ type: string;
35
+ properties: {
36
+ name: {
37
+ type: string;
38
+ description: string;
39
+ };
40
+ server?: undefined;
41
+ database?: undefined;
42
+ user?: undefined;
43
+ password?: undefined;
44
+ };
45
+ required: string[];
46
+ };
47
+ } | {
48
+ name: string;
49
+ description: string;
50
+ inputSchema: {
51
+ type: string;
52
+ properties: {
53
+ server?: undefined;
54
+ database?: undefined;
55
+ user?: undefined;
56
+ password?: undefined;
57
+ name?: undefined;
58
+ };
59
+ required: never[];
60
+ };
61
+ })[];
62
+ /**
63
+ * Connection Tool Handlers
64
+ */
65
+ export declare function handleConnectionTool(name: string, args: any): Promise<any>;
66
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/tools/connection.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2D3B,CAAC;AAEF;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAwChF"}