Skip to content

Commit

Permalink
Push
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellatman committed Nov 27, 2024
1 parent a9915ea commit db7c54f
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 16 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/update-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ jobs:
automated pr
automerge
# - name: Enable Auto-Merge
# if: steps.git-check.outputs.changes == 'true'
# run: |
# PR_NUMBER=$(gh pr list --json number --jq '.[0].number')
# gh pr merge $PR_NUMBER --auto --merge
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable Auto-Merge
if: steps.git-check.outputs.changes == 'true'
run: |
PR_NUMBER=$(gh pr list --json number --jq '.[0].number')
gh pr merge $PR_NUMBER --auto --merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion src/extractors/modelcontextprotocol-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ export async function extractPackageInfo(): Promise<PackageInfo[]> {
fs.writeFileSync(outputPath, JSON.stringify(mergedPackages, null, 2));
console.log('Package list updated successfully');

// Write commit message
// Write commit message with total number of changes
if (changes.length === 0) {
changes.push('- Initial package list creation');
}
commitMsg = `chore(packages): update MCP package list (${changes.length} packages)\n\nChanges:\n`;
commitMsg += changes.join('\n');
fs.writeFileSync(commitMsgPath, commitMsg);
console.log('Commit message generated');
Expand Down
29 changes: 21 additions & 8 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,33 @@ import { join } from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import { Package } from './types/index.js';
import { installMCPServer } from './utils/config';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const packageListPath = join(__dirname, '../packages/package-list.json');

export async function installPackage(pkg: Package): Promise<void> {
console.log(`Installing package: ${pkg.name}`);
console.log(`Description: ${pkg.description}`);
console.log(`Vendor: ${pkg.vendor}`);
console.log(`Source URL: ${pkg.sourceUrl}`);
console.log(`License: ${pkg.license}`);
export async function installPackage(packageName: string): Promise<void> {
try {
console.log(`Installing package: ${packageName}`);
console.log(`Description: ${packageName}`);
console.log(`Vendor: ${packageName}`);
console.log(`Source URL: ${packageName}`);
console.log(`License: ${packageName}`);

// Here you can add the logic to download and install the package from the sourceUrl
// Here you can add the logic to download and install the package from the sourceUrl

// After successful installation, update the config
if (packageName.startsWith('@modelcontextprotocol/server-')) {
installMCPServer(packageName);
console.log('Updated Claude desktop configuration');
}

} catch (error) {
console.error('Failed to install package:', error);
throw error;
}
}

export async function install(packageName: string): Promise<void> {
Expand All @@ -28,5 +41,5 @@ export async function install(packageName: string): Promise<void> {
process.exit(1);
}

await installPackage(pkg);
await installPackage(pkg.name);
}
53 changes: 53 additions & 0 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';

interface MCPServerConfig {
command: string;
args: string[];
}

interface ClaudeConfig {
mcpServers?: Record<string, MCPServerConfig>;
[key: string]: any;
}

export function getConfigPath(): string {
const configDir = path.join(os.homedir(), 'Library', 'Application Support', 'Claude');
return path.join(configDir, 'claude_desktop_config.json');
}

export function readConfig(): ClaudeConfig {
const configPath = getConfigPath();
if (!fs.existsSync(configPath)) {
return {};
}
return JSON.parse(fs.readFileSync(configPath, 'utf8'));
}

export function writeConfig(config: ClaudeConfig): void {
const configPath = getConfigPath();
const configDir = path.dirname(configPath);

if (!fs.existsSync(configDir)) {
fs.mkdirSync(configDir, { recursive: true });
}

fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
}

export function installMCPServer(packageName: string): void {
const config = readConfig();
const serverName = packageName;

if (!config.mcpServers) {
config.mcpServers = {};
}

config.mcpServers[serverName] = {
command: 'npx',
args: ['-y', packageName]
};

writeConfig(config);
}

0 comments on commit db7c54f

Please sign in to comment.