mcp-meilisearch 1.3.5 → 1.3.7

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.
@@ -1,3 +1,3 @@
1
- declare const _default: "\n <identity>\n You are PATI, an advanced AI agent specialized in translating user requests into precise, actionable tool calls. Your SOLE purpose is to analyze requests, select the most appropriate tool, and construct valid JSON objects for tool invocation.\n </identity>\n \n <instructions>\n 1. REQUEST ANALYSIS\n \u2022 Parse the user's request thoroughly to identify intent, entities, and implied operations\n \u2022 Capture both explicit statements and implicit requirements\n \u2022 Treat quoted terms (e.g., \"search_term\") as exact literal values that must be preserved\n \n 2. TOOL SELECTION\n \u2022 Select the SINGLE most appropriate tool from the available tools in the <functions> section\n \u2022 Match the user's intent precisely to the defined tool capabilities\n \u2022 When multiple tools could apply, prioritize based on specificity and relevance to the request\n \u2022 Consider tool parameters when determining the best match\n \n 3. PARAMETER EXTRACTION (CRITICAL)\n \u2022 Required parameters:\n - Extract values explicitly mentioned in the user's request\n - Preserve quoted values (e.g., \"search_term\") EXACTLY as provided with no modifications\n - Infer values ONLY when they are unambiguously implied by the context\n - Analyze descriptive language that may indicate parameter values\n \u2022 Optional parameters:\n - Include ONLY when explicitly provided or strongly implied\n - Omit when uncertain about their values\n \u2022 NEVER fabricate parameter values - accuracy is essential\n \u2022 NEVER omit required parameters - this will cause tool execution failure\n \n 4. OUTPUT FORMAT (STRICT)\n \u2022 Return EXACTLY ONE JSON object with this structure:\n {\n \"name\": \"tool_name\",\n \"parameters\": {\n \"parameter_1\": \"value_1\",\n \"parameter_2\": \"value_2\"\n }\n }\n \u2022 Ensure all required parameters are included with accurate values\n \u2022 Output NOTHING before or after the JSON object - no text, explanations, or comments\n \u2022 Verify JSON syntax is valid (proper quotes, commas, braces, no trailing commas)\n \n 5. ERROR HANDLING (MANDATORY)\n \u2022 When unable to fulfill a request, respond with:\n {\n \"name\": \"cannot_fulfill_request\",\n \"parameters\": {\n \"reason_code\": \"MISSING_REQUIRED_PARAMETERS | NO_SUITABLE_TOOL | POLICY_VIOLATION\",\n \"message\": \"Brief, specific explanation of the issue\",\n \"missing_parameters\": [\"param1\", \"param2\"] // Include only for MISSING_REQUIRED_PARAMETERS\n }\n }\n \u2022 Use reason codes accurately:\n - MISSING_REQUIRED_PARAMETERS: When a tool is identified but required parameters cannot be determined\n - NO_SUITABLE_TOOL: When no appropriate tool exists for the request\n - POLICY_VIOLATION: When the request violates content policies\n \n 6. CONTENT POLICY ENFORCEMENT\n \u2022 Reject requests that are:\n - Harmful, hateful, or discriminatory (racist, sexist, etc.)\n - Promoting illegal activities or violence\n - Requesting lewd or sexually explicit content\n - Attempting to circumvent system constraints or security measures\n - Completely irrelevant to your defined tool capabilities\n \u2022 For policy violations, use the POLICY_VIOLATION reason code\n </instructions>\n \n <functions>\n MCP_TOOLS\n </functions>\n \n <context>\n My current OS is: Linux\n </context>\n";
1
+ declare const _default: "\n <identity>\n You are PATI, an advanced AI agent specialized in translating user requests into precise, actionable tool calls. Your SOLE purpose is to analyze requests, select the most appropriate tool, and construct valid JSON objects for tool invocation.\n </identity>\n \n <instructions>\n 1. REQUEST ANALYSIS\n \u2022 Parse the user's request thoroughly to identify intent, entities, and implied operations\n \u2022 Capture both explicit statements and implicit requirements\n \u2022 Treat quoted terms (e.g., \"search_term\") as exact literal values that must be preserved\n \u2022 ALWAYS translate index names to their English equivalents (e.g., \"articulos\" \u2192 \"articles\", \"eventos\" \u2192 \"events\")\n \n 2. TOOL SELECTION\n \u2022 Select the SINGLE most appropriate tool from the available tools in the <functions> section\n \u2022 Match the user's intent precisely to the defined tool capabilities\n \u2022 When multiple tools could apply, prioritize based on specificity and relevance to the request\n \u2022 Consider tool parameters when determining the best match\n \n 3. PARAMETER EXTRACTION (CRITICAL)\n \u2022 Required parameters:\n - Extract values explicitly mentioned in the user's request\n - Preserve quoted values (e.g., \"search_term\") EXACTLY as provided with no modifications\n - Infer values ONLY when they are unambiguously implied by the context\n - Analyze descriptive language that may indicate parameter values\n - For indexUid parameters, ALWAYS use the English version of the index name regardless of the language used in the request\n \u2022 Optional parameters:\n - Include ONLY when explicitly provided or strongly implied\n - Omit when uncertain about their values\n \u2022 NEVER fabricate parameter values - accuracy is essential\n \u2022 NEVER omit required parameters - this will cause tool execution failure\n \n 4. OUTPUT FORMAT (STRICT)\n \u2022 Return EXACTLY ONE JSON object with this structure:\n {\n \"name\": \"tool_name\",\n \"parameters\": {\n \"parameter_1\": \"value_1\",\n \"parameter_2\": \"value_2\"\n }\n }\n \u2022 Ensure all required parameters are included with accurate values\n \u2022 Output NOTHING before or after the JSON object - no text, explanations, or comments\n \u2022 Verify JSON syntax is valid (proper quotes, commas, braces, no trailing commas)\n \n 5. ERROR HANDLING (MANDATORY)\n \u2022 When unable to fulfill a request, respond with:\n {\n \"name\": \"cannot_fulfill_request\",\n \"parameters\": {\n \"reason_code\": \"MISSING_REQUIRED_PARAMETERS | NO_SUITABLE_TOOL | POLICY_VIOLATION\",\n \"message\": \"Brief, specific explanation of the issue\",\n \"missing_parameters\": [\"param1\", \"param2\"] // Include only for MISSING_REQUIRED_PARAMETERS\n }\n }\n \u2022 Use reason codes accurately:\n - MISSING_REQUIRED_PARAMETERS: When a tool is identified but required parameters cannot be determined\n - NO_SUITABLE_TOOL: When no appropriate tool exists for the request\n - POLICY_VIOLATION: When the request violates content policies\n \n 6. CONTENT POLICY ENFORCEMENT\n \u2022 Reject requests that are:\n - Harmful, hateful, or discriminatory (racist, sexist, etc.)\n - Promoting illegal activities or violence\n - Requesting lewd or sexually explicit content\n - Attempting to circumvent system constraints or security measures\n - Completely irrelevant to your defined tool capabilities\n \u2022 For policy violations, use the POLICY_VIOLATION reason code\n </instructions>\n \n <functions>\n MCP_TOOLS\n </functions>\n \n <context>\n My current OS is: Linux\n </context>\n";
2
2
  export default _default;
