Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: combine custom command implementations from #47 and #53 #59

Closed
wants to merge 10 commits into from
Closed
4 changes: 4 additions & 0 deletions src/types/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export interface PackageHelper {
};
configureEnv?: (config: any) => Promise<void>;
runtime?: 'node' | 'python';
Copy link
Owner

Choose a reason for hiding this comment

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

Runtime should be custom right?

customCommand?: {
command: string;
args?: string[];
}
}

export interface PackageHelpers {
Expand Down
20 changes: 15 additions & 5 deletions src/utils/config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class ConfigManager {
return serverName in (config.mcpServers || {});
}

static async installPackage(pkg: Package, envVars?: Record<string, string>): Promise<void> {
static async installPackage(pkg: Package, envVars?: Record<string, string>, customCommand?: Record<string, any>): Promise<void> {
const config = this.readConfig();
const serverName = pkg.name.replace(/\//g, '-');

Expand All @@ -114,11 +114,21 @@ export class ConfigManager {

// Add command and args based on runtime
if (pkg.runtime === 'node') {
serverConfig.command = 'npx';
serverConfig.args = ['-y', pkg.name];
if (customCommand) {
serverConfig.command = customCommand.command;
Copy link
Owner

Choose a reason for hiding this comment

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

Custom command should be handled in its own rumtime

serverConfig.args = customCommand.args || [];
} else {
serverConfig.command = 'npx';
serverConfig.args = ['-y', pkg.name];
}
} else if (pkg.runtime === 'python') {
serverConfig.command = 'uvx';
Copy link
Owner

Choose a reason for hiding this comment

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

Looks like we can basically just resolve the command and args based on runtime and custom command and then just set serverCOnfig.command and args based on that versus these if branches

serverConfig.args = [pkg.name];
if (customCommand) {
serverConfig.command = customCommand.command;
serverConfig.args = customCommand.args || [];
} else {
serverConfig.command = 'uvx';
serverConfig.args = [pkg.name];
}
}

config.mcpServers[serverName] = serverConfig;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/package-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ export async function installPackage(pkg: Package): Promise<void> {
}

const envVars = await promptForEnvVars(pkg.name);
const customCommand = packageHelpers[pkg.name]?.customCommand;

await ConfigManager.installPackage(pkg, envVars);
await ConfigManager.installPackage(pkg, envVars, customCommand);
console.log('Updated Claude desktop configuration');

// Check analytics consent and track if allowed
Expand Down