mcp-meilisearch 1.4.14 → 1.4.16

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 CHANGED
@@ -97,21 +97,28 @@ await client.connectToServer("http://localhost:4995/mcp");
97
97
  const result = await client.callTool("global-search", {
98
98
  q: "search kiosco antonio",
99
99
  });
100
+ ```
100
101
 
101
- // Use AI inference to choose the most appropriate tool
102
+ #### Client Methods
102
103
 
103
- const result = await client.callToolWithAI("Find articles about cucumber", {
104
- provideSummary: true,
105
- });
106
- console.log(`Tool used: ${result.toolUsed}`);
107
- console.log(`Reasoning: ${result.reasoning}`);
108
- console.log(`Results: ${JSON.stringify(result.data)}`);
109
- console.log(`Summary: ${result.summary}`);
110
- ```
104
+ ##### `callTool(name, args)`
105
+
106
+ Calls a specific tool on the MCP server with optional arguments.
107
+
108
+ **Parameters:**
109
+
110
+ - `name`: String - The name of the tool to call
111
+ - `args`: Object (Optional) - Arguments to pass to the tool
112
+
113
+ ##### `processSummary(query)`
114
+
115
+ Processes data using AI to generate a human-readable summary.
116
+
117
+ **Parameters:**
111
118
 
112
- #### AI Inference Client Methods
119
+ - `query`: Any - The data to be summarized
113
120
 
114
- #### `callToolWithAI(query, options)`
121
+ ##### `callToolWithAI(query, options)`
115
122
 
116
123
  Processes a user query through AI to determine and execute the most appropriate tool.
117
124
 
@@ -120,8 +127,7 @@ Processes a user query through AI to determine and execute the most appropriate
120
127
  - `query`: String - The user's query or request to be processed
121
128
  - `options`: Object (Optional) - Configuration options
122
129
  - `specificTools`: String[] (Optional) - Restricts tool selection to this list of tool names
123
- - `justReasoning`: Boolean (Optional) - When set to `true`, returns only the AI's reasoning without executing the
124
- selected tool
130
+ - `justReasoning`: Boolean (Optional) - When set to `true`, returns only the AI's reasoning without executing the selected tool
125
131
  - `provideSummary`: Boolean (Optional) - When set to `true`, generates a concise summary of the search results along with the regular response
126
132
 
127
133
  ### Starting the Server