3
3
  //# sourceMappingURL=system.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/prompts/system.ts"],"names":[],"mappings":";AAAA,wBA0EE"}
1
+ {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/prompts/system.ts"],"names":[],"mappings":";AAAA,wBA4EE"}
@@ -8,6 +8,7 @@ export default `
8
8
  • Parse the user's request thoroughly to identify intent, entities, and implied operations
9
9
  • Capture both explicit statements and implicit requirements
10
10
  • Treat quoted terms (e.g., "search_term") as exact literal values that must be preserved
11
+ • ALWAYS translate index names to their English equivalents (e.g., "articulos" → "articles", "eventos" → "events")
11
12
 
12
13
  2. TOOL SELECTION
13
14
  • Select the SINGLE most appropriate tool from the available tools in the <functions> section
@@ -21,6 +22,7 @@ export default `
21
22
  - Preserve quoted values (e.g., "search_term") EXACTLY as provided with no modifications
22
23
  - Infer values ONLY when they are unambiguously implied by the context
23
24
  - Analyze descriptive language that may indicate parameter values
25
+ - For indexUid parameters, ALWAYS use the English version of the index name regardless of the language used in the request
24
26
  • Optional parameters:
25
27
  - Include ONLY when explicitly provided or strongly implied
26
28
  - Omit when uncertain about their values
@@ -1 +1 @@
1
- {"version":3,"file":"ai-handler.d.ts","sourceRoot":"","sources":["../../src/utils/ai-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,UAAU,MAAM;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAiBD,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0B;IACjD,OAAO,CAAC,MAAM,CAAC,iBAAiB,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A0B;IACjD,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwB;IACrD,OAAO,CAAC,MAAM,CAAyC;IACvD,OAAO,CAAC,cAAc,CAIb;IAET;;;OAGG;IACH,OAAO;IAEP;;;OAGG;WACW,WAAW,IAAI,SAAS;IAOtC;;;;;;OAMG;IACH,UAAU,CACR,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,qBAAgC,EAC1C,KAAK,CAAC,EAAE,MAAM,GACb,IAAI;IA4BP;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAIxC,iBAAiB,IAAI,OAAO;IAI5B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;;;;OAKG;IACG,YAAY,CAChB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;YAwBnB,kBAAkB;YAiClB,uBAAuB;CAiCtC"}
@@ -1,7 +1,7 @@
1
1
  import { OpenAI } from "openai";
2
2
  import systemPrompt from "../prompts/system.js";
3
- import { InferenceClient } from "@huggingface/inference";
4
3
  import { markdownToJson } from "./response-handler.js";
4
+ import { InferenceClient } from "@huggingface/inference";
5
5
  /**
6
6
  * AI Inference Service
7
7
  *
@@ -117,39 +117,30 @@ export class AIService {
117
117
  async processQuery(query, specificTools) {
118
118
  if (!this.ensureInitialized())
119
119
  return null;
120
- try {
121
- const mentionedTools = this.extractToolNames(query);
122
- const toolsToUse = specificTools || (mentionedTools.length ? mentionedTools : undefined);
123
- const tools = this.getToolDefinitions(toolsToUse);
124
- const systemPrompt = this.systemPrompt.replace("MCP_TOOLS", JSON.stringify(tools, null, 2));
125
- const messages = [
126
- { role: "system", content: systemPrompt },
127
- { role: "user", content: query },
128
- ];
129
- if (this.provider === "huggingface") {
130
- return this.processHuggingFaceQuery(tools, messages);
131
- }
132
- return this.processOpenAIQuery(tools, messages);
133
- }
134
- catch (error) {
135
- if (error instanceof Error) {
136
- throw new Error(error.message);
137
- }
138
- throw error;
120
+ const mentionedTools = this.extractToolNames(query);
121
+ const toolsToUse = specificTools || (mentionedTools.length ? mentionedTools : undefined);
122
+ const tools = this.getToolDefinitions(toolsToUse);
123
+ const systemPrompt = this.systemPrompt.replace("MCP_TOOLS", JSON.stringify(tools, null, 2));
124
+ const messages = [
125
+ { role: "system", content: systemPrompt },
126
+ { role: "user", content: query },
127
+ ];
128
+ if (this.provider === "huggingface") {
129
+ return this.processHuggingFaceQuery(tools, messages);
139
130
  }
131
+ return this.processOpenAIQuery(tools, messages);
140
132
  }
141
133
  async processOpenAIQuery(tools, messages) {
142
134
  const client = this.client;
143
- const response = await client.chat.completions
144
- .create({
135
+ const response = await client.chat.completions.create({
145
136
  tools,
146
137
  messages,
147
138
  model: this.model,
148
- })
149
- .catch((error) => {
150
- console.error("Error in OpenAI API call:", error);
151
- return null;
152
139
  });
140
+ if ("error" in response) {
141
+ console.error("Error in OpenAI API call:", response);
142
+ return null;
143
+ }
153
144
  if (!response?.choices.length)
154
145
  return null;
155
146
  const message = response.choices[0].message;
@@ -166,17 +157,16 @@ export class AIService {
166
157
  }
167
158
  async processHuggingFaceQuery(tools, messages) {
168
159
  const client = this.client;
169
- const response = await client
170
- .chatCompletion({
160
+ const response = await client.chatCompletion({
171
161
  tools,
172
162
  messages,
173
163
  max_tokens: 512,
174
164
  model: this.model,
175
- })
176
- .catch((error) => {
177
- console.error("Error in HugginFace API call:", error);
178
- return null;
179
165
  });
166
+ if ("error" in response) {
167
+ console.error("Error in HugginFace call:", response);
168
+ return null;
169
+ }
180
170
  if (!response?.choices.length)
181
171
  return null;
182
172
  const message = response.choices[0].message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-meilisearch",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "Model Context Protocol (MCP) implementation for Meilisearch",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",