mcp-meilisearch 1.4.15 → 1.4.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.
package/README.md CHANGED
@@ -110,13 +110,6 @@ Calls a specific tool on the MCP server with optional arguments.
110
110
  - `name`: String - The name of the tool to call
111
111
  - `args`: Object (Optional) - Arguments to pass to the tool
112
112
 
113
- **Returns:**
114
-
115
- - Promise resolving to a `ToolClientResponse` object with:
116
- - `success`: Boolean - Whether the tool call was successful
117
- - `data`: Any (Optional) - The data returned by the tool if successful
118
- - `error`: String (Optional) - Error message if the tool call failed
119
-
120
113
  ##### `processSummary(query)`
121
114
 
122
115
  Processes data using AI to generate a human-readable summary.
@@ -125,13 +118,6 @@ Processes data using AI to generate a human-readable summary.
125
118
 
126
119
  - `query`: Any - The data to be summarized
127
120
 
128
- **Returns:**
129
-
130
- - Promise resolving to an `AIToolClientResponse` object with:
131
- - `success`: Boolean - Whether the summary generation was successful
132
- - `data`: Any (Optional) - The generated summary if successful
133
- - `error`: String (Optional) - Error message if summary generation failed
134
-
135
121
  ##### `callToolWithAI(query, options)`
136
122
 
137
123
  Processes a user query through AI to determine and execute the most appropriate tool.
package/dist/client.d.ts CHANGED
@@ -3,12 +3,12 @@ interface ToolClientResponse {
3
3
  error?: string;
4
4
  success: boolean;
5
5
  }
