Skip to content

feat: mcp config generator and docs - #28

Merged
AngelAlexQC merged 3 commits into
mainfrom
feat/mcp-config-gen
Jan 5, 2026
Merged

feat: mcp config generator and docs#28
AngelAlexQC merged 3 commits into
mainfrom
feat/mcp-config-gen

Conversation

@AngelAlexQC

Copy link
Copy Markdown
Collaborator

Integrates generate-config tools and fixes CI badge

Copilot AI review requested due to automatic review settings January 5, 2026 23:34
@AngelAlexQC
AngelAlexQC merged commit 2621489 into main Jan 5, 2026
@codecov

codecov Bot commented Jan 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-config command 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

Comment on lines +13 to +14
// Set default timeout for IPv4/IPv6 family auto-selection to avoid long delays
// This fixes: Set default auto-select family attempt timeout to 1000ms

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +82
// 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);
}
}

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
type: 'string',
},
},
strict: false, // allow params we don't know yet (though we should know them)

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +82
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);
}
}

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +81
// 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);
}

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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;

Copilot uses AI. Check for mistakes.
const guard = new ContextGuard();

// CLI Argument Handling for `generate-config`
import { parseArgs } from 'node:util';

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants