@toolplex/client 0.1.15 → 0.1.17

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.
@@ -40,11 +40,7 @@ export async function handleGetServerConfig(params) {
40
40
  content: [
41
41
  {
42
42
  type: "text",
43
- text: promptsCache
44
- .getPrompt("get_server_config_header")
45
- .replace("{SERVER_ID}", server_id) +
46
- "\n" +
47
- JSON.stringify(config, null, 2),
43
+ text: JSON.stringify(config, null, 2),
48
44
  },
49
45
  ],
50
46
  };
@@ -22,6 +22,24 @@ export async function handleSearchTool(params) {
22
22
  throw new Error("Search functionality is disabled in restricted mode.");
23
23
  }
24
24
  const results = await apiService.search(query, expandedKeywords, filter, size, scope);
25
+ // Handle both unified format (entities) and legacy format (mcp_servers/playbooks)
26
+ let totalResults = 0;
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ let servers = [];
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ let playbooks = [];
31
+ if (results.entities) {
32
+ // Unified format (v0.1.16+) - split entities by type for annotation
33
+ totalResults = results.entities.length;
34
+ servers = results.entities.filter((e) => e.type === "server" || e.server_id);
35
+ playbooks = results.entities.filter((e) => e.type === "playbook" || e.playbook_id);
36
+ }
37
+ else {
38
+ // Legacy format (< v0.1.16) - separate arrays
39
+ servers = Array.isArray(results.mcp_servers) ? results.mcp_servers : [];
40
+ playbooks = Array.isArray(results.playbooks) ? results.playbooks : [];
41
+ totalResults = servers.length + playbooks.length;
42
+ }
25
43
  // Log telemetry event
26
44
  await telemetryLogger.log("client_search", {
27
45
  success: true,
@@ -30,28 +48,10 @@ export async function handleSearchTool(params) {
30
48
  size,
31
49
  scope,
32
50
  num_expanded_keywords: expandedKeywords.length,
33
- num_results: (results.mcp_servers?.length ?? -1) +
34
- (results.playbooks?.length ?? -1),
51
+ num_results: totalResults,
35
52
  },
36
53
  latency_ms: Date.now() - startTime,
37
54
  });
38
- const mcpServers = Array.isArray(results.mcp_servers)
39
- ? results.mcp_servers
40
- : [];
41
- const playbooks = Array.isArray(results.playbooks) ? results.playbooks : [];
42
- const totalResults = mcpServers.length + playbooks.length;
43
- // Annotate installed servers using resultAnnotators
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- let annotatedServers = [];
46
- if (mcpServers.length > 0) {
47
- try {
48
- annotatedServers = annotateInstalledServers(mcpServers, serversCache);
49
- }
50
- catch (err) {
51
- await logger.warn(`Error annotating installed servers: ${err}`);
52
- annotatedServers = mcpServers;
53
- }
54
- }
55
55
  if (totalResults === 0) {
56
56
  await logger.info("No search results found");
57
57
  return {
@@ -64,23 +64,62 @@ export async function handleSearchTool(params) {
64
64
  };
65
65
  }
66
66
  await logger.debug(`Found ${totalResults} results`);
67
+ // Annotate installed servers
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ let annotatedServers = servers;
70
+ if (servers.length > 0) {
71
+ try {
72
+ annotatedServers = annotateInstalledServers(servers, serversCache);
73
+ }
74
+ catch (err) {
75
+ await logger.warn(`Error annotating installed servers: ${err}`);
76
+ }
77
+ }
78
+ // Rebuild response in the same format we received it
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ let responseData;
81
+ if (results.entities) {
82
+ // Unified format - rebuild entities array preserving backend ranking
83
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
+ const annotatedEntities = results.entities.map((entity) => {
85
+ if (entity.type === "server" || entity.server_id) {
86
+ // Find annotated version
87
+ const annotated = annotatedServers.find((s) => s.server_id === (entity.server_id || entity.id));
88
+ return annotated || entity;
89
+ }
90
+ return entity;
91
+ });
92
+ responseData = {
93
+ query,
94
+ expanded_keywords: expandedKeywords,
95
+ filter,
96
+ scope,
97
+ size,
98
+ entities: annotatedEntities,
99
+ total_results: totalResults,
100
+ };
101
+ }
102
+ else {
103
+ // Legacy format - return separate arrays
104
+ responseData = {
105
+ query,
106
+ expanded_keywords: expandedKeywords,
107
+ filter,
108
+ scope,
109
+ size,
110
+ servers: annotatedServers,
111
+ playbooks,
112
+ server_count: annotatedServers.length,
113
+ playbook_count: playbooks.length,
114
+ total_results: totalResults,
115
+ };
116
+ }
67
117
  // Build structured response content
68
118
  const content = [
69
119
  // First: Structured JSON for easy parsing
70
120
  {
71
121
  type: "text",
72
- text: JSON.stringify({
73
- query,
74
- expanded_keywords: expandedKeywords,
75
- filter,
76
- scope,
77
- size,
78
- servers: annotatedServers,
79
- playbooks,
80
- server_count: annotatedServers.length,
81
- playbook_count: playbooks.length,
82
- total_results: totalResults,
83
- }),
122
+ text: JSON.stringify(responseData),
84
123
  },
85
124
  // Second: Followup instructions
86
125
  {
@@ -1,4 +1,4 @@
1
- import { CreatePlaybookResponse, LogPlaybookUsageResponse, SubmitFeedbackResponse, SecurityAssessment, FeedbackSummaryResponse, LogTelemetryRequest, LogTelemetryBatchResponse, InitResponse } from "./types.js";
1
+ import { CreatePlaybookResponse, LogPlaybookUsageResponse, SubmitFeedbackResponse, SecurityAssessment, FeedbackSummaryResponse, LogTelemetryRequest, LogTelemetryBatchResponse, InitResponse, SearchResponse } from "./types.js";
2
2
  import { ClientContext } from "../clientContext.js";
3
3
  import { Tool } from "@modelcontextprotocol/sdk/types.js";
4
4
  import { PlaybookAction } from "../../shared/mcpServerTypes.js";
@@ -21,10 +21,7 @@ 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, scope?: string): Promise<{
25
- mcp_servers?: any[];
26
- playbooks?: any[];
27
- }>;
24
+ search(query: string, expandedKeywords?: string[], filter?: string, size?: number, scope?: string): Promise<SearchResponse>;
28
25
  createPlaybook(playbook_name: string, description: string, actions: Array<PlaybookAction>, domain?: string, keywords?: string[], requirements?: string[], privacy?: "public" | "private", sourcePlaybookId?: string, forkReason?: string): Promise<CreatePlaybookResponse>;
29
26
  logPlaybookUsage(playbookId: string, success: boolean, errorMessage?: string): Promise<LogPlaybookUsageResponse>;
30
27
  submitFeedback(targetType: "server" | "playbook", targetId: string, vote: "up" | "down", message?: string, securityAssessment?: SecurityAssessment): Promise<SubmitFeedbackResponse>;
@@ -122,6 +122,7 @@ export interface LogTelemetryBatchResponse {
122
122
  success: boolean;
123
123
  }
124
124
  export interface SearchResponse {
125
+ entities?: any[];
125
126
  mcp_servers?: any[];
126
127
  playbooks?: any[];
127
128
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "0.1.15";
1
+ export declare const version = "0.1.17";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '0.1.15';
1
+ export const version = '0.1.17';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolplex/client",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "author": "ToolPlex LLC",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "description": "The official ToolPlex client for AI agent tool discovery and execution",