@siemens/ix-mcp-angular 3.2.0-v.1.7.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.
Files changed (45) hide show
  1. package/LICENSE.md +20 -0
  2. package/README.md +330 -0
  3. package/config.json +48 -0
  4. package/database/vectors.db +0 -0
  5. package/dist/src/cli.d.ts +3 -0
  6. package/dist/src/cli.d.ts.map +1 -0
  7. package/dist/src/cli.js +298 -0
  8. package/dist/src/cli.js.map +1 -0
  9. package/dist/src/config.d.ts +34 -0
  10. package/dist/src/config.d.ts.map +1 -0
  11. package/dist/src/config.js +33 -0
  12. package/dist/src/config.js.map +1 -0
  13. package/dist/src/db-handler.d.ts +47 -0
  14. package/dist/src/db-handler.d.ts.map +1 -0
  15. package/dist/src/db-handler.js +143 -0
  16. package/dist/src/db-handler.js.map +1 -0
  17. package/dist/src/embeddings.d.ts +84 -0
  18. package/dist/src/embeddings.d.ts.map +1 -0
  19. package/dist/src/embeddings.js +300 -0
  20. package/dist/src/embeddings.js.map +1 -0
  21. package/dist/src/index.d.ts +24 -0
  22. package/dist/src/index.d.ts.map +1 -0
  23. package/dist/src/index.js +342 -0
  24. package/dist/src/index.js.map +1 -0
  25. package/dist/src/keys.d.ts +4 -0
  26. package/dist/src/keys.d.ts.map +1 -0
  27. package/dist/src/keys.js +25 -0
  28. package/dist/src/keys.js.map +1 -0
  29. package/dist/src/logger.d.ts +24 -0
  30. package/dist/src/logger.d.ts.map +1 -0
  31. package/dist/src/logger.js +185 -0
  32. package/dist/src/logger.js.map +1 -0
  33. package/dist/src/prompt.d.ts +19 -0
  34. package/dist/src/prompt.d.ts.map +1 -0
  35. package/dist/src/prompt.js +94 -0
  36. package/dist/src/prompt.js.map +1 -0
  37. package/dist/src/setup.d.ts +26 -0
  38. package/dist/src/setup.d.ts.map +1 -0
  39. package/dist/src/setup.js +718 -0
  40. package/dist/src/setup.js.map +1 -0
  41. package/dist/src/token.d.ts +22 -0
  42. package/dist/src/token.d.ts.map +1 -0
  43. package/dist/src/token.js +75 -0
  44. package/dist/src/token.js.map +1 -0
  45. package/package.json +56 -0
