@smithery/cli 0.0.7 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -7
- package/dist/index.js +96 -45
- package/package.json +12 -12
- package/LICENSE +0 -21
- package/dist/auto-update.js +0 -33
- package/dist/commands/get.js +0 -25
- package/dist/commands/install.js +0 -76
- package/dist/commands/installed.js +0 -31
- package/dist/commands/list.js +0 -45
- package/dist/commands/uninstall.js +0 -47
- package/dist/extractors/modelcontextprotocol-extractor.js +0 -209
- package/dist/helpers/index.js +0 -94
- package/dist/install.js +0 -79
- package/dist/types/analytics.js +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/package.js +0 -1
- package/dist/types.js +0 -1
- package/dist/utils/analytics.js +0 -44
- package/dist/utils/config-manager.js +0 -122
- package/dist/utils/config.js +0 -74
- package/dist/utils/display.js +0 -39
- package/dist/utils/package-actions.js +0 -52
- package/dist/utils/package-management.js +0 -217
- package/dist/utils/package-resolver.js +0 -133
- package/dist/utils/runtime-utils.js +0 -37
- package/dist/utils/ui.js +0 -65
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { ConfigManager } from "./config-manager.js";
|
|
2
|
-
// import path from 'path';
|
|
3
|
-
// import fs from 'fs';
|
|
4
|
-
// import { dirname } from 'path';
|
|
5
|
-
// import { fileURLToPath } from 'url';
|
|
6
|
-
import dotenv from "dotenv";
|
|
7
|
-
dotenv.config();
|
|
8
|
-
export const REGISTRY_ENDPOINT = process.env.REGISTRY_ENDPOINT || "https://registry.smithery.ai";
|
|
9
|
-
export function isPackageInstalled(packageName) {
|
|
10
|
-
return ConfigManager.isPackageInstalled(packageName);
|
|
11
|
-
}
|
|
12
|
-
export async function resolvePackages(client) {
|
|
13
|
-
try {
|
|
14
|
-
// Updated API endpoint
|
|
15
|
-
const response = await fetch(`${REGISTRY_ENDPOINT}/servers/`);
|
|
16
|
-
if (!response.ok) {
|
|
17
|
-
throw new Error(`Failed to fetch packages: ${response.statusText} (${response.status})`);
|
|
18
|
-
}
|
|
19
|
-
// Add text validation before JSON parsing
|
|
20
|
-
const text = await response.text();
|
|
21
|
-
if (!text) {
|
|
22
|
-
throw new Error("Empty response received from registry");
|
|
23
|
-
}
|
|
24
|
-
let packages;
|
|
25
|
-
try {
|
|
26
|
-
packages = JSON.parse(text);
|
|
27
|
-
}
|
|
28
|
-
catch (parseError) {
|
|
29
|
-
const errorMessage = parseError instanceof Error
|
|
30
|
-
? parseError.message
|
|
31
|
-
: "Unknown parsing error";
|
|
32
|
-
throw new Error(`Invalid JSON response from registry: ${errorMessage}`);
|
|
33
|
-
}
|
|
34
|
-
const resolvedPackages = new Map();
|
|
35
|
-
// Add packages from registry
|
|
36
|
-
for (const pkg of packages) {
|
|
37
|
-
resolvedPackages.set(pkg.id, {
|
|
38
|
-
id: pkg.id || "",
|
|
39
|
-
name: pkg.name || "",
|
|
40
|
-
description: pkg.description || "",
|
|
41
|
-
vendor: pkg.vendor || "",
|
|
42
|
-
sourceUrl: pkg.sourceUrl || "",
|
|
43
|
-
license: pkg.license || "",
|
|
44
|
-
connections: pkg.connections || [],
|
|
45
|
-
homepage: pkg.homepage || "",
|
|
46
|
-
isInstalled: false,
|
|
47
|
-
isVerified: true,
|
|
48
|
-
client: client,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
// Process installed packages
|
|
52
|
-
const config = ConfigManager.readConfig();
|
|
53
|
-
const installedIds = Object.keys(config.mcpServers || {});
|
|
54
|
-
const installedServers = config.mcpServers || {};
|
|
55
|
-
for (const id of installedIds) {
|
|
56
|
-
const installedServer = installedServers[id];
|
|
57
|
-
const existingPkg = resolvedPackages.get(id);
|
|
58
|
-
if (existingPkg) {
|
|
59
|
-
resolvedPackages.set(id, {
|
|
60
|
-
...existingPkg,
|
|
61
|
-
isInstalled: true,
|
|
62
|
-
client: client || existingPkg.client,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
resolvedPackages.set(id, {
|
|
67
|
-
...installedServer,
|
|
68
|
-
id: id || "",
|
|
69
|
-
name: id || "",
|
|
70
|
-
description: "Local package",
|
|
71
|
-
vendor: "Local",
|
|
72
|
-
sourceUrl: "",
|
|
73
|
-
license: "",
|
|
74
|
-
connections: [],
|
|
75
|
-
homepage: "",
|
|
76
|
-
isInstalled: true,
|
|
77
|
-
isVerified: false,
|
|
78
|
-
client: client,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return Array.from(resolvedPackages.values());
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
throw new Error(`Failed to resolve packages: ${error instanceof Error ? error.message : String(error)}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
export async function resolvePackage(packageId, client) {
|
|
89
|
-
try {
|
|
90
|
-
// Updated API endpoint
|
|
91
|
-
const response = await fetch(`${REGISTRY_ENDPOINT}/servers/${packageId}`);
|
|
92
|
-
if (!response.ok) {
|
|
93
|
-
// Check if it's an installed package
|
|
94
|
-
const config = ConfigManager.readConfig();
|
|
95
|
-
const installedServer = config.mcpServers?.[packageId];
|
|
96
|
-
if (installedServer) {
|
|
97
|
-
return {
|
|
98
|
-
id: packageId,
|
|
99
|
-
name: packageId,
|
|
100
|
-
description: "Local package",
|
|
101
|
-
vendor: "Local",
|
|
102
|
-
sourceUrl: "",
|
|
103
|
-
license: "",
|
|
104
|
-
connections: [],
|
|
105
|
-
homepage: "",
|
|
106
|
-
isInstalled: true,
|
|
107
|
-
isVerified: false,
|
|
108
|
-
client: client,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
const registryPackage = await response.json();
|
|
114
|
-
const resolvedPackage = {
|
|
115
|
-
id: registryPackage.id,
|
|
116
|
-
name: registryPackage.name,
|
|
117
|
-
description: registryPackage.description,
|
|
118
|
-
vendor: registryPackage.vendor,
|
|
119
|
-
sourceUrl: registryPackage.sourceUrl,
|
|
120
|
-
license: registryPackage.license,
|
|
121
|
-
connections: registryPackage.connections,
|
|
122
|
-
homepage: registryPackage.homepage,
|
|
123
|
-
isInstalled: isPackageInstalled(registryPackage.id),
|
|
124
|
-
isVerified: true,
|
|
125
|
-
client: client,
|
|
126
|
-
};
|
|
127
|
-
return resolvedPackage;
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
console.error("Error resolving package:", error);
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { exec } from "node:child_process";
|
|
2
|
-
import { promisify } from "node:util";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
const execAsync = promisify(exec);
|
|
5
|
-
export async function checkUVInstalled() {
|
|
6
|
-
try {
|
|
7
|
-
await execAsync("uvx --version");
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export async function promptForUVInstall(inquirerInstance) {
|
|
15
|
-
const { shouldInstall } = await inquirerInstance.prompt([
|
|
16
|
-
{
|
|
17
|
-
type: "confirm",
|
|
18
|
-
name: "shouldInstall",
|
|
19
|
-
message: "UV package manager is required for Python MCP servers. Would you like to install it?",
|
|
20
|
-
default: true,
|
|
21
|
-
},
|
|
22
|
-
]);
|
|
23
|
-
if (!shouldInstall) {
|
|
24
|
-
console.warn(chalk.yellow("UV installation was declined. You can install it manually from https://astral.sh/uv"));
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
console.log("Installing uv package manager...");
|
|
28
|
-
try {
|
|
29
|
-
await execAsync("curl -LsSf https://astral.sh/uv/install.sh | sh");
|
|
30
|
-
console.log(chalk.green("✓ UV installed successfully"));
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
console.warn(chalk.yellow("Failed to install UV. You can install it manually from https://astral.sh/uv"));
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
package/dist/utils/ui.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import inquirer from "inquirer";
|
|
2
|
-
import fuzzy from "fuzzy";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
export function formatPackageChoice(pkg, showInstallStatus = false) {
|
|
5
|
-
const prefix = showInstallStatus ? (pkg.isInstalled ? "✓ " : " ") : "";
|
|
6
|
-
const name = (pkg.name || "").toString();
|
|
7
|
-
const description = (pkg.description || "").toString();
|
|
8
|
-
const vendor = (pkg.vendor || "").toString();
|
|
9
|
-
const id = (pkg.id || "").toString();
|
|
10
|
-
// Adjust column widths (removed license column)
|
|
11
|
-
const nameWidth = 20;
|
|
12
|
-
const idWidth = 15;
|
|
13
|
-
const descWidth = 45; // Increased description width
|
|
14
|
-
const vendorWidth = 15;
|
|
15
|
-
// Truncation function remains the same
|
|
16
|
-
const truncateText = (text, width) => {
|
|
17
|
-
if (text.length <= width) {
|
|
18
|
-
return text.padEnd(width);
|
|
19
|
-
}
|
|
20
|
-
return `${text.slice(0, width - 3).padEnd(width - 3)}...`;
|
|
21
|
-
};
|
|
22
|
-
// Apply truncation (removed license)
|
|
23
|
-
const truncatedName = truncateText(name, nameWidth);
|
|
24
|
-
const truncatedId = truncateText(id, idWidth);
|
|
25
|
-
const truncatedDesc = truncateText(description, descWidth);
|
|
26
|
-
const truncatedVendor = truncateText(vendor, vendorWidth);
|
|
27
|
-
return {
|
|
28
|
-
name: `${prefix}${truncatedName} │ ${truncatedId} │ ${truncatedDesc} │ ${truncatedVendor}`,
|
|
29
|
-
value: pkg,
|
|
30
|
-
short: name,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function createPackagePrompt(packages, options = {}) {
|
|
34
|
-
const choices = packages.map((pkg) => formatPackageChoice(pkg, options.showInstallStatus));
|
|
35
|
-
return {
|
|
36
|
-
type: "autocomplete",
|
|
37
|
-
name: "selectedPackage",
|
|
38
|
-
message: options.message || "Search and select a package:",
|
|
39
|
-
source: async (_answersSoFar, input) => {
|
|
40
|
-
if (!input)
|
|
41
|
-
return choices;
|
|
42
|
-
return fuzzy
|
|
43
|
-
.filter(input.toLowerCase(), choices, {
|
|
44
|
-
extract: (choice) => `${choice.value.name} ${choice.value.description} ${choice.value.vendor}`.toLowerCase(),
|
|
45
|
-
})
|
|
46
|
-
.map((result) => result.original);
|
|
47
|
-
},
|
|
48
|
-
pageSize: 10,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export async function confirmUninstall(packageName) {
|
|
52
|
-
const { confirmUninstall } = await inquirer.prompt([
|
|
53
|
-
{
|
|
54
|
-
type: "confirm",
|
|
55
|
-
name: "confirmUninstall",
|
|
56
|
-
message: `Are you sure you want to uninstall ${packageName}?`,
|
|
57
|
-
default: false,
|
|
58
|
-
},
|
|
59
|
-
]);
|
|
60
|
-
return confirmUninstall;
|
|
61
|
-
}
|
|
62
|
-
export function printPackageListHeader(count, type = "all") {
|
|
63
|
-
console.log(chalk.bold.cyan(`\n📦 ${type === "installed" ? "Installed Packages" : "Available Packages"}`));
|
|
64
|
-
console.log(chalk.gray(`Found ${count} ${type === "installed" ? "installed " : ""}packages\n`));
|
|
65
|
-
}
|