6
- interface AIToolClientResponse extends ToolClientResponse {
6
+ interface SearchToolClientResponse extends ToolClientResponse {
7
7
  summary?: any;
8
8
  toolUsed?: string;
9
9
  reasoning?: string;
10
10
  }
11
- interface AIToolClientOptions {
11
+ interface SearchToolClientOptions {
12
12
  specificTools?: string[];
13
13
  justReasoning?: boolean;
14
14
  provideSummary?: boolean;
@@ -73,13 +73,13 @@ export declare class MCPClient {
73
73
  * @throws Error if AI inference fails
74
74
  * @returns The result of calling the selected tool, or an error
75
75
  */
76
- callToolWithAI(query: string, options?: AIToolClientOptions): Promise<AIToolClientResponse>;
76
+ callToolWithAI(query: string, options?: SearchToolClientOptions): Promise<SearchToolClientResponse>;
77
77
  /**
78
78
  * Process a summary text using AI
79
79
  * @param query The natural language query to process
80
80
  * @throws Error if AI inference fails
81
81
  */
82
- processSummary(query: unknown): Promise<AIToolClientResponse>;
82
+ processSummary(query: any): Promise<ToolClientResponse>;
83
83
  /**
84
84
  * Closes the connection to the server and resets the connection state
85
85
  * Called automatically on transport error or can be called manually
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,oBAAqB,SAAQ,kBAAkB;IACvD,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,mBAAmB;IAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;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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Ac;CAIvB"}
@@ -1,3 +1,3 @@
1
- declare const _default: "\n<identity>\n You are PATI, an AI agent.\n</identity>\n\n<instructions>\n Your primary function is to generate a summary. This summary MUST adhere to the following rules:\n\n 1. **Language Matching:** The language of your summary MUST strictly match the predominant language of the user's provided input.\n - If the user's input is in Spanish, your summary MUST be in Spanish.\n - If the user's input is in English, your summary MUST be in English.\n - And so on for any other language.\n\n 2. **Content to Summarize:** Your summary MUST be a description of the key information, findings, or results presented in the user's input.\n - Do NOT summarize the user's instructions to you or the act of providing input.\n - Focus ONLY on the core data or text provided by the user for summarization.\n\n 3. **Handling Structured Data (e.g., JSON):**\n - If the user provides structured data (like a JSON object), identify the key textual fields that contain the main information (e.g., 'title', 'abstract', 'summary', 'content_to_search', 'description', 'text', etc.).\n - Synthesize the information from these relevant fields into a coherent, natural language summary.\n - If the JSON contains multiple results (e.g., in a 'hits' or 'results' array), list each result separately and provide a summary for each.\n - Include a general summary of all results at the beginning or end when multiple results are present.\n - Do NOT describe the structure of the data (e.g., \"The JSON has a 'hits' array...\"). Summarize the *meaning* conveyed by the content within those fields.\n\n 4. **Output Format:**\n - Your response MUST be formatted as valid HTML.\n - Use appropriate HTML elements for structure (headings, paragraphs, lists, etc.).\n - No greetings, no apologies, no explanations, no meta-comments. Just the summary in HTML format.\n - Do not include HTML, HEAD, or BODY tags - focus only on the content elements.\n</instructions>\n";
1
+ declare const _default: "\n<identity>\n You are PATI, an AI summarization agent.\n</identity>\n\n<instructions>\n Your primary function is to generate a summary. This summary MUST adhere to the following rules:\n\n 1. **Language:** The language of your summary MUST strictly match the predominant language of the user's provided input.\n\n 2. **Content to Summarize:** Your summary MUST be a description of the key information, findings, or results presented in the user's input.\n - Do NOT summarize the user's instructions to you or the act of providing input.\n - Focus ONLY on the core data or text provided by the user for summarization.\n\n 3. **Structured Data (e.g., JSON):**\n - If the user provides structured data (like a JSON object), identify the key textual fields that contain the main information (e.g., 'title', 'abstract', 'summary', 'content_to_search', 'description', 'text', etc.).\n - Synthesize the information from these relevant fields into a coherent, natural language summary.\n - For multiple results, list each separately plus provide an overall summary.\n - Include a general summary of all results at the beginning or end when multiple results are present.\n - Do NOT describe the structure of the data (e.g., \"The JSON has a 'hits' array...\"). Summarize the *meaning* conveyed by the content within those fields.\n\n 4. **Output Format:**\n - Your response MUST be formatted as valid HTML.\n - Use appropriate HTML elements for structure (headings, paragraphs, lists, etc.).\n - If you include video elements in the HTML, ensure they do NOT autoplay by omitting the autoplay attribute or setting autoplay=\"false\".\n - No greetings, no apologies, no explanations, no meta-comments. Just the summary in HTML format.\n - Do not include HTML, HEAD, or BODY tags - focus only on the content elements.\n</instructions>\n";
2
2
  export default _default;
3
3
  //# sourceMappingURL=text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/prompts/developer/text.ts"],"names":[],"mappings":";AAAA,wBA8BE"}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/prompts/developer/text.ts"],"names":[],"mappings":";AAAA,wBA4BE"}
@@ -1,30 +1,28 @@
1
1
  export default `
2
2
  <identity>
3
- You are PATI, an AI agent.
3
+ You are PATI, an AI summarization agent.
4
4
  </identity>
5
5
 
6
6
  <instructions>
7
7
  Your primary function is to generate a summary. This summary MUST adhere to the following rules:
8
8
 
9
- 1. **Language Matching:** The language of your summary MUST strictly match the predominant language of the user's provided input.
10
- - If the user's input is in Spanish, your summary MUST be in Spanish.
11
- - If the user's input is in English, your summary MUST be in English.
12
- - And so on for any other language.
9
+ 1. **Language:** The language of your summary MUST strictly match the predominant language of the user's provided input.
13
10
 
14
11
  2. **Content to Summarize:** Your summary MUST be a description of the key information, findings, or results presented in the user's input.
15
12
  - Do NOT summarize the user's instructions to you or the act of providing input.
16
13
  - Focus ONLY on the core data or text provided by the user for summarization.
17
14
 
18
- 3. **Handling Structured Data (e.g., JSON):**
15
+ 3. **Structured Data (e.g., JSON):**
19
16
  - If the user provides structured data (like a JSON object), identify the key textual fields that contain the main information (e.g., 'title', 'abstract', 'summary', 'content_to_search', 'description', 'text', etc.).
20
17
  - Synthesize the information from these relevant fields into a coherent, natural language summary.
21
- - If the JSON contains multiple results (e.g., in a 'hits' or 'results' array), list each result separately and provide a summary for each.
18
+ - For multiple results, list each separately plus provide an overall summary.
22
19
  - Include a general summary of all results at the beginning or end when multiple results are present.
23
20
  - Do NOT describe the structure of the data (e.g., "The JSON has a 'hits' array..."). Summarize the *meaning* conveyed by the content within those fields.
24
21
 
25
22
  4. **Output Format:**
26
23
  - Your response MUST be formatted as valid HTML.
27
24
  - Use appropriate HTML elements for structure (headings, paragraphs, lists, etc.).
25
+ - If you include video elements in the HTML, ensure they do NOT autoplay by omitting the autoplay attribute or setting autoplay="false".
28
26
  - No greetings, no apologies, no explanations, no meta-comments. Just the summary in HTML format.
29
27
  - Do not include HTML, HEAD, or BODY tags - focus only on the content elements.
30
28
  </instructions>
@@ -25,6 +25,7 @@ interface AIProcessResponse extends AIToolResponse, AITextResponse {
25
25
  * to use based on the user's query
26
26
  */
27
27
  export declare class AIService {
28
+ private readonly chunkSize;
28
29
  private availableTools;
29
30
  private model;
30
31
  private static instance;
@@ -1 +1 @@
1
- {"version":3,"file":"ai-handler.d.ts","sourceRoot":"","sources":["../../src/utils/ai-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAI5D,UAAU,MAAM;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,UAAU,qBAAqB;IAC7B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAkBD,UAAU,cAAc;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CA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;IAiCpC,OAAO,CAAC,mBAAmB;CAyD5B"}
@@ -1,7 +1,7 @@
1
1
  import { OpenAI } from "openai";
2
- import developerPrompts from "../prompts/developer/index.js";
3
2
  import { markdownToJson } from "./response-handler.js";
4
3
  import { InferenceClient } from "@huggingface/inference";
4
+ import developerPrompts from "../prompts/developer/index.js";
5
5
  import { OLLAMA_API, OPEN_ROUTER_API } from "../types/enums.js";
6
6
  /**
7
7
  * AI Inference Service
@@ -10,6 +10,7 @@ import { OLLAMA_API, OPEN_ROUTER_API } from "../types/enums.js";
10
10
  * to use based on the user's query
11
11
  */
12
12
  export class AIService {
13
+ chunkSize = 50000;
13
14
  availableTools = [];
14
15
  model = "gpt-3.5-turbo";
15
16
  static instance = null;
@@ -130,12 +131,21 @@ export class AIService {
130
131
  const processTextMethod = this.provider === "huggingface"
131
132
  ? this.processHuggingFaceText.bind(this)
132
133
  : this.processOpenAIText.bind(this);
133
- const chunks = this.splitTextIntoChunks(query, 50000);
134
+ const chunks = this.splitTextIntoChunks(query, this.chunkSize);
134
135
  if (chunks.length === 1) {
135
136
  return processTextMethod(messages);
136
137
  }
137
- const chunkPromises = chunks.map((content) => processTextMethod([messages[0], { role: "user", content }]));
138
- const results = await Promise.all(chunkPromises);
138
+ const results = [];
139
+ for (let i = 0; i < chunks.length; i++) {
140
+ const result = await processTextMethod([
141
+ messages[0],
142
+ { role: "user", content: chunks[i] },
143
+ ]);
144
+ results.push(result);
145
+ if (i < chunks.length - 1) {
146
+ await new Promise((resolve) => setTimeout(resolve, 500));
147
+ }
148
+ }
139
149
  const error = results.find((result) => result.error);
140
150
  if (error) {
141
151
  return { error };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-meilisearch",
3
- "version": "1.4.15",
3
+ "version": "1.4.17",
4
4
  "description": "Model Context Protocol (MCP) implementation for Meilisearch",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",