@toolplex/client 0.1.37 → 0.1.39
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/dist/mcp-server/policy/serverPolicy.d.ts +2 -3
- package/dist/mcp-server/policy/serverPolicy.js +2 -12
- package/dist/server-manager/serverManager.js +14 -1
- package/dist/src/mcp-server/policy/serverPolicy.js +2 -12
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -18,10 +18,9 @@ export declare class ServerPolicy {
|
|
|
18
18
|
*/
|
|
19
19
|
enforceAllowedServerPolicy(serverId: string): void;
|
|
20
20
|
/**
|
|
21
|
-
* Validates that a server is
|
|
22
|
-
* Also checks if desktop commander is enabled when calling tools on the desktop commander server.
|
|
21
|
+
* Validates that a server is allowed before calling a tool on it.
|
|
23
22
|
*
|
|
24
|
-
* @throws Error if attempting to call a tool on a blocked
|
|
23
|
+
* @throws Error if attempting to call a tool on a blocked or disallowed server
|
|
25
24
|
*/
|
|
26
25
|
enforceCallToolPolicy(serverId: string): void;
|
|
27
26
|
/**
|
|
@@ -37,23 +37,13 @@ export class ServerPolicy {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Validates that a server is
|
|
41
|
-
* Also checks if desktop commander is enabled when calling tools on the desktop commander server.
|
|
40
|
+
* Validates that a server is allowed before calling a tool on it.
|
|
42
41
|
*
|
|
43
|
-
* @throws Error if attempting to call a tool on a blocked
|
|
42
|
+
* @throws Error if attempting to call a tool on a blocked or disallowed server
|
|
44
43
|
*/
|
|
45
44
|
enforceCallToolPolicy(serverId) {
|
|
46
45
|
this.enforceBlockedServerPolicy(serverId);
|
|
47
46
|
this.enforceAllowedServerPolicy(serverId);
|
|
48
|
-
// Check if desktop commander is disabled and this is the desktop commander server
|
|
49
|
-
// Skip this check if the server is in the allowed list (admin explicitly approved it)
|
|
50
|
-
const allowedServers = this.clientContext.permissions.allowed_mcp_servers;
|
|
51
|
-
const isExplicitlyAllowed = allowedServers && allowedServers.includes(serverId);
|
|
52
|
-
if (!isExplicitlyAllowed &&
|
|
53
|
-
!this.clientContext.permissions.use_desktop_commander &&
|
|
54
|
-
serverId === this.clientContext.flags.desktop_commander_server_id) {
|
|
55
|
-
throw new Error("Desktop Commander is disabled for your account");
|
|
56
|
-
}
|
|
57
47
|
}
|
|
58
48
|
/**
|
|
59
49
|
* Validates that a server can be used.
|
|
@@ -50,6 +50,9 @@ function extractPrivateRegistryScope(args) {
|
|
|
50
50
|
* - username: the scope without @ (e.g., "tp-user-abc123def45")
|
|
51
51
|
* - password: the ToolPlex API key (tp_live_xxx or tp_test_xxx)
|
|
52
52
|
*
|
|
53
|
+
* IMPORTANT: We also clear _authToken to override any expired tokens in the
|
|
54
|
+
* user's ~/.npmrc. This ensures our injected basic auth takes precedence.
|
|
55
|
+
*
|
|
53
56
|
* @param scope - The scope without @ (e.g., "tp-user-abc123def45")
|
|
54
57
|
* @param apiKey - The ToolPlex API key
|
|
55
58
|
*/
|
|
@@ -66,14 +69,24 @@ function getPrivateRegistryEnv(scope, apiKey) {
|
|
|
66
69
|
// Set Basic auth for the registry
|
|
67
70
|
// npm_config_//host/:_auth maps to //host/:_auth in .npmrc
|
|
68
71
|
"npm_config_//registry.toolplex.ai/:_auth": auth,
|
|
72
|
+
// Clear any existing _authToken from user's ~/.npmrc to prevent expired tokens
|
|
73
|
+
// from taking precedence over our injected basic auth
|
|
74
|
+
"npm_config_//registry.toolplex.ai/:_authToken": "",
|
|
69
75
|
};
|
|
70
76
|
}
|
|
71
77
|
/**
|
|
72
78
|
* Get additional args to prepend for private registry packages.
|
|
73
79
|
* Uses --registry flag which is more reliable than env vars with special chars.
|
|
80
|
+
*
|
|
81
|
+
* IMPORTANT: We use --userconfig=/dev/null to completely ignore the user's ~/.npmrc.
|
|
82
|
+
* This prevents expired tokens in ~/.npmrc from interfering with our injected basic auth.
|
|
74
83
|
*/
|
|
75
84
|
function getPrivateRegistryArgs() {
|
|
76
|
-
return [
|
|
85
|
+
return [
|
|
86
|
+
`--registry=${PRIVATE_REGISTRY_URL}`,
|
|
87
|
+
// Ignore user's ~/.npmrc to prevent expired _authToken from taking precedence
|
|
88
|
+
`--userconfig=/dev/null`,
|
|
89
|
+
];
|
|
77
90
|
}
|
|
78
91
|
export class ServerManager {
|
|
79
92
|
constructor() {
|
|
@@ -37,23 +37,13 @@ export class ServerPolicy {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Validates that a server is
|
|
41
|
-
* Also checks if desktop commander is enabled when calling tools on the desktop commander server.
|
|
40
|
+
* Validates that a server is allowed before calling a tool on it.
|
|
42
41
|
*
|
|
43
|
-
* @throws Error if attempting to call a tool on a blocked
|
|
42
|
+
* @throws Error if attempting to call a tool on a blocked or disallowed server
|
|
44
43
|
*/
|
|
45
44
|
enforceCallToolPolicy(serverId) {
|
|
46
45
|
this.enforceBlockedServerPolicy(serverId);
|
|
47
46
|
this.enforceAllowedServerPolicy(serverId);
|
|
48
|
-
// Check if desktop commander is disabled and this is the desktop commander server
|
|
49
|
-
// Skip this check if the server is in the allowed list (admin explicitly approved it)
|
|
50
|
-
const allowedServers = this.clientContext.permissions.allowed_mcp_servers;
|
|
51
|
-
const isExplicitlyAllowed = allowedServers && allowedServers.includes(serverId);
|
|
52
|
-
if (!isExplicitlyAllowed &&
|
|
53
|
-
!this.clientContext.permissions.use_desktop_commander &&
|
|
54
|
-
serverId === this.clientContext.flags.desktop_commander_server_id) {
|
|
55
|
-
throw new Error("Desktop Commander is disabled for your account");
|
|
56
|
-
}
|
|
57
47
|
}
|
|
58
48
|
/**
|
|
59
49
|
* Validates that a server can be used.
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.1.
|
|
1
|
+
export declare const version = "0.1.39";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.1.
|
|
1
|
+
export const version = '0.1.39';
|