@toolplex/client 0.1.2 → 0.1.4
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/toolHandlers/callToolHandler.js +10 -0
- package/dist/mcp-server/toolHandlers/initHandler.js +6 -0
- package/dist/mcp-server/toolHandlers/savePlaybookHandler.js +2 -2
- package/dist/mcp-server/toolHandlers/searchHandler.js +4 -1
- package/dist/mcp-server/toolplexApi/service.d.ts +2 -2
- package/dist/mcp-server/toolplexApi/service.js +4 -2
- package/dist/mcp-server/toolplexApi/types.d.ts +2 -0
- package/dist/shared/mcpServerTypes.d.ts +6 -0
- package/dist/shared/mcpServerTypes.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,14 @@ import { CallToolResultSchema } from "../../shared/serverManagerTypes.js";
|
|
|
3
3
|
import { FileLogger } from "../../shared/fileLogger.js";
|
|
4
4
|
import Registry from "../registry.js";
|
|
5
5
|
const logger = FileLogger;
|
|
6
|
+
function safeLength(obj) {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.stringify(obj).length;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
6
14
|
export async function handleCallTool(params) {
|
|
7
15
|
await logger.debug(`Handling call tool request with params: ${JSON.stringify(params)}`);
|
|
8
16
|
const serverManagerClients = Registry.getServerManagerClients();
|
|
@@ -42,6 +50,8 @@ export async function handleCallTool(params) {
|
|
|
42
50
|
log_context: {
|
|
43
51
|
server_id: params.server_id,
|
|
44
52
|
tool_name: params.tool_name,
|
|
53
|
+
input_length: safeLength(params),
|
|
54
|
+
response_length: safeLength(content),
|
|
45
55
|
},
|
|
46
56
|
latency_ms: Date.now() - startTime,
|
|
47
57
|
});
|
|
@@ -100,6 +100,12 @@ export async function handleInitialize(params) {
|
|
|
100
100
|
.join("\n") +
|
|
101
101
|
"\n\nMore playbooks are available through the search tool.",
|
|
102
102
|
});
|
|
103
|
+
if (toolplexApiInitResponse.announcement) {
|
|
104
|
+
result.content.push({
|
|
105
|
+
type: "text",
|
|
106
|
+
text: `\nToolPlex Platform Announcements: ${toolplexApiInitResponse.announcement}`,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
103
109
|
await telemetryLogger.log("client_initialize_toolplex", {
|
|
104
110
|
session_id: toolplexApiInitResponse.session_id,
|
|
105
111
|
success: Object.keys(allFailures).length === 0,
|
|
@@ -21,8 +21,8 @@ export async function handleSavePlaybook(params) {
|
|
|
21
21
|
}
|
|
22
22
|
// Enforce playbook policy before saving
|
|
23
23
|
policyEnforcer.enforceSavePlaybookPolicy(params);
|
|
24
|
-
const { description, actions, domain, keywords, requirements, source_playbook_id, fork_reason, } = params;
|
|
25
|
-
const response = await apiService.createPlaybook(description, actions, domain, keywords, requirements, source_playbook_id, fork_reason);
|
|
24
|
+
const { description, actions, domain, keywords, requirements, privacy, source_playbook_id, fork_reason, } = params;
|
|
25
|
+
const response = await apiService.createPlaybook(description, actions, domain, keywords, requirements, privacy, source_playbook_id, fork_reason);
|
|
26
26
|
await logger.info(`Playbook created successfully with ID: ${response.id}`);
|
|
27
27
|
await telemetryLogger.log("client_save_playbook", {
|
|
28
28
|
success: true,
|
|
@@ -15,18 +15,20 @@ export async function handleSearchTool(params) {
|
|
|
15
15
|
const expandedKeywords = params.expanded_keywords || [];
|
|
16
16
|
const filter = params.filter || "all";
|
|
17
17
|
const size = params.size || 10;
|
|
18
|
+
const scope = params.scope || "all";
|
|
18
19
|
try {
|
|
19
20
|
// Check if the client is in restricted mode
|
|
20
21
|
if (clientContext.clientMode === "restricted") {
|
|
21
22
|
throw new Error("Search functionality is disabled in restricted mode.");
|
|
22
23
|
}
|
|
23
|
-
const results = await apiService.search(query, expandedKeywords, filter, size);
|
|
24
|
+
const results = await apiService.search(query, expandedKeywords, filter, size, scope);
|
|
24
25
|
// Log telemetry event
|
|
25
26
|
await telemetryLogger.log("client_search", {
|
|
26
27
|
success: true,
|
|
27
28
|
log_context: {
|
|
28
29
|
filter,
|
|
29
30
|
size,
|
|
31
|
+
scope,
|
|
30
32
|
num_expanded_keywords: expandedKeywords.length,
|
|
31
33
|
num_results: (results.mcp_servers?.length ?? -1) +
|
|
32
34
|
(results.playbooks?.length ?? -1),
|
|
@@ -99,6 +101,7 @@ export async function handleSearchTool(params) {
|
|
|
99
101
|
log_context: {
|
|
100
102
|
filter,
|
|
101
103
|
size,
|
|
104
|
+
scope,
|
|
102
105
|
num_expanded_keywords: expandedKeywords.length,
|
|
103
106
|
},
|
|
104
107
|
pii_sanitized_error_message: errorMessage,
|
|
@@ -21,11 +21,11 @@ export declare class ToolplexApiService {
|
|
|
21
21
|
data: Partial<Omit<LogTelemetryRequest, "event_type">>;
|
|
22
22
|
}>): Promise<LogTelemetryBatchResponse>;
|
|
23
23
|
lookupEntity(entityType: "server" | "playbook" | "feedback", entityId: string): Promise<any>;
|
|
24
|
-
search(query: string, expandedKeywords?: string[], filter?: string, size?: number): Promise<{
|
|
24
|
+
search(query: string, expandedKeywords?: string[], filter?: string, size?: number, scope?: string): Promise<{
|
|
25
25
|
mcp_servers?: any[];
|
|
26
26
|
playbooks?: any[];
|
|
27
27
|
}>;
|
|
28
|
-
createPlaybook(description: string, actions: Array<PlaybookAction>, domain?: string, keywords?: string[], requirements?: string[], sourcePlaybookId?: string, forkReason?: string): Promise<CreatePlaybookResponse>;
|
|
28
|
+
createPlaybook(description: string, actions: Array<PlaybookAction>, domain?: string, keywords?: string[], requirements?: string[], privacy?: "public" | "private", sourcePlaybookId?: string, forkReason?: string): Promise<CreatePlaybookResponse>;
|
|
29
29
|
logPlaybookUsage(playbookId: string, success: boolean, errorMessage?: string): Promise<LogPlaybookUsageResponse>;
|
|
30
30
|
submitFeedback(targetType: "server" | "playbook", targetId: string, vote: "up" | "down", message?: string, securityAssessment?: SecurityAssessment): Promise<SubmitFeedbackResponse>;
|
|
31
31
|
getFeedbackSummary(): Promise<FeedbackSummaryResponse>;
|
|
@@ -110,12 +110,13 @@ export class ToolplexApiService {
|
|
|
110
110
|
throw err;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
async search(query, expandedKeywords = [], filter = "all", size = 10) {
|
|
113
|
+
async search(query, expandedKeywords = [], filter = "all", size = 10, scope = "all") {
|
|
114
114
|
const requestBody = {
|
|
115
115
|
query,
|
|
116
116
|
expanded_keywords: expandedKeywords,
|
|
117
117
|
filter,
|
|
118
118
|
size,
|
|
119
|
+
scope,
|
|
119
120
|
};
|
|
120
121
|
await logger.debug(`Searching API at ${this.baseUrl} with query: ${query}`);
|
|
121
122
|
try {
|
|
@@ -135,7 +136,7 @@ export class ToolplexApiService {
|
|
|
135
136
|
throw err;
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
|
-
async createPlaybook(description, actions, domain, keywords, requirements, sourcePlaybookId, forkReason) {
|
|
139
|
+
async createPlaybook(description, actions, domain, keywords, requirements, privacy, sourcePlaybookId, forkReason) {
|
|
139
140
|
const requestBody = {
|
|
140
141
|
description,
|
|
141
142
|
actions,
|
|
@@ -143,6 +144,7 @@ export class ToolplexApiService {
|
|
|
143
144
|
domain,
|
|
144
145
|
keywords,
|
|
145
146
|
requirements,
|
|
147
|
+
privacy,
|
|
146
148
|
source_playbook_id: sourcePlaybookId,
|
|
147
149
|
fork_reason: forkReason,
|
|
148
150
|
};
|
|
@@ -23,6 +23,7 @@ export interface InitResponse {
|
|
|
23
23
|
is_org_user: boolean;
|
|
24
24
|
prompts: Record<string, string>;
|
|
25
25
|
permissions: ClientPermissions;
|
|
26
|
+
announcement?: string;
|
|
26
27
|
flags: ClientFlags;
|
|
27
28
|
}
|
|
28
29
|
export type SecurityFlag = string;
|
|
@@ -51,6 +52,7 @@ export interface CreatePlaybookRequest {
|
|
|
51
52
|
domain?: string;
|
|
52
53
|
keywords?: string[];
|
|
53
54
|
requirements?: string[];
|
|
55
|
+
privacy?: "public" | "private";
|
|
54
56
|
source_playbook_id?: string;
|
|
55
57
|
fork_reason?: string;
|
|
56
58
|
}
|
|
@@ -96,16 +96,19 @@ export declare const SearchParamsSchema: z.ZodObject<{
|
|
|
96
96
|
expanded_keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
97
97
|
filter: z.ZodOptional<z.ZodEnum<["all", "servers_only", "playbooks_only"]>>;
|
|
98
98
|
size: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
scope: z.ZodOptional<z.ZodEnum<["all", "public_only", "private_only"]>>;
|
|
99
100
|
}, "strip", z.ZodTypeAny, {
|
|
100
101
|
query: string;
|
|
101
102
|
filter?: "all" | "servers_only" | "playbooks_only" | undefined;
|
|
102
103
|
expanded_keywords?: string[] | undefined;
|
|
103
104
|
size?: number | undefined;
|
|
105
|
+
scope?: "all" | "public_only" | "private_only" | undefined;
|
|
104
106
|
}, {
|
|
105
107
|
query: string;
|
|
106
108
|
filter?: "all" | "servers_only" | "playbooks_only" | undefined;
|
|
107
109
|
expanded_keywords?: string[] | undefined;
|
|
108
110
|
size?: number | undefined;
|
|
111
|
+
scope?: "all" | "public_only" | "private_only" | undefined;
|
|
109
112
|
}>;
|
|
110
113
|
export type SearchParams = z.infer<typeof SearchParamsSchema>;
|
|
111
114
|
export declare const LookupEntityParamsSchema: z.ZodObject<{
|
|
@@ -295,6 +298,7 @@ export declare const SavePlaybookParamsSchema: z.ZodObject<{
|
|
|
295
298
|
domain: z.ZodOptional<z.ZodString>;
|
|
296
299
|
keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
297
300
|
requirements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
301
|
+
privacy: z.ZodOptional<z.ZodEnum<["public", "private"]>>;
|
|
298
302
|
source_playbook_id: z.ZodOptional<z.ZodString>;
|
|
299
303
|
fork_reason: z.ZodOptional<z.ZodString>;
|
|
300
304
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -310,6 +314,7 @@ export declare const SavePlaybookParamsSchema: z.ZodObject<{
|
|
|
310
314
|
domain?: string | undefined;
|
|
311
315
|
keywords?: string[] | undefined;
|
|
312
316
|
requirements?: string[] | undefined;
|
|
317
|
+
privacy?: "public" | "private" | undefined;
|
|
313
318
|
source_playbook_id?: string | undefined;
|
|
314
319
|
fork_reason?: string | undefined;
|
|
315
320
|
}, {
|
|
@@ -325,6 +330,7 @@ export declare const SavePlaybookParamsSchema: z.ZodObject<{
|
|
|
325
330
|
domain?: string | undefined;
|
|
326
331
|
keywords?: string[] | undefined;
|
|
327
332
|
requirements?: string[] | undefined;
|
|
333
|
+
privacy?: "public" | "private" | undefined;
|
|
328
334
|
source_playbook_id?: string | undefined;
|
|
329
335
|
fork_reason?: string | undefined;
|
|
330
336
|
}>;
|
|
@@ -43,6 +43,7 @@ export const SearchParamsSchema = z.object({
|
|
|
43
43
|
expanded_keywords: z.array(z.string()).optional(),
|
|
44
44
|
filter: z.enum(["all", "servers_only", "playbooks_only"]).optional(),
|
|
45
45
|
size: z.number().int().min(1).max(25).optional(),
|
|
46
|
+
scope: z.enum(["all", "public_only", "private_only"]).optional(),
|
|
46
47
|
});
|
|
47
48
|
// --------------------
|
|
48
49
|
// LookupEntityParams
|
|
@@ -121,6 +122,7 @@ export const SavePlaybookParamsSchema = z.object({
|
|
|
121
122
|
domain: z.string().optional(),
|
|
122
123
|
keywords: z.array(z.string()).optional(),
|
|
123
124
|
requirements: z.array(z.string()).optional(),
|
|
125
|
+
privacy: z.enum(["public", "private"]).optional(),
|
|
124
126
|
source_playbook_id: z.string().optional(),
|
|
125
127
|
fork_reason: z.string().optional(),
|
|
126
128
|
});
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.1.
|
|
1
|
+
export declare const version = "0.1.4";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.1.
|
|
1
|
+
export const version = '0.1.4';
|