@toolplex/client 0.1.1 → 0.1.2

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.
Files changed (76) hide show
  1. package/dist/mcp-server/clientContext.d.ts +7 -4
  2. package/dist/mcp-server/clientContext.js +21 -10
  3. package/dist/mcp-server/index.js +9 -7
  4. package/dist/mcp-server/logging/telemetryLogger.d.ts +2 -2
  5. package/dist/mcp-server/logging/telemetryLogger.js +2 -2
  6. package/dist/mcp-server/policy/callToolObserver.js +4 -2
  7. package/dist/mcp-server/policy/feedbackPolicy.d.ts +4 -4
  8. package/dist/mcp-server/policy/feedbackPolicy.js +1 -1
  9. package/dist/mcp-server/policy/installObserver.js +4 -4
  10. package/dist/mcp-server/policy/playbookPolicy.d.ts +3 -3
  11. package/dist/mcp-server/policy/playbookPolicy.js +5 -5
  12. package/dist/mcp-server/policy/policyEnforcer.d.ts +4 -4
  13. package/dist/mcp-server/policy/policyEnforcer.js +13 -13
  14. package/dist/mcp-server/policy/serverPolicy.d.ts +1 -1
  15. package/dist/mcp-server/policy/serverPolicy.js +4 -2
  16. package/dist/mcp-server/promptsCache.js +2 -2
  17. package/dist/mcp-server/registry.d.ts +8 -8
  18. package/dist/mcp-server/registry.js +19 -17
  19. package/dist/mcp-server/serversCache.d.ts +1 -1
  20. package/dist/mcp-server/serversCache.js +6 -6
  21. package/dist/mcp-server/staticPrompts.js +2 -2
  22. package/dist/mcp-server/toolDefinitionsCache.d.ts +3 -3
  23. package/dist/mcp-server/toolDefinitionsCache.js +3 -3
  24. package/dist/mcp-server/toolHandlers/callToolHandler.d.ts +2 -2
  25. package/dist/mcp-server/toolHandlers/callToolHandler.js +22 -20
  26. package/dist/mcp-server/toolHandlers/getServerConfigHandler.d.ts +2 -2
  27. package/dist/mcp-server/toolHandlers/getServerConfigHandler.js +24 -18
  28. package/dist/mcp-server/toolHandlers/initHandler.d.ts +2 -2
  29. package/dist/mcp-server/toolHandlers/initHandler.js +41 -39
  30. package/dist/mcp-server/toolHandlers/installServerHandler.d.ts +2 -2
  31. package/dist/mcp-server/toolHandlers/installServerHandler.js +36 -32
  32. package/dist/mcp-server/toolHandlers/listServersHandler.d.ts +1 -1
  33. package/dist/mcp-server/toolHandlers/listServersHandler.js +21 -17
  34. package/dist/mcp-server/toolHandlers/listToolsHandler.d.ts +2 -2
  35. package/dist/mcp-server/toolHandlers/listToolsHandler.js +32 -26
  36. package/dist/mcp-server/toolHandlers/logPlaybookUsageHandler.d.ts +2 -2
  37. package/dist/mcp-server/toolHandlers/logPlaybookUsageHandler.js +14 -14
  38. package/dist/mcp-server/toolHandlers/lookupEntityHandler.d.ts +2 -2
  39. package/dist/mcp-server/toolHandlers/lookupEntityHandler.js +30 -28
  40. package/dist/mcp-server/toolHandlers/savePlaybookHandler.d.ts +2 -2
  41. package/dist/mcp-server/toolHandlers/savePlaybookHandler.js +17 -15
  42. package/dist/mcp-server/toolHandlers/searchHandler.d.ts +2 -2
  43. package/dist/mcp-server/toolHandlers/searchHandler.js +33 -28
  44. package/dist/mcp-server/toolHandlers/serverManagerUtils.d.ts +1 -1
  45. package/dist/mcp-server/toolHandlers/serverManagerUtils.js +2 -2
  46. package/dist/mcp-server/toolHandlers/submitFeedbackHandler.d.ts +2 -2
  47. package/dist/mcp-server/toolHandlers/submitFeedbackHandler.js +17 -15
  48. package/dist/mcp-server/toolHandlers/uninstallServerHandler.d.ts +2 -2
  49. package/dist/mcp-server/toolHandlers/uninstallServerHandler.js +21 -19
  50. package/dist/mcp-server/toolplexApi/service.d.ts +8 -8
  51. package/dist/mcp-server/toolplexApi/service.js +24 -28
  52. package/dist/mcp-server/toolplexApi/types.d.ts +3 -3
  53. package/dist/mcp-server/toolplexServer.d.ts +1 -1
  54. package/dist/mcp-server/toolplexServer.js +78 -77
  55. package/dist/mcp-server/tools.d.ts +1 -1
  56. package/dist/mcp-server/tools.js +3 -3
  57. package/dist/mcp-server/utils/initServerManagers.d.ts +4 -4
  58. package/dist/mcp-server/utils/initServerManagers.js +5 -5
  59. package/dist/mcp-server/utils/resultAnnotators.js +3 -7
  60. package/dist/mcp-server/utils/runtimeCheck.js +8 -8
  61. package/dist/server-manager/index.js +4 -4
  62. package/dist/server-manager/serverManager.d.ts +6 -6
  63. package/dist/server-manager/serverManager.js +34 -36
  64. package/dist/server-manager/stdioServer.js +37 -35
  65. package/dist/server-manager/stdioTransportProtocol.d.ts +2 -2
  66. package/dist/server-manager/stdioTransportProtocol.js +7 -7
  67. package/dist/shared/enhancedPath.js +13 -13
  68. package/dist/shared/fileLogger.js +19 -19
  69. package/dist/shared/mcpServerTypes.d.ts +4 -3
  70. package/dist/shared/mcpServerTypes.js +17 -10
  71. package/dist/shared/serverManagerTypes.d.ts +1 -1
  72. package/dist/shared/serverManagerTypes.js +1 -1
  73. package/dist/shared/stdioServerManagerClient.js +20 -18
  74. package/dist/version.d.ts +1 -1
  75. package/dist/version.js +1 -1
  76. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { LLMContext } from '../shared/mcpServerTypes.js';
2
- import { ClientPermissions, ClientFlags } from './toolplexApi/types.js';
1
+ import { LLMContext } from "../shared/mcpServerTypes.js";
2
+ import { ClientPermissions, ClientFlags } from "./toolplexApi/types.js";
3
3
  /**
4
4
  * Maintains client context for the ToolPlex server
5
5
  */
@@ -13,14 +13,17 @@ export declare class ClientContext {
13
13
  private _permissions;
14
14
  private _flags;
15
15
  private _isOrgUser;
16
+ private _clientName;
16
17
  get sessionId(): string;
17
18
  set sessionId(id: string);
18
19
  get dev(): boolean;
19
20
  set dev(isDev: boolean);
20
21
  get apiKey(): string;
21
22
  set apiKey(key: string);
22
- get clientMode(): 'standard' | 'restricted';
23
- set clientMode(mode: 'standard' | 'restricted');
23
+ get clientMode(): "standard" | "restricted";
24
+ set clientMode(mode: "standard" | "restricted");
25
+ get clientName(): string;
26
+ set clientName(name: string);
24
27
  get llmContext(): LLMContext;
25
28
  set llmContext(context: LLMContext);
26
29
  get clientVersion(): string;
@@ -12,10 +12,11 @@ export class ClientContext {
12
12
  this._permissions = null;
13
13
  this._flags = null;
14
14
  this._isOrgUser = null;
15
+ this._clientName = null;
15
16
  }
16
17
  get sessionId() {
17
18
  if (!this._sessionId) {
18
- throw new Error('Session ID not set - ToolPlex not initialized');
19
+ throw new Error("Session ID not set - ToolPlex not initialized");
19
20
  }
20
21
  return this._sessionId;
21
22
  }
@@ -24,7 +25,7 @@ export class ClientContext {
24
25
  }
25
26
  get dev() {
26
27
  if (this._dev === null) {
27
- throw new Error('Dev mode not set - ToolPlex not initialized');
28
+ throw new Error("Dev mode not set - ToolPlex not initialized");
28
29
  }
29
30
  return this._dev;
30
31
  }
@@ -33,7 +34,7 @@ export class ClientContext {
33
34
  }
34
35
  get apiKey() {
35
36
  if (!this._apiKey) {
36
- throw new Error('API key not set - ToolPlex not initialized');
37
+ throw new Error("API key not set - ToolPlex not initialized");
37
38
  }
38
39
  return this._apiKey;
39
40
  }
@@ -42,16 +43,25 @@ export class ClientContext {
42
43
  }
43
44
  get clientMode() {
44
45
  if (!this._clientMode) {
45
- throw new Error('Client mode not set - ToolPlex not initialized');
46
+ throw new Error("Client mode not set - ToolPlex not initialized");
46
47
  }
47
48
  return this._clientMode;
48
49
  }
49
50
  set clientMode(mode) {
50
51
  this._clientMode = mode;
51
52
  }
53
+ get clientName() {
54
+ if (!this._clientName) {
55
+ throw new Error("Client name not set - ToolPlex not initialized");
56
+ }
57
+ return this._clientName;
58
+ }
59
+ set clientName(name) {
60
+ this._clientName = name;
61
+ }
52
62
  get llmContext() {
53
63
  if (!this._llmContext) {
54
- throw new Error('LLM context not set - ToolPlex not initialized');
64
+ throw new Error("LLM context not set - ToolPlex not initialized");
55
65
  }
56
66
  return this._llmContext;
57
67
  }
@@ -60,7 +70,7 @@ export class ClientContext {
60
70
  }
61
71
  get clientVersion() {
62
72
  if (!this._clientVersion) {
63
- throw new Error('Client version not set - ToolPlex not initialized');
73
+ throw new Error("Client version not set - ToolPlex not initialized");
64
74
  }
65
75
  return this._clientVersion;
66
76
  }
@@ -69,7 +79,7 @@ export class ClientContext {
69
79
  }
70
80
  get permissions() {
71
81
  if (!this._permissions) {
72
- throw new Error('Permissions not set - ToolPlex not initialized');
82
+ throw new Error("Permissions not set - ToolPlex not initialized");
73
83
  }
74
84
  return this._permissions;
75
85
  }
@@ -78,7 +88,7 @@ export class ClientContext {
78
88
  }
79
89
  get flags() {
80
90
  if (!this._flags) {
81
- throw new Error('Consts not set - ToolPlex not initialized');
91
+ throw new Error("Consts not set - ToolPlex not initialized");
82
92
  }
83
93
  return this._flags;
84
94
  }
@@ -87,7 +97,7 @@ export class ClientContext {
87
97
  }
88
98
  get isOrgUser() {
89
99
  if (this._isOrgUser === null) {
90
- throw new Error('Organization user status not set - ToolPlex not initialized');
100
+ throw new Error("Organization user status not set - ToolPlex not initialized");
91
101
  }
92
102
  return this._isOrgUser;
93
103
  }
@@ -102,6 +112,7 @@ export class ClientContext {
102
112
  this._clientVersion &&
103
113
  this._permissions &&
104
114
  this._flags &&
105
- this._isOrgUser !== null);
115
+ this._isOrgUser !== null &&
116
+ this._clientName);
106
117
  }