package/dist/client.d.ts CHANGED
@@ -1,16 +1,18 @@
1
- interface AIToolClientOptions {
2
- specificTools?: string[];
3
- justReasoning?: boolean;
4
- provideSummary?: boolean;
5
- }
6
- interface AIToolClientResponse {
1
+ interface ToolClientResponse {
7
2
  data?: any;
8
- summary?: any;
9
3
  error?: string;
10
4
  success: boolean;
5
+ }
6
+ interface SearchToolClientResponse extends ToolClientResponse {
7
+ summary?: any;
11
8
  toolUsed?: string;
12
9
  reasoning?: string;
13
10
  }
11
+ interface SearchToolClientOptions {
12
+ specificTools?: string[];
13
+ justReasoning?: boolean;
14
+ provideSummary?: boolean;
15
+ }
14
16
  export declare class MCPClient {
15
17
  /**
16
18
  * Indicates whether the client is connected to the MCP server
@@ -52,8 +54,6 @@ export declare class MCPClient {
52
54
  * @throws Error if connection fails after 5 attempts
53
55
  */
54
56
  connectToServer(serverUrl: string): Promise<void>;
55
- private listTools;
56
- private setUpNotifications;
57
57
  /**
58
58
  * Calls a tool on the MCP server with optional arguments
59
59
  * Parses and processes the response from the server
@@ -62,11 +62,7 @@ export declare class MCPClient {
62
62
  * @throws Error if the tool call fails
63
63
  * @returns Object containing success status and either data or error message
64
64
  */
65
- callTool(name: string, args?: Record<string, any>): Promise<{
66
- success: boolean;
67
- data?: any;
68
- error?: string;
69
- }>;
65
+ callTool(name: string, args?: Record<string, any>): Promise<ToolClientResponse>;
70
66
  /**
71
67
  * Process a user query through the AI to determine which tool to use
72
68
  * @param query The user's query
@@ -77,13 +73,21 @@ export declare class MCPClient {
77
73
  * @throws Error if AI inference fails
78
74
  * @returns The result of calling the selected tool, or an error
79
75
  */
80
- callToolWithAI(query: string, options?: AIToolClientOptions): Promise<AIToolClientResponse>;
81
- private setUpTransport;
76
+ callToolWithAI(query: string, options?: SearchToolClientOptions): Promise<SearchToolClientResponse>;
77
+ /**
78
+ * Process a summary text using AI
79
+ * @param query The natural language query to process
80
+ * @throws Error if AI inference fails
81
+ */
82
+ processSummary(query: any): Promise<ToolClientResponse>;
82
83
  /**
83
84
  * Closes the connection to the server and resets the connection state
84
85
  * Called automatically on transport error or can be called manually
85
86
  */
86
87
  cleanup(): Promise<void>;
88
+ private listTools;
89
+ private setUpNotifications;
90
+ private setUpTransport;
87
91
  }
88
92
  export {};
89
93
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,UAAU,mBAAmB;IAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,UAAU,oBAAoB;IAC5B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,SAAS;IACpB;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAS;IAE7B;;;OAGG;IACH,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACjC,EAAE,CAAM;IAET,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,oBAAoB,CAEZ;gBAEJ,UAAU,EAAE,MAAM;IAI9B;;;OAGG;IACH,sBAAsB,CACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI;IAKzE;;;;;OAKG;IACG,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,C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- async listTools() {
67
- try {
68
- const toolsResult = await this.client.listTools();
69
- if (!toolsResult) {
70
- this.tools = [];
71
- }
72
- else if (toolsResult.tools && Array.isArray(toolsResult.tools)) {
73
- this.tools = toolsResult.tools
74
- .filter(({ annotations }) => annotations?.category !== "core")
75
- .map((tool) => ({
76
- name: tool.name,
77
- description: tool.description ?? "",
78
- parameters: tool.parameters || {},
79
- }));
80
- }
81
- else {
82
- this.tools = [];
83
- }
84
- }
85
- catch (error) {
86
- this.tools = [];
87
- }
88
- finally {
89
- if (this.toolsUpdatedCallback) {
90
- this.toolsUpdatedCallback([...this.tools]);
91
- }
92
- }
93
- }
94
- setUpNotifications() {
95
- this.client.setNotificationHandler(LoggingMessageNotificationSchema, console.info);
96
- this.client.setNotificationHandler(ToolListChangedNotificationSchema, this.listTools);
97
- }
98
66
  /**
99
67
  * Calls a tool on the MCP server with optional arguments
100
68
  * Parses and processes the response from the server
@@ -183,11 +151,7 @@ export class MCPClient {
183
151
  toolUsed: toolName,
184
152
  };
185
153
  if (provideSummary) {
186
- const summary = await this.callTool("process-ai-text", {
187
- query: JSON.stringify(toolResult.data),
188
- });
189
- if (!summary.success)
190
- console.error(summary);
154
+ const summary = await this.processSummary(toolResult.data);
191
155
  response["summary"] = summary.data;
192
156
  }
193
157
  return response;
@@ -200,10 +164,18 @@ export class MCPClient {
200
164
  };
201
165
  }
202
166
  }
203
- setUpTransport() {
204
- if (this.transport == null)
205
- return;
206
- this.transport.onerror = this.cleanup;
167
+ /**
168
+ * Process a summary text using AI
169
+ * @param query The natural language query to process
170
+ * @throws Error if AI inference fails
171
+ */
172
+ async processSummary(query) {
173
+ const result = await this.callTool("process-ai-text", {
174
+ query: JSON.stringify(query),
175
+ });
176
+ if (!result.success)
177
+ console.error(result);
178
+ return result;
207
179
  }
208
180
  /**
209
181
  * Closes the connection to the server and resets the connection state
@@ -215,4 +187,41 @@ export class MCPClient {
215
187
  await this.client.close();
216
188
  this.isConnected = false;
217
189
  }
190
+ async listTools() {
191
+ try {
192
+ const toolsResult = await this.client.listTools();
193
+ if (!toolsResult) {
194
+ this.tools = [];
195
+ }
196
+ else if (toolsResult.tools && Array.isArray(toolsResult.tools)) {
197
+ this.tools = toolsResult.tools
198
+ .filter(({ annotations }) => annotations?.category !== "core")
199
+ .map((tool) => ({
200
+ name: tool.name,
201
+ parameters: tool.parameters || {},
202
+ description: tool.description ?? "",
203
+ }));
204
+ }
205
+ else {
206
+ this.tools = [];
207
+ }
208
+ }
209
+ catch (error) {
210
+ this.tools = [];
211
+ }
212
+ finally {
213
+ if (this.toolsUpdatedCallback) {
214
+ this.toolsUpdatedCallback([...this.tools]);
215
+ }
216
+ }
217
+ }
218
+ setUpNotifications() {
219
+ this.client.setNotificationHandler(LoggingMessageNotificationSchema, console.info);
220
+ this.client.setNotificationHandler(ToolListChangedNotificationSchema, this.listTools);
221
+ }
222
+ setUpTransport() {
223
+ if (this.transport == null)
224
+ return;
225
+ this.transport.onerror = this.cleanup;
226
+ }
218
227
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-meilisearch",
3
- "version": "1.4.14",
3
+ "version": "1.4.16",
4
4
  "description": "Model Context Protocol (MCP) implementation for Meilisearch",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",