@@ -0,0 +1,298 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Copyright (c) Siemens 2016 - 2025
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { readFileSync, copyFileSync } from 'fs';
7
+ import { dirname, join, basename } from 'path';
8
+ import { fileURLToPath } from 'url';
9
+ import { Command } from 'commander';
10
+ import { SDLMCPSetup } from './setup.js';
11
+ import { loadConfig } from './config.js';
12
+ import { ObservabilityLogger } from './logger.js';
13
+ import { selectPrompt, showSuccess, showError, showInfo } from './prompt.js';
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ const config = loadConfig();
16
+ const program = new Command();
17
+ const binName = config.binName; // 'mcp'
18
+ const designSystem = config.designSystem; // 'Design System'
19
+ const projectName = config.projectName; // 'SDL'
20
+ program.name(binName).description(`${projectName} MCP Server CLI - Set up local MCP configurations for ${designSystem} documentation access
21
+
22
+ This tool creates an MCP (Model Context Protocol) server configuration in your repository
23
+ root, allowing AI tools like VS Code Copilot to access
24
+ ${designSystem} documentation and provide intelligent assistance with ${designSystem} components.
25
+ </parameter>
26
+
27
+ Repository Detection:
28
+ Automatically detects your repository root by looking for .git or package.json
29
+ Creates configurations locally in your project, not globally
30
+
31
+ Team Collaboration:
32
+ Configuration files can be committed and shared with your team
33
+ Each team member needs to set up their own LLM token`);
34
+ program
35
+ .command('setup')
36
+ .description(`Create MCP server configurations${config.agentsFile ? ' and optional AI agent instruction files' : ''}`)
37
+ .addHelpText('after', `
38
+ Examples:
39
+ $ ${binName} setup # Set up all MCP${config.agentsFile ? ' and agent instructions' : ' configs'}
40
+ $ cd my-project && ${binName} setup # Set up in specific project
41
+
42
+ This creates:
43
+ .vscode/mcp.json # VS Code MCP extension config
44
+ ${config.agentsFile
45
+ ? `
46
+ Optional AI agent instruction files:
47
+ .github/instructions/${designSystem}.instructions.md # ${designSystem}-specific instructions for AI agents
48
+ .github/copilot-instructions.md # General instructions for AI agents
49
+ AGENTS.md # Repository root instructions for AI agents
50
+ `
51
+ : ''}
52
+ Note: Run this from your project directory or any subdirectory`)
53
+ .action(async () => {
54
+ const setup = new SDLMCPSetup();
55
+ await setup.setupMCPConfigs();
56
+ });
57
+ program
58
+ .command('setup-token')
59
+ .description(`Configure your personal LLM token for ${designSystem} documentation access`)
60
+ .addHelpText('after', `
61
+ Examples:
62
+ $ ${binName} setup-token # Set up your personal token
63
+
64
+ Token Requirements:
65
+ - Get your token from: https://my.siemens.com/
66
+ - Must have 'llm' scope
67
+ - Stored securely in system keychain
68
+ - Required for embedding generation
69
+
70
+ Note: This is a one-time setup per machine/user`)
71
+ .action(async () => {
72
+ const setup = new SDLMCPSetup();
73
+ await setup.setupToken();
74
+ });
75
+ program
76
+ .command('check')
77
+ .description('Verify current MCP setup status and configuration')
78
+ .addHelpText('after', `
79
+ Examples:
80
+ $ ${binName} check # Check setup status
81
+ $ cd my-project && ${binName} check # Check specific project
82
+
83
+ Checks:
84
+ ✓ LLM token configuration
85
+ ✓ MCP configuration files existence
86
+ ✓ ${projectName} MCP server presence in configs
87
+ ✓ Configuration file validity`)
88
+ .action(async () => {
89
+ const setup = new SDLMCPSetup();
90
+ await setup.checkSetup();
91
+ });
92
+ program
93
+ .command('init')
94
+ .description('Complete initial setup: configure token, MCP configurations, and optional AI agent instruction files')
95
+ .addHelpText('after', `
96
+ Examples:
97
+ $ ${binName} init # Complete setup for new user
98
+ $ cd new-project && ${binName} init # Set up new project
99
+
100
+ This command:
101
+ 1. Prompts for your LLM token
102
+ 2. Stores token securely in keychain
103
+ 3. Creates all MCP configuration files
104
+ 4. Optionally adds instruction files for AI agents
105
+ 5. Provides next steps guidance
106
+
107
+ Perfect for first-time setup or new projects`)
108
+ .action(async () => {
109
+ const setup = new SDLMCPSetup();
110
+ await setup.setupToken();
111
+ await setup.setupMCPConfigs();
112
+ });
113
+ program
114
+ .command('test')
115
+ .description('Test MCP server functionality and connection')
116
+ .addHelpText('after', `
117
+ Examples:
118
+ $ ${binName} test # Test server functionality
119
+
120
+ This command:
121
+ - Validates server can be imported
122
+ - Tests basic initialization
123
+ - Verifies no critical errors
124
+ - Useful for troubleshooting`)
125
+ .action(async () => {
126
+ console.log(`Testing ${projectName} MCP server...`);
127
+ try {
128
+ // Dynamic import is necessary here for CLI testing
129
+ const { SDLMCPServer } = await import('./index.js');
130
+ const server = new SDLMCPServer({ debug: true });
131
+ setTimeout(() => {
132
+ console.log('✓ Server initialized successfully');
133
+ console.log('✓ MCP server is working correctly');
134
+ server.close();
135
+ process.exit(0);
136
+ }, 1000);
137
+ }
138
+ catch (error) {
139
+ console.error('✗ Server test failed:', error);
140
+ console.error('');
141
+ console.error('Troubleshooting:');
142
+ console.error(` 1. Ensure ${config.name /* 'MCP package' */} is installed`);
143
+ console.error(` 2. Check your LLM token is configured: ${binName} setup-token`);
144
+ console.error(` 3. Verify network connectivity to ${designSystem} documentation`);
145
+ process.exit(1);
146
+ }
147
+ });
148
+ // Only register log command if observability is enabled
149
+ program
150
+ .command('log', { hidden: !config.observabilityLogging })
151
+ .description('View and copy observability logs from previous MCP server sessions')
152
+ .addHelpText('after', `
153
+ Examples:
154
+ $ ${binName} log # View recent sessions and copy log
155
+
156
+ This command:
157
+ - Shows all recent MCP server sessions
158
+ - Lets you choose a session to view
159
+ - Copies the log file to current directory
160
+ - Displays the log content
161
+
162
+ Note: Observability must be enabled in config for logs to be created`)
163
+ .action(async () => {
164
+ try {
165
+ const sessions = ObservabilityLogger.listSessions();
166
+ if (sessions.length === 0) {
167
+ showInfo('No session logs found.');
168
+ console.log('');
169
+ console.log('Possible reasons:');
170
+ console.log(' - No MCP server sessions have been started yet');
171
+ console.log(' - Log directory has been cleared');
172
+ console.log('');
173
+ console.log(`Log directory: ${ObservabilityLogger.getLogDir()}`);
174
+ process.exit(0);
175
+ }
176
+ showSuccess(`Found ${sessions.length} session log(s)`);
177
+ console.log('');
178
+ const choices = sessions.map(session => ({
179
+ title: ObservabilityLogger.formatSessionDate(session),
180
+ value: session,
181
+ description: session
182
+ }));
183
+ const selectedSession = await selectPrompt('Select a session to view:', choices, 0);
184
+ if (!selectedSession) {
185
+ showInfo('No session selected.');
186
+ process.exit(0);
187
+ }
188
+ const logPath = ObservabilityLogger.getSessionPath(selectedSession);
189
+ const logContent = ObservabilityLogger.readSessionLog(selectedSession);
190
+ const fileName = basename(logPath);
191
+ const destPath = join(process.cwd(), fileName);
192
+ try {
193
+ copyFileSync(logPath, destPath);
194
+ showSuccess(`Log file copied to current directory: ${fileName}`);
195
+ }
196
+ catch (error) {
197
+ showError('Failed to copy log file');
198
+ console.error('Error:', error);
199
+ }
200
+ console.log('');
201
+ showInfo(`Original log location: ${logPath}`);
202
+ console.log('');
203
+ console.log('Log content:');
204
+ console.log('========================================');
205
+ console.log(logContent);
206
+ console.log('========================================');
207
+ console.log('');
208
+ showInfo(`Copied to: ${destPath}`);
209
+ console.log('');
210
+ }
211
+ catch (error) {
212
+ showError('Failed to read logs');
213
+ console.error('Error:', error);
214
+ process.exit(1);
215
+ }
216
+ });
217
+ program
218
+ .option('--verbose', 'Enable verbose logging for debugging')
219
+ .option('--debug', 'Enable debug mode with console logging')
220
+ .option('--test', 'Test mode - validate configuration and exit')
221
+ .option('--version', 'Display the current version')
222
+ .addHelpText('after', `
223
+ Quick Start:
224
+ 1. Navigate to your project directory
225
+ 2. Run: ${binName} init
226
+ 3. Follow the prompts to set up your token
227
+ 4. Restart VS Code or your AI tool
228
+ 5. Ask questions about ${designSystem} components!
229
+
230
+ Examples:
231
+ ${binName} init # Complete first-time setup
232
+ ${binName} setup # Add to existing project
233
+ ${binName} check # Verify everything works
234
+ ${binName} setup-token # Update your token
235
+ ${binName} --version # Show version
236
+
237
+ For more information: https://code.siemens.com/ux/sdl-mcp`);
238
+ if (!config.observabilityLogging) {
239
+ program.option('--log', 'Enable observability logging (add this flag in your MCP config, use the log command to view logs)');
240
+ }
241
+ else {
242
+ program.option('--nolog', 'Disable observability logging (add this flag in your MCP config, use the log command to view logs)');
243
+ }
244
+ // Handle --version option before parsing
245
+ if (process.argv.includes('--version')) {
246
+ try {
247
+ const packageJsonPath = join(__dirname, '../../package.json');
248
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
249
+ console.log(packageJson.version);
250
+ process.exit(0);
251
+ }
252
+ catch (error) {
253
+ console.error('Error reading version:', error);
254
+ process.exit(1);
255
+ }
256
+ }
257
+ const nonServerArgs = process.argv.slice(2).filter(arg => !['--verbose', '--debug', '--log', '--nolog'].includes(arg));
258
+ // If no arguments provided, default to starting the server
259
+ if (nonServerArgs.length === 0) {
260
+ // No command provided, start the MCP server directly
261
+ (async () => {
262
+ try {
263
+ const args = process.argv.slice(2);
264
+ const verbose = args.includes('--verbose');
265
+ const debug = args.includes('--debug');
266
+ const log = args.includes('--log');
267
+ const noLog = args.includes('--nolog');
268
+ const { SDLMCPServer } = await import('./index.js');
269
+ const server = new SDLMCPServer({ verbose, debug, overrideLogging: noLog ? false : log || undefined });
270
+ await server.run();
271
+ // Graceful shutdown handlers
272
+ process.on('SIGINT', () => {
273
+ if (verbose || debug || process.env.SDL_MCP_DEBUG_LOG === 'true') {
274
+ console.log('');
275
+ console.log('Received shutdown signal...');
276
+ }
277
+ server.close();
278
+ process.exit(0);
279
+ });
280
+ process.on('SIGTERM', () => {
281
+ if (verbose || debug || process.env.SDL_MCP_DEBUG_LOG === 'true') {
282
+ console.log('');
283
+ console.log('Received termination signal...');
284
+ }
285
+ server.close();
286
+ process.exit(0);
287
+ });
288
+ }
289
+ catch (error) {
290
+ console.error('Failed to start MCP server:', error);
291
+ process.exit(1);
292
+ }
293
+ })();
294
+ }
295
+ else {
296
+ program.parse();
297
+ }
298
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/mcp/cli.ts"],"names":[],"mappings":";AAEA;;;GAGG;AACH,OAAO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AAC;gBAC7C,CAAC;gBACD,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;gBACzB,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,MAAM,EAAE,CAAC;oBACjE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;oBAChB,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;gBAChD,CAAC;gBACD,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;YACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
@@ -0,0 +1,34 @@
1
+ declare function loadConfig(): {
2
+ name: string;
3
+ description: string;
4
+ displayName: string;
5
+ binName: string;
6
+ compatTokenName?: string;
7
+ designSystem: string;
8
+ projectName: string;
9
+ searchToolName: string;
10
+ iconSearch?: boolean;
11
+ iconSearchToolName?: string;
12
+ iconName?: string;
13
+ agentsFile?: boolean;
14
+ instructionFileName?: string;
15
+ observabilityLogging?: boolean;
16
+ exampleQuestions: string[];
17
+ texts: {
18
+ FRAMEWORK_LIBRARY_LIST?: string;
19
+ FRAMEWORK_DEV_QUESTION: string;
20
+ FRAMEWORK_IMPLEMENTATIONS: string;
21
+ FRAMEWORK_COMPONENT_LIBRARIES: string;
22
+ FRAMEWORK_SUPPORTED_LIBRARIES: string;
23
+ FRAMEWORK_SEMANTIC_SEARCH_TOOL: string;
24
+ FRAMEWORK_ALL_QUERIES: string;
25
+ FRAMEWORK_VERSION_SPECIFIC: string;
26
+ FRAMEWORK_SETUP_ADVICE: string;
27
+ FRAMEWORK_COMPREHENSIVE_GUIDANCE: string;
28
+ FRAMEWORK_SEARCH_QUERY: string;
29
+ FRAMEWORK_DOCUMENTATION_RESULTS: string;
30
+ };
31
+ };
32
+ declare function setConfigPath(customPath: string): void;
33
+ export { loadConfig, setConfigPath };
34
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/mcp/config.ts"],"names":[],"mappings":"AA+CA,iBAAS,UAAU;UAhCP,MAAM;iBACC,MAAM;iBACN,MAAM;aACV,MAAM;sBACG,MAAM;kBACV,MAAM;iBACP,MAAM;oBACH,MAAM;iBACT,OAAO;yBACC,MAAM;eAChB,MAAM;iBACJ,OAAO;0BACE,MAAM;2BACL,OAAO;sBACZ,MAAM,EAAE;WACnB;QACL,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,yBAAyB,EAAE,MAAM,CAAC;QAClC,6BAA6B,EAAE,MAAM,CAAC;QACtC,6BAA6B,EAAE,MAAM,CAAC;QACtC,8BAA8B,EAAE,MAAM,CAAC;QACvC,qBAAqB,EAAE,MAAM,CAAC;QAC9B,0BAA0B,EAAE,MAAM,CAAC;QACnC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,gCAAgC,EAAE,MAAM,CAAC;QACzC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,+BAA+B,EAAE,MAAM,CAAC;KACzC;EAgBN;AAED,iBAAS,aAAa,CAAC,UAAU,EAAE,MAAM,QAQxC;AAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) Siemens 2016 - 2025
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+ import * as fs from 'fs';
6
+ import * as path from 'path';
7
+ import { fileURLToPath } from 'url';
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ let configPath = undefined;
11
+ let config = undefined;
12
+ function loadConfig() {
13
+ if (config)
14
+ return config;
15
+ const actualConfigPath = configPath || path.join(__dirname, '..', '..', 'config.json');
16
+ const configData = fs.readFileSync(actualConfigPath, 'utf8');
17
+ config = JSON.parse(configData);
18
+ if (!config) {
19
+ throw new Error('Failed to load configuration');
20
+ }
21
+ return config;
22
+ }
23
+ function setConfigPath(customPath) {
24
+ if (customPath === configPath) {
25
+ return;
26
+ }
27
+ if (config) {
28
+ throw new Error('Cannot set config path after config has been loaded');
29
+ }
30
+ configPath = customPath;
31
+ }
32
+ export { loadConfig, setConfigPath };
33
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/mcp/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,IAAI,UAAU,GAAuB,SAAS,CAAC;AAE/C,IAAI,MAAM,GAgCM,SAAS,CAAC;AAE1B,SAAS,UAAU;IACjB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,MAAM,gBAAgB,GAAG,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;IACvF,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAC7D,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAEhC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,UAAkB;IACvC,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO;IACT,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,UAAU,GAAG,UAAU,CAAC;AAC1B,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,47 @@
1
+ export interface DocumentRow {
2
+ id: string;
3
+ content: string;
4
+ embedding: string;
5
+ chunk_index: number;
6
+ type: string;
7
+ header_path: string | undefined;
8
+ header_level: number | undefined;
9
+ category: string | undefined;
10
+ terms: string | undefined;
11
+ token_count: number;
12
+ }
13
+ export interface ChunkData {
14
+ chunkId: string;
15
+ content: string;
16
+ type: string;
17
+ headerPath: string | undefined;
18
+ headerLevel: number | undefined;
19
+ category: string | undefined;
20
+ terms: string | undefined;
21
+ tokenCount: number;
22
+ chunkIndex: number;
23
+ }
24
+ export declare class DatabaseHandler {
25
+ private db;
26
+ private insertStmt;
27
+ private verbose;
28
+ constructor(dbPath: string, options?: {
29
+ verbose?: boolean;
30
+ });
31
+ private initializeDatabase;
32
+ private prepareStatements;
33
+ getDocumentCount(): number;
34
+ getDocumentsByType(type: string): DocumentRow[];
35
+ getAllDocuments(): DocumentRow[];
36
+ insertDocument(chunk: ChunkData, embedding: number[]): void;
37
+ insertDocumentsBatch(chunks: ChunkData[], embeddings: number[][]): void;
38
+ clearAllDocuments(): number;
39
+ clearDocumentsByType(type: string): number;
40
+ close(): void;
41
+ transaction<T>(fn: () => T): T;
42
+ getStats(): {
43
+ totalDocuments: number;
44
+ documentsByType: Record<string, number>;
45
+ };
46
+ }
47
+ //# sourceMappingURL=db-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-handler.d.ts","sourceRoot":"","sources":["../../../src/mcp/db-handler.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,OAAO,CAAU;gBAEb,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;IAkB3D,OAAO,CAAC,kBAAkB;IAgC1B,OAAO,CAAC,iBAAiB;IAWzB,gBAAgB,IAAI,MAAM;IAK1B,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE;IAK/C,eAAe,IAAI,WAAW,EAAE;IAKhC,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAkB3D,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI;IAUvE,iBAAiB,IAAI,MAAM;IAW3B,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAW1C,KAAK,IAAI,IAAI;IAUb,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAM9B,QAAQ,IAAI;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE;CAehF"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Copyright (c) Siemens 2016 - 2025
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+ import Database from 'better-sqlite3';
6
+ import * as fs from 'fs';
7
+ import * as path from 'path';
8
+ export class DatabaseHandler {
9
+ db;
10
+ insertStmt;
11
+ verbose;
12
+ constructor(dbPath, options) {
13
+ this.verbose = options?.verbose || false;
14
+ // Ensure database directory exists
15
+ const dbDir = path.dirname(dbPath);
16
+ if (!fs.existsSync(dbDir)) {
17
+ fs.mkdirSync(dbDir, { recursive: true });
18
+ }
19
+ this.db = new Database(dbPath);
20
+ this.initializeDatabase();
21
+ this.prepareStatements();
22
+ if (!this.insertStmt) {
23
+ throw new Error('Failed to initialize prepared statements');
24
+ }
25
+ }
26
+ initializeDatabase() {
27
+ try {
28
+ // Create documents table if it doesn't exist
29
+ this.db.exec(`
30
+ CREATE TABLE IF NOT EXISTS documents (
31
+ id TEXT PRIMARY KEY,
32
+ content TEXT NOT NULL,
33
+ embedding TEXT NOT NULL,
34
+ chunk_index INTEGER NOT NULL,
35
+ type TEXT DEFAULT 'documentation',
36
+ header_path TEXT,
37
+ header_level INTEGER,
38
+ category TEXT,
39
+ terms TEXT,
40
+ token_count INTEGER
41
+ )
42
+ `);
43
+ // Create index for faster queries
44
+ this.db.exec(`
45
+ CREATE INDEX IF NOT EXISTS idx_type ON documents(type);
46
+ `);
47
+ if (this.verbose) {
48
+ const count = this.getDocumentCount();
49
+ console.log(`Database ready with ${count} documentation chunks`);
50
+ }
51
+ }
52
+ catch (error) {
53
+ throw new Error(`Failed to initialize SQLite database: ${error}`);
54
+ }
55
+ }
56
+ prepareStatements() {
57
+ try {
58
+ this.insertStmt = this.db.prepare(`
59
+ INSERT INTO documents (id, content, embedding, chunk_index, type, header_path, header_level, category, terms, token_count)
60
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
61
+ `);
62
+ }
63
+ catch (error) {
64
+ throw new Error(`Failed to prepare SQL statements: ${error}`);
65
+ }
66
+ }
67
+ getDocumentCount() {
68
+ const result = this.db.prepare('SELECT COUNT(*) as count FROM documents').get();
69
+ return result.count;
70
+ }
71
+ getDocumentsByType(type) {
72
+ const stmt = this.db.prepare('SELECT * FROM documents WHERE type = ?');
73
+ return stmt.all(type);
74
+ }
75
+ getAllDocuments() {
76
+ const stmt = this.db.prepare('SELECT * FROM documents');
77
+ return stmt.all();
78
+ }
79
+ insertDocument(chunk, embedding) {
80
+ if (!this.insertStmt) {
81
+ throw new Error('Database not properly initialized - insert statement not prepared');
82
+ }
83
+ this.insertStmt.run(chunk.chunkId, chunk.content, JSON.stringify(embedding), chunk.chunkIndex, chunk.type, chunk.headerPath, chunk.headerLevel, chunk.category, chunk.terms, chunk.tokenCount);
84
+ }
85
+ insertDocumentsBatch(chunks, embeddings) {
86
+ const transaction = this.db.transaction(() => {
87
+ for (let i = 0; i < chunks.length; i++) {
88
+ this.insertDocument(chunks[i], embeddings[i]);
89
+ }
90
+ });
91
+ transaction();
92
+ }
93
+ clearAllDocuments() {
94
+ try {
95
+ const deleteStmt = this.db.prepare('DELETE FROM documents');
96
+ const result = deleteStmt.run();
97
+ return result.changes;
98
+ }
99
+ catch (error) {
100
+ console.warn('Error clearing existing data:', error);
101
+ return 0;
102
+ }
103
+ }
104
+ clearDocumentsByType(type) {
105
+ try {
106
+ const deleteStmt = this.db.prepare('DELETE FROM documents WHERE type = ?');
107
+ const result = deleteStmt.run(type);
108
+ return result.changes;
109
+ }
110
+ catch (error) {
111
+ console.warn(`Error clearing ${type} data:`, error);
112
+ return 0;
113
+ }
114
+ }
115
+ close() {
116
+ if (this.db) {
117
+ this.db.close();
118
+ if (this.verbose) {
119
+ console.log('Database connection closed');
120
+ }
121
+ }
122
+ }
123
+ // Transaction wrapper for bulk operations
124
+ transaction(fn) {
125
+ const transaction = this.db.transaction(fn);
126
+ return transaction();
127
+ }
128
+ // Get database statistics
129
+ getStats() {
130
+ const total = this.getDocumentCount();
131
+ const typeStmt = this.db.prepare('SELECT type, COUNT(*) as count FROM documents GROUP BY type');
132
+ const typeResults = typeStmt.all();
133
+ const documentsByType = {};
134
+ for (const result of typeResults) {
135
+ documentsByType[result.type] = result.count;
136
+ }
137
+ return {
138
+ totalDocuments: total,
139
+ documentsByType
140
+ };
141
+ }
142
+ }
143
+ //# sourceMappingURL=db-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-handler.js","sourceRoot":"","sources":["../../../src/mcp/db-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AA2B7B,MAAM,OAAO,eAAe;IAClB,EAAE,CAAoB;IACtB,UAAU,CAAiC;IAC3C,OAAO,CAAU;IAEzB,YAAY,MAAc,EAAE,OAA+B;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC;QAEzC,mCAAmC;QACnC,MAAM,KAAK,GAAG,IAAI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