107
118
  }
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { serve } from './toolplexServer.js';
3
- import dotenv from 'dotenv';
4
- import { FileLogger } from '../shared/fileLogger.js';
2
+ import { serve } from "./toolplexServer.js";
3
+ import dotenv from "dotenv";
4
+ import { FileLogger } from "../shared/fileLogger.js";
5
5
  dotenv.config();
6
- FileLogger.initialize('mcp-server');
7
- const isDev = process.env.DEV === 'true';
6
+ FileLogger.initialize("mcp-server");
7
+ const isDev = process.env.DEV === "true";
8
8
  const apiKey = process.env.TOOLPLEX_API_KEY;
9
- const clientMode = process.env.TOOLPLEX_CLIENT_MODE || 'standard';
10
- const logLevel = process.env.LOG_LEVEL || 'info';
9
+ const clientMode = process.env.TOOLPLEX_CLIENT_MODE || "standard";
10
+ const clientName = process.env.CLIENT_NAME || "unknown";
11
+ const logLevel = process.env.LOG_LEVEL || "info";
11
12
  if (!apiKey) {
12
13
  process.exit(1);
13
14
  }
@@ -15,6 +16,7 @@ const config = {
15
16
  dev: isDev,
16
17
  apiKey,
17
18
  clientMode,
19
+ clientName,
18
20
  logLevel,
19
21
  };
20
22
  serve(config).catch(() => {
@@ -1,4 +1,4 @@
1
- import { LogTelemetryRequest } from '../toolplexApi/types.js';
1
+ import { LogTelemetryRequest } from "../toolplexApi/types.js";
2
2
  export declare class TelemetryLogger {
3
3
  private eventQueue;
4
4
  private flushTimeout;
@@ -8,7 +8,7 @@ export declare class TelemetryLogger {
8
8
  /**
9
9
  * Log a telemetry event
10
10
  */
11
- log(eventType: LogTelemetryRequest['event_type'], data: Partial<Omit<LogTelemetryRequest, 'event_type'>>): Promise<void>;
11
+ log(eventType: LogTelemetryRequest["event_type"], data: Partial<Omit<LogTelemetryRequest, "event_type">>): Promise<void>;
12
12
  private flush;
13
13
  private scheduleFlush;
14
14
  /**
@@ -1,5 +1,5 @@
1
- import Registry from '../registry.js';
2
- import { FileLogger } from '../../shared/fileLogger.js';
1
+ import Registry from "../registry.js";
2
+ import { FileLogger } from "../../shared/fileLogger.js";
3
3
  const logger = FileLogger;
4
4
  export class TelemetryLogger {
5
5
  constructor() {
@@ -11,11 +11,13 @@ class CallToolObserver {
11
11
  }
12
12
  // Check if a server was called at all
13
13
  wasServerCalled(serverId) {
14
- return this.serverToolCalls.has(serverId) && this.serverToolCalls.get(serverId).size > 0;
14
+ return (this.serverToolCalls.has(serverId) &&
15
+ this.serverToolCalls.get(serverId).size > 0);
15
16
  }
16
17
  // Check if a specific tool was called on a server
17
18
  wasToolCalled(serverId, toolName) {
18
- return this.serverToolCalls.has(serverId) && this.serverToolCalls.get(serverId).has(toolName);
19
+ return (this.serverToolCalls.has(serverId) &&
20
+ this.serverToolCalls.get(serverId).has(toolName));
19
21
  }
20
22
  // Optionally, clear all records (for testing or reset)
21
23
  clear() {
@@ -1,7 +1,7 @@
1
- import CallToolObserver from './callToolObserver.js';
2
- import InstallObserver from './installObserver.js';
3
- import { ClientContext } from '../clientContext.js';
4
- import { SubmitFeedbackParams } from '../../shared/mcpServerTypes.js';
1
+ import CallToolObserver from "./callToolObserver.js";
2
+ import InstallObserver from "./installObserver.js";
3
+ import { ClientContext } from "../clientContext.js";
4
+ import { SubmitFeedbackParams } from "../../shared/mcpServerTypes.js";
5
5
  export declare class FeedbackPolicy {
6
6
  private callToolObserver;
7
7
  private installObserver;
@@ -22,7 +22,7 @@ export class FeedbackPolicy {
22
22
  */
23
23
  enforceFeedbackPolicy(feedback) {
24
24
  const { target_type, target_id } = feedback;
25
- if (target_type === 'server') {
25
+ if (target_type === "server") {
26
26
  // Check if server is blocked
27
27
  if (this.blockedMcpServersSet.has(target_id)) {
28
28
  throw new Error(`Cannot submit feedback for blocked server "${target_id}"`);
@@ -4,21 +4,21 @@ class InstallObserver {
4
4
  }
5
5
  // Record an install action on a server
6
6
  recordInstall(serverId) {
7
- this.recordAction(serverId, 'install');
7
+ this.recordAction(serverId, "install");
8
8
  }
9
9
  // Record an uninstall action on a server
10
10
  recordUninstall(serverId) {
11
- this.recordAction(serverId, 'uninstall');
11
+ this.recordAction(serverId, "uninstall");
12
12
  }
13
13
  // Check if a server has been installed
14
14
  wasServerInstalled(serverId) {
15
15
  return (this.serverInstallActions.has(serverId) &&
16
- this.serverInstallActions.get(serverId).has('install'));
16
+ this.serverInstallActions.get(serverId).has("install"));
17
17
  }
18
18
  // Check if a server has been uninstalled
19
19
  wasServerUninstalled(serverId) {
20
20
  return (this.serverInstallActions.has(serverId) &&
21
- this.serverInstallActions.get(serverId).has('uninstall'));
21
+ this.serverInstallActions.get(serverId).has("uninstall"));
22
22
  }
23
23
  // Optionally, clear all records (for testing or reset)
24
24
  clear() {
@@ -1,6 +1,6 @@
1
- import CallToolObserver from './callToolObserver.js';
2
- import { ClientContext } from '../clientContext.js';
3
- import { SavePlaybookParams } from '../../shared/mcpServerTypes.js';
1
+ import CallToolObserver from "./callToolObserver.js";
2
+ import { ClientContext } from "../clientContext.js";
3
+ import { SavePlaybookParams } from "../../shared/mcpServerTypes.js";
4
4
  export declare class PlaybookPolicy {
5
5
  private callToolObserver;
6
6
  private clientContext;
@@ -1,4 +1,4 @@
1
- import Registry from '../registry.js';
1
+ import Registry from "../registry.js";
2
2
  export class PlaybookPolicy {
3
3
  constructor(clientContext, callToolObserver) {
4
4
  this.callToolObserver = callToolObserver;
@@ -21,7 +21,7 @@ export class PlaybookPolicy {
21
21
  */
22
22
  enforceSavePlaybookPolicy(playbook) {
23
23
  if (!Array.isArray(playbook.actions)) {
24
- throw new Error('Playbook actions must be an array');
24
+ throw new Error("Playbook actions must be an array");
25
25
  }
26
26
  for (const [idx, action] of playbook.actions.entries()) {
27
27
  if (!action.call)
@@ -32,7 +32,7 @@ export class PlaybookPolicy {
32
32
  // - "mcp_server_id:<server_id>"
33
33
  // - "playbook_id:<playbook_id>"
34
34
  const call = action.call.trim();
35
- if (call.startsWith('mcp_server_id:')) {
35
+ if (call.startsWith("mcp_server_id:")) {
36
36
  // Could be with or without tool_name
37
37
  // e.g. mcp_server_id:abc123::toolX or mcp_server_id:abc123
38
38
  const match = call.match(/^mcp_server_id:([^:]+)(?:::([^:]+))?$/);
@@ -58,7 +58,7 @@ export class PlaybookPolicy {
58
58
  }
59
59
  }
60
60
  }
61
- else if (call.startsWith('playbook_id:')) {
61
+ else if (call.startsWith("playbook_id:")) {
62
62
  // For playbook references, we could skip or add logic if needed
63
63
  // For now, we do not validate playbook_id usage
64
64
  continue;
@@ -75,7 +75,7 @@ export class PlaybookPolicy {
75
75
  enforceLogPlaybookUsagePolicy() {
76
76
  if (this.clientContext.permissions.enable_read_only_mode) {
77
77
  const promptsCache = Registry.getPromptsCache();
78
- throw new Error(promptsCache.getPrompt('log_playbook_usage_disabled'));
78
+ throw new Error(promptsCache.getPrompt("log_playbook_usage_disabled"));
79
79
  }
80
80
  }
81
81
  }
@@ -1,7 +1,7 @@
1
- import { ClientContext } from '../clientContext.js';
2
- import CallToolObserver from './callToolObserver.js';
3
- import InstallObserver from './installObserver.js';
4
- import { SavePlaybookParams, SubmitFeedbackParams } from '../../shared/mcpServerTypes.js';
1
+ import { ClientContext } from "../clientContext.js";
2
+ import CallToolObserver from "./callToolObserver.js";
3
+ import InstallObserver from "./installObserver.js";
4
+ import { SavePlaybookParams, SubmitFeedbackParams } from "../../shared/mcpServerTypes.js";
5
5
  export declare class PolicyEnforcer {
6
6
  private playbookPolicy;
7
7
  private feedbackPolicy;
@@ -1,8 +1,8 @@
1
- import { PlaybookPolicy } from './playbookPolicy.js';
2
- import { FeedbackPolicy } from './feedbackPolicy.js';
3
- import CallToolObserver from './callToolObserver.js';
4
- import InstallObserver from './installObserver.js';
5
- import { ServerPolicy } from './serverPolicy.js';
1
+ import { PlaybookPolicy } from "./playbookPolicy.js";
2
+ import { FeedbackPolicy } from "./feedbackPolicy.js";
3
+ import CallToolObserver from "./callToolObserver.js";
4
+ import InstallObserver from "./installObserver.js";
5
+ import { ServerPolicy } from "./serverPolicy.js";
6
6
  export class PolicyEnforcer {
7
7
  constructor() {
8
8
  this.playbookPolicy = null;
@@ -27,7 +27,7 @@ export class PolicyEnforcer {
27
27
  */
28
28
  enforceSavePlaybookPolicy(playbook) {
29
29
  if (!this.playbookPolicy) {
30
- throw new Error('PolicyEnforcer not initialized');
30
+ throw new Error("PolicyEnforcer not initialized");
31
31
  }
32
32
  this.playbookPolicy.enforceSavePlaybookPolicy(playbook);
33
33
  }
@@ -37,7 +37,7 @@ export class PolicyEnforcer {
37
37
  */
38
38
  enforceFeedbackPolicy(feedback) {
39
39
  if (!this.feedbackPolicy) {
40
- throw new Error('PolicyEnforcer not initialized');
40
+ throw new Error("PolicyEnforcer not initialized");
41
41
  }
42
42
  this.feedbackPolicy.enforceFeedbackPolicy(feedback);
43
43
  }
@@ -47,7 +47,7 @@ export class PolicyEnforcer {
47
47
  */
48
48
  enforceCallToolPolicy(serverId) {
49
49
  if (!this.serverPolicy) {
50
- throw new Error('PolicyEnforcer not initialized');
50
+ throw new Error("PolicyEnforcer not initialized");
51
51
  }
52
52
  this.serverPolicy.enforceCallToolPolicy(serverId);
53
53
  }
@@ -57,7 +57,7 @@ export class PolicyEnforcer {
57
57
  */
58
58
  enforceUseServerPolicy(serverId) {
59
59
  if (!this.serverPolicy) {
60
- throw new Error('PolicyEnforcer not initialized');
60
+ throw new Error("PolicyEnforcer not initialized");
61
61
  }
62
62
  this.serverPolicy.enforceUseServerPolicy(serverId);
63
63
  }
@@ -67,7 +67,7 @@ export class PolicyEnforcer {
67
67
  */
68
68
  enforceLogPlaybookUsagePolicy() {
69
69
  if (!this.playbookPolicy) {
70
- throw new Error('PolicyEnforcer not initialized');
70
+ throw new Error("PolicyEnforcer not initialized");
71
71
  }
72
72
  this.playbookPolicy.enforceLogPlaybookUsagePolicy();
73
73
  }
@@ -80,7 +80,7 @@ export class PolicyEnforcer {
80
80
  */
81
81
  filterBlockedMcpServers(servers, getServerId) {
82
82
  if (!this.serverPolicy) {
83
- throw new Error('PolicyEnforcer not initialized');
83
+ throw new Error("PolicyEnforcer not initialized");
84
84
  }
85
85
  return this.serverPolicy.filterBlockedMcpServers(servers, getServerId);
86
86
  }
@@ -89,7 +89,7 @@ export class PolicyEnforcer {
89
89
  */
90
90
  getCallToolObserver() {
91
91
  if (!this.callToolObserver) {
92
- throw new Error('PolicyEnforcer not initialized');
92
+ throw new Error("PolicyEnforcer not initialized");
93
93
  }
94
94
  return this.callToolObserver;
95
95
  }
@@ -98,7 +98,7 @@ export class PolicyEnforcer {
98
98
  */
99
99
  getInstallObserver() {
100
100
  if (!this.installObserver) {
101
- throw new Error('PolicyEnforcer not initialized');
101
+ throw new Error("PolicyEnforcer not initialized");
102
102
  }
103
103
  return this.installObserver;
104
104
  }
@@ -1,4 +1,4 @@
1
- import { ClientContext } from '../clientContext.js';
1
+ import { ClientContext } from "../clientContext.js";
2
2
  export declare class ServerPolicy {
3
3
  private clientContext;
4
4
  private blockedMcpServersSet;
@@ -20,7 +20,9 @@ export class ServerPolicy {
20
20
  */
21
21
  enforceAllowedServerPolicy(serverId) {
22
22
  const allowedServers = this.clientContext.permissions.allowed_mcp_servers;
23
- if (allowedServers && allowedServers.length > 0 && !allowedServers.includes(serverId)) {
23
+ if (allowedServers &&
24
+ allowedServers.length > 0 &&
25
+ !allowedServers.includes(serverId)) {
24
26
  throw new Error(`Server "${serverId}" is not allowed for your account. Please adjust the Allowed MCP Servers permissions on the ToolPlex Dashboard if this is a mistake.`);
25
27
  }
26
28
  }
@@ -36,7 +38,7 @@ export class ServerPolicy {
36
38
  // Check if desktop commander is disabled and this is the desktop commander server
37
39
  if (!this.clientContext.permissions.use_desktop_commander &&
38
40
  serverId === this.clientContext.flags.desktop_commander_server_id) {
39
- throw new Error('Desktop Commander is disabled for your account');
41
+ throw new Error("Desktop Commander is disabled for your account");
40
42
  }
41
43
  }
42
44
  /**
@@ -18,7 +18,7 @@ export class PromptsCache {
18
18
  */
19
19
  getPrompt(key) {
20
20
  if (!this._prompts) {
21
- throw new Error('PromptsCache not initialized');
21
+ throw new Error("PromptsCache not initialized");
22
22
  }
23
23
  const prompt = this._prompts[key];
24
24
  if (!prompt) {
@@ -31,7 +31,7 @@ export class PromptsCache {
31
31
  */
32
32
  getVersion() {
33
33
  if (!this._version) {
34
- throw new Error('PromptsCache not initialized');
34
+ throw new Error("PromptsCache not initialized");
35
35
  }
36
36
  return this._version;
37
37
  }
@@ -1,11 +1,11 @@
1
- import { ClientContext } from './clientContext.js';
2
- import { ToolplexApiService } from './toolplexApi/service.js';
3
- import { StdioServerManagerClient } from '../shared/stdioServerManagerClient.js';
4
- import { TelemetryLogger } from './logging/telemetryLogger.js';
5
- import { PromptsCache } from './promptsCache.js';
6
- import { ToolDefinitionsCache } from './toolDefinitionsCache.js';
7
- import { ServersCache } from './serversCache.js';
8
- import { PolicyEnforcer } from './policy/policyEnforcer.js';
1
+ import { ClientContext } from "./clientContext.js";
2
+ import { ToolplexApiService } from "./toolplexApi/service.js";
3
+ import { StdioServerManagerClient } from "../shared/stdioServerManagerClient.js";
4
+ import { TelemetryLogger } from "./logging/telemetryLogger.js";
5
+ import { PromptsCache } from "./promptsCache.js";
6
+ import { ToolDefinitionsCache } from "./toolDefinitionsCache.js";
7
+ import { ServersCache } from "./serversCache.js";
8
+ import { PolicyEnforcer } from "./policy/policyEnforcer.js";
9
9
  /**
10
10
  * In-memory global registry for the ToolPlex client.
11
11
  * Maintains singleton instances of core services and clients used throughout the application.
@@ -1,17 +1,19 @@
1
- import { ToolplexApiService } from './toolplexApi/service.js';
2
- import { TelemetryLogger } from './logging/telemetryLogger.js';
3
- import { PromptsCache } from './promptsCache.js';
4
- import { ToolDefinitionsCache } from './toolDefinitionsCache.js';
5
- import { ServersCache } from './serversCache.js';
6
- import { PolicyEnforcer } from './policy/policyEnforcer.js';
1
+ import { ToolplexApiService } from "./toolplexApi/service.js";
2
+ import { TelemetryLogger } from "./logging/telemetryLogger.js";
3
+ import { PromptsCache } from "./promptsCache.js";
4
+ import { ToolDefinitionsCache } from "./toolDefinitionsCache.js";
5
+ import { ServersCache } from "./serversCache.js";
6
+ import { PolicyEnforcer } from "./policy/policyEnforcer.js";
7
7
  /**
8
8
  * In-memory global registry for the ToolPlex client.
9
9
  * Maintains singleton instances of core services and clients used throughout the application.
10
10
  */
11
11
  class Registry {
12
12
  static async init(clientContext) {
13
- if (this._clientContext || this._toolplexApiService || this._serverManagerClients) {
14
- throw new Error('Registry already initialized');
13
+ if (this._clientContext ||
14
+ this._toolplexApiService ||
15
+ this._serverManagerClients) {
16
+ throw new Error("Registry already initialized");
15
17
  }
16
18
  this._clientContext = clientContext;
17
19
  this._toolplexApiService = new ToolplexApiService(clientContext);
@@ -26,55 +28,55 @@ class Registry {
26
28
  }
27
29
  static getClientContext() {
28
30
  if (!this._clientContext) {
29
- throw new Error('ClientContext not initialized in Registry');
31
+ throw new Error("ClientContext not initialized in Registry");
30
32
  }
31
33
  return this._clientContext;
32
34
  }
33
35
  static getToolplexApiService() {
34
36
  if (!this._toolplexApiService) {
35
- throw new Error('ToolplexApiService not initialized in Registry');
37
+ throw new Error("ToolplexApiService not initialized in Registry");
36
38
  }
37
39
  return this._toolplexApiService;
38
40
  }
39
41
  static getServerManagerClients() {
40
42
  if (!this._serverManagerClients) {
41
- throw new Error('ServerManagerClients not initialized in Registry');
43
+ throw new Error("ServerManagerClients not initialized in Registry");
42
44
  }
43
45
  return this._serverManagerClients;
44
46
  }
45
47
  static setServerManagerClients(clients) {
46
48
  if (!this._serverManagerClients) {
47
- throw new Error('Registry not initialized');
49
+ throw new Error("Registry not initialized");
48
50
  }
49
51
  this._serverManagerClients = clients;
50
52
  }
51
53
  static getTelemetryLogger() {
52
54
  if (!this._telemetryLogger) {
53
- throw new Error('TelemetryLogger not initialized in Registry');
55
+ throw new Error("TelemetryLogger not initialized in Registry");
54
56
  }
55
57
  return this._telemetryLogger;
56
58
  }
57
59
  static getPromptsCache() {
58
60
  if (!this._promptsCache) {
59
- throw new Error('PromptsCache not initialized in Registry');
61
+ throw new Error("PromptsCache not initialized in Registry");
60
62
  }
61
63
  return this._promptsCache;
62
64
  }
63
65
  static getToolDefinitionsCache() {
64
66
  if (!this._toolDefinitionsCache) {
65
- throw new Error('ToolDefinitionsCache not initialized in Registry');
67
+ throw new Error("ToolDefinitionsCache not initialized in Registry");
66
68
  }
67
69
  return this._toolDefinitionsCache;
68
70
  }
69
71
  static getServersCache() {
70
72
  if (!this._serversCache) {
71
- throw new Error('ServersCache not initialized in Registry');
73
+ throw new Error("ServersCache not initialized in Registry");
72
74
  }
73
75
  return this._serversCache;
74
76
  }
75
77
  static getPolicyEnforcer() {
76
78
  if (!this._policyEnforcer) {
77
- throw new Error('PolicyEnforcer not initialized in Registry');
79
+ throw new Error("PolicyEnforcer not initialized in Registry");
78
80
  }
79
81
  return this._policyEnforcer;
80
82
  }
@@ -1,4 +1,4 @@
1
- import { StdioServerManagerClient } from '../shared/stdioServerManagerClient.js';
1
+ import { StdioServerManagerClient } from "../shared/stdioServerManagerClient.js";
2
2
  type ServerInfo = {
3
3
  server_id: string;
4
4
  server_name: string;
@@ -1,5 +1,5 @@
1
- import { ListServersResultSchema } from '../shared/serverManagerTypes.js';
2
- import { FileLogger } from '../shared/fileLogger.js';
1
+ import { ListServersResultSchema } from "../shared/serverManagerTypes.js";
2
+ import { FileLogger } from "../shared/fileLogger.js";
3
3
  const logger = FileLogger;
4
4
  /**
5
5
  * An in-memory cache that tracks currently installed servers.
@@ -32,7 +32,7 @@ export class ServersCache {
32
32
  */
33
33
  isInstalled(serverId) {
34
34
  if (!this.isInitialized()) {
35
- throw new Error('ServersCache not initialized');
35
+ throw new Error("ServersCache not initialized");
36
36
  }
37
37
  if (!serverId) {
38
38
  throw new Error(`Invalid serverId: "${serverId}"`);
@@ -44,7 +44,7 @@ export class ServersCache {
44
44
  */
45
45
  getServerIds() {
46
46
  if (!this._serverIds) {
47
- throw new Error('ServersCache not initialized');
47
+ throw new Error("ServersCache not initialized");
48
48
  }
49
49
  return Array.from(this._serverIds);
50
50
  }
@@ -60,7 +60,7 @@ export class ServersCache {
60
60
  const allServerIds = new Set();
61
61
  for (const [runtime, client] of Object.entries(serverManagerClients)) {
62
62
  try {
63
- const response_data = await client.sendRequest('list_servers', {});
63
+ const response_data = await client.sendRequest("list_servers", {});
64
64
  if (response_data.error) {
65
65
  await logger.warn(`Error from server manager client "${runtime}": ${response_data.error}`);
66
66
  continue;
@@ -72,7 +72,7 @@ export class ServersCache {
72
72
  }
73
73
  if (parsed.data.servers && parsed.data.servers.length > 0) {
74
74
  for (const server of parsed.data.servers) {
75
- if (server && typeof server.server_id === 'string') {
75
+ if (server && typeof server.server_id === "string") {
76
76
  allServerIds.add(server.server_id);
77
77
  }
78
78
  }
@@ -1,6 +1,6 @@
1
1
  export const PRE_INITIALIZATION_PROMPTS = {
2
2
  tools_initialization_error: `ERROR: Unable to connect to ToolPlex. Please check your API key and network connection. If the problem persists, contact support at support@toolplex.ai for assistance.`,
3
3
  enforce_init_toolplex: `ERROR: Attempted to call tool {TOOL_NAME} before calling initalize_toolplex().\nPlease init and retry.`,
4
- unknown_tool: 'Unknown tool: {TOOL_NAME}. Use list_toolplex_tools() to see available tools.',
5
- unexpected_error: 'Unexpected error: {ERROR}',
4
+ unknown_tool: "Unknown tool: {TOOL_NAME}. Use list_toolplex_tools() to see available tools.",
5
+ unexpected_error: "Unexpected error: {ERROR}",
6
6
  };
@@ -1,6 +1,6 @@
1
- import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
- import { ToolplexApiService } from './toolplexApi/service.js';
3
- import { ClientContext } from './clientContext.js';
1
+ import { Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import { ToolplexApiService } from "./toolplexApi/service.js";
3
+ import { ClientContext } from "./clientContext.js";
4
4
  export declare class ToolDefinitionsCache {
5
5
  private _tools;
6
6
  private _version;