feat: mcp config generator and docs - #28
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR consolidates the MCP configuration generation functionality by moving it from a standalone script into the main MCP server entry point, updates documentation, and fixes the CI badge reference. The changes enable users to generate AI tool configurations directly through the server binary.
- Integrates
generate-configcommand into the main MCP server file, removing the separate script - Adds comprehensive MCP server documentation with usage examples for multiple AI tools
- Fixes VS Code extension compatibility with FTS5 database triggers and network timeout settings
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/vscode-extension/src/storage.ts | Adds cleanup logic to drop FTS5 triggers for sql.js compatibility |
| packages/vscode-extension/src/extension.ts | Sets default IPv4/IPv6 auto-select timeout to reduce connection delays |
| packages/vscode-extension/package.json | Updates @types/vscode dependency to v1.107.0 |
| packages/mcp-server/src/mcp-server.ts | Embeds generate-config CLI command handler with multi-target support |
| packages/mcp-server/scripts/generate-config.ts | Removes standalone script (functionality moved to main server) |
| packages/mcp-server/package.json | Updates generate-config script to invoke main server with command |
| packages/mcp-server/README.md | Adds comprehensive documentation for MCP server usage and tools |
| README.md | Updates CI badge URL and simplifies MCP server configuration example |
| // Set default timeout for IPv4/IPv6 family auto-selection to avoid long delays | ||
| // This fixes: Set default auto-select family attempt timeout to 1000ms |
There was a problem hiding this comment.
The comment says "This fixes: Set default auto-select family attempt timeout to 1000ms" which is unclear and appears to be a copy-paste from an issue or commit message. The comment should explain WHY this timeout is being set (e.g., "Reduces connection delays when resolving IPv4/IPv6 addresses in dual-stack environments").
| // Set default timeout for IPv4/IPv6 family auto-selection to avoid long delays | |
| // This fixes: Set default auto-select family attempt timeout to 1000ms | |
| // Limit IPv4/IPv6 family auto-selection to 1000ms to avoid long DNS/connection delays | |
| // that can otherwise slow down network requests and VS Code extension activation. |
| // CLI Argument Handling for `generate-config` | ||
| import { parseArgs } from 'node:util'; | ||
|
|
||
| try { | ||
| const args = process.argv.slice(2); | ||
| if (args[0] === 'generate-config') { | ||
| const { values } = parseArgs({ | ||
| args: args, | ||
| options: { | ||
| target: { | ||
| type: 'string', | ||
| }, | ||
| }, | ||
| strict: false, // allow params we don't know yet (though we should know them) | ||
| }); | ||
|
|
||
| const target = values.target as string | undefined; | ||
| const targets = ['claude', 'cursor', 'windsurf', 'goose']; | ||
|
|
||
| if (!target || !targets.includes(target)) { | ||
| console.error(`Usage: cortex-mcp generate-config --target <${targets.join('|')}>`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const command = 'npx'; | ||
| const cmdArgs = ['-y', '@ecuabyte/cortex-mcp-server']; | ||
| let config: Record<string, unknown> = {}; | ||
|
|
||
| switch (target) { | ||
| case 'claude': | ||
| config = { | ||
| mcpServers: { | ||
| cortex: { | ||
| command, | ||
| args: cmdArgs, | ||
| }, | ||
| }, | ||
| }; | ||
| break; | ||
| case 'cursor': | ||
| case 'windsurf': | ||
| config = { | ||
| cortex: { | ||
| type: 'command', | ||
| command, | ||
| args: cmdArgs, | ||
| }, | ||
| }; | ||
| break; | ||
| case 'goose': | ||
| console.log(`Run this command to configure Goose:`); | ||
| console.log(`goose configure mcp add cortex "${command} ${cmdArgs.join(' ')}"`); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| console.log(JSON.stringify(config, null, 2)); | ||
| process.exit(0); | ||
| } | ||
| } catch (e) { | ||
| // If parsing fails or other issues, just ignore and proceed to server start | ||
| // or print error if it was clearly a CLI attempt | ||
| if (process.argv[2] === 'generate-config') { | ||
| console.error('Error generating config:', e); | ||
| process.exit(1); | ||
| } | ||
| } |
There was a problem hiding this comment.
The generate-config logic is embedded in the main server entry point, making it execute on every server start. This adds unnecessary overhead and complexity to the main server module. Consider extracting this to a separate CLI entry point or at least moving it to a dedicated function to improve maintainability.
| type: 'string', | ||
| }, | ||
| }, | ||
| strict: false, // allow params we don't know yet (though we should know them) |
There was a problem hiding this comment.
The comment "allow params we don't know yet (though we should know them)" suggests incomplete implementation or uncertainty about the command line interface. This should be either removed or clarified. If there are specific parameters planned for the future, document them; otherwise, set strict: true for better validation.
| strict: false, // allow params we don't know yet (though we should know them) | |
| strict: true, // fail on unknown params to ensure the CLI surface stays well-defined |
| try { | ||
| const args = process.argv.slice(2); | ||
| if (args[0] === 'generate-config') { | ||
| const { values } = parseArgs({ | ||
| args: args, | ||
| options: { | ||
| target: { | ||
| type: 'string', | ||
| }, | ||
| }, | ||
| strict: false, // allow params we don't know yet (though we should know them) | ||
| }); | ||
|
|
||
| const target = values.target as string | undefined; | ||
| const targets = ['claude', 'cursor', 'windsurf', 'goose']; | ||
|
|
||
| if (!target || !targets.includes(target)) { | ||
| console.error(`Usage: cortex-mcp generate-config --target <${targets.join('|')}>`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const command = 'npx'; | ||
| const cmdArgs = ['-y', '@ecuabyte/cortex-mcp-server']; | ||
| let config: Record<string, unknown> = {}; | ||
|
|
||
| switch (target) { | ||
| case 'claude': | ||
| config = { | ||
| mcpServers: { | ||
| cortex: { | ||
| command, | ||
| args: cmdArgs, | ||
| }, | ||
| }, | ||
| }; | ||
| break; | ||
| case 'cursor': | ||
| case 'windsurf': | ||
| config = { | ||
| cortex: { | ||
| type: 'command', | ||
| command, | ||
| args: cmdArgs, | ||
| }, | ||
| }; | ||
| break; | ||
| case 'goose': | ||
| console.log(`Run this command to configure Goose:`); | ||
| console.log(`goose configure mcp add cortex "${command} ${cmdArgs.join(' ')}"`); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| console.log(JSON.stringify(config, null, 2)); | ||
| process.exit(0); | ||
| } | ||
| } catch (e) { | ||
| // If parsing fails or other issues, just ignore and proceed to server start | ||
| // or print error if it was clearly a CLI attempt | ||
| if (process.argv[2] === 'generate-config') { | ||
| console.error('Error generating config:', e); | ||
| process.exit(1); | ||
| } | ||
| } |
There was a problem hiding this comment.
The generate-config functionality lacks test coverage. The existing test file (mcp-server.test.ts) only tests the MCP server's JSON-RPC functionality but doesn't validate the generate-config command. Consider adding tests to verify that each target (claude, cursor, windsurf, goose) generates the correct configuration format.
| // If parsing fails or other issues, just ignore and proceed to server start | ||
| // or print error if it was clearly a CLI attempt | ||
| if (process.argv[2] === 'generate-config') { | ||
| console.error('Error generating config:', e); | ||
| process.exit(1); | ||
| } |
There was a problem hiding this comment.
The catch block silently swallows errors for non-generate-config invocations. If parseArgs or the generate-config logic fails for other reasons (e.g., during normal server initialization), this will hide important errors. Consider logging the error or being more specific about which errors to ignore.
| // If parsing fails or other issues, just ignore and proceed to server start | |
| // or print error if it was clearly a CLI attempt | |
| if (process.argv[2] === 'generate-config') { | |
| console.error('Error generating config:', e); | |
| process.exit(1); | |
| } | |
| // If this was a generate-config CLI invocation, report the error and exit | |
| if (process.argv[2] === 'generate-config') { | |
| console.error('Error generating config:', e); | |
| process.exit(1); | |
| } | |
| // For all other cases, log and rethrow so startup failures are not silently swallowed | |
| console.error('[Cortex] Failed during CLI argument handling:', e); | |
| throw e; |
| const guard = new ContextGuard(); | ||
|
|
||
| // CLI Argument Handling for `generate-config` | ||
| import { parseArgs } from 'node:util'; |
There was a problem hiding this comment.
The import statement for parseArgs is placed after the initial imports and right before the try-catch block. According to best practices and the project's TypeScript guidelines, all imports should be grouped at the top of the file. Move this import to line 1 or after the other imports from node modules.
Integrates generate-config tools and fixes CI badge