Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 135 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"typescript": "^5.8.3"
},
"dependencies": {
"@supabase/supabase-js": "^2.49.4",
"chalk": "^5.4.1",
"dotenv": "^16.5.0",
"fuzzy": "^0.1.3",
"inquirer": "^12.5.2",
"yargs": "^17.7.2"
Expand Down
59 changes: 25 additions & 34 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import inquirer from "inquirer";
import fuzzy from "fuzzy";
import { packages } from "./packages";

import { spawn } from "child_process";
import { readClaudeConfig, writeClaudeConfig } from "./claude_config";
import { term } from "./term";
import { InputType } from "./create_package";
import { RegistryManager } from './registry/registry_manager';
import { PackageMetadata } from './types/registry';
const registryManager = new RegistryManager();

// Search functionality
function searchPackages(term: string) {
const packageNames = Object.keys(packages);
async function searchPackages(term: string) {
const packages = await registryManager.listPackages();
const packageNames = packages.map(p => p.name);
const results = fuzzy
.filter(term, packageNames)
.map((result) => result.string);

// Include aliases in search
Object.entries(packages).forEach(([name, pkg]) => {
if (!results.includes(name)) {
const matchesAlias = pkg.aliases.some(
packages.forEach((pkg) => {
if (!results.includes(pkg.name)) {
const matchesAlias = pkg.aliases?.some(
(alias) => fuzzy.match(term, alias) !== null
);
if (matchesAlias) results.push(name);
if (matchesAlias) results.push(pkg.name);
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Replace this with server side SQL fuzzy search perhaps?


return results;
}

// Format output
function formatPackage(name: string) {
const pkg = packages[name as keyof typeof packages];
async function formatPackage(pkg: PackageMetadata) {
if (!pkg) return '';

return `
${term.bold(pkg.name)} ${term.gray(`(${pkg.aliases.join(", ")})`)}
${term.bold(pkg.name)} ${term.gray(`(${pkg.version})`)}
${term.dim("Dependencies:")} ${
pkg.dependsOn.length ? pkg.dependsOn.join(", ") : "None"
pkg.dependencies.length ? pkg.dependencies.join(", ") : "None"
}
${term.dim("Inputs:")}
${pkg.inputs
Expand Down Expand Up @@ -71,9 +71,9 @@ ${term.green(name)}
}
async function installPackage(packageName: string, serverName?: string) {
// Find package
const pkg = packages[packageName as keyof typeof packages];
const pkg = await registryManager.getPackage(packageName);
if (!pkg) {
const suggestions = searchPackages(packageName);
const suggestions = await searchPackages(packageName);
if (suggestions.length > 0) {
console.log(term.red(`Package "${packageName}" not found.`));
console.log(term.yellow(`Did you mean: ${suggestions.join(", ")}?`));
Expand All @@ -84,9 +84,9 @@ async function installPackage(packageName: string, serverName?: string) {
}

// Check dependencies
if (pkg.dependsOn.length > 0) {
if (pkg.dependencies.length > 0) {
console.log(
term.yellow(`Checking dependencies: ${pkg.dependsOn.join(", ")}`)
term.yellow(`Checking dependencies: ${pkg.dependencies.join(", ")}`)
);
// Implement dependency checking logic
}
Expand Down Expand Up @@ -162,7 +162,7 @@ async function installPackage(packageName: string, serverName?: string) {
}

// Build config
const mcpConfig = pkg.buildConfig(inputs as any);
const mcpConfig = await registryManager.buildConfig(packageName, inputs);

// Update Claude config
await updateClaudeConfig({
Expand Down Expand Up @@ -304,22 +304,13 @@ async function startServer(serverName: string) {
}

async function listPackages(searchTerm?: string) {
let packageNames = Object.keys(packages);
let packages = await registryManager.listPackages(searchTerm);

if (searchTerm) {
packageNames = searchPackages(searchTerm);
if (packageNames.length === 0) {
console.log(term.yellow(`No packages found matching "${searchTerm}"`));
return;
}
console.log(term.bold(`\nPackages matching "${searchTerm}":`));
} else {
console.log(term.bold("\nAvailable MCP Packages:"));
}


packageNames.forEach((name) => {
console.log(formatPackage(name));
});
for (const pkg of packages) {
console.log(await formatPackage(pkg));
}
}

// Main CLI definition
Expand Down
Loading