mcp-meilisearch 1.4.17 → 1.4.19

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/client.js CHANGED
@@ -174,7 +174,7 @@ export class MCPClient {
174
174
  query: JSON.stringify(query),
175
175
  });
176
176
  if (!result.success)
177
- console.error(result);
177
+ console.warn(result);
178
178
  return result;
179
179
  }
180
180
  /**
package/dist/server.js CHANGED
@@ -49,7 +49,7 @@ export class MCPServer {
49
49
  async handleHttpRequest(req, res, mcpEndpoint = defaultOptions.mcpEndpoint) {
50
50
  res.setHeader("Access-Control-Allow-Origin", "*");
51
51
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
52
- res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, mcp-session-id");
52
+ res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, mcp-session-id, mcp-protocol-version");
53
53
  if (req.method === "OPTIONS") {
54
54
  res.statusCode = 200;
55
55
  res.end();
@@ -1 +1 @@
1
- {"version":3,"file":"search-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/search-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAwFpE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,SAAS,SA6NpD,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"search-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/search-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA2JpE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,SAAS,SAwMpD,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -54,6 +54,56 @@ const SearchParamsSchema = {
54
54
  .optional()
55
55
  .describe("Matching strategy: 'all' or 'last'"),
56
56
  };
57
+ const getIndexUids = async () => {
58
+ const indexesResponse = await apiClient.get("/indexes", {
59
+ params: { limit: 1000 },
60
+ });
61
+ const indexUids = indexesResponse.data.results.map((index) => index.uid);
62
+ return indexUids;
63
+ };
64
+ const globalSearch = async ({ q, limit, indexUids, attributesToRetrieve, }) => {
65
+ try {
66
+ if (!indexUids?.length) {
67
+ return {
68
+ content: [
69
+ {
70
+ type: "text",
71
+ text: JSON.stringify({ hits: [], message: "No indexes found in Meilisearch." }, null, 2),
72
+ },
73
+ ],
74
+ };
75
+ }
76
+ const searchPromises = indexUids.map(async (uid) => {
77
+ try {
78
+ const searchResult = await apiClient.post(`/indexes/${uid}/search`, {
79
+ q,
80
+ limit,
81
+ attributesToRetrieve,
82
+ });
83
+ return searchResult.data.hits.map((hit) => ({
84
+ indexUid: uid,
85
+ ...hit,
86
+ }));
87
+ }
88
+ catch (searchError) {
89
+ return [];
90
+ }
91
+ });
92
+ const resultsPerIndex = await Promise.all(searchPromises);
93
+ const result = { limit, query: q, hits: resultsPerIndex.flat() };
94
+ return {
95
+ content: [
96
+ {
97
+ type: "text",
98
+ text: JSON.stringify(result, null, 2),
99
+ },
100
+ ],
101
+ };
102
+ }
103
+ catch (error) {
104
+ return createErrorResponse(error);
105
+ }
106
+ };
57
107
  /**
58
108
  * Register search tools with the MCP server
59
109
  *
@@ -79,6 +129,15 @@ export const registerSearchTools = (server) => {
79
129
  showMatchesPosition,
80
130
  matchingStrategy,
81
131
  });
132
+ const indexUids = await getIndexUids();
133
+ if (!indexUids.includes(indexUid)) {
134
+ return await globalSearch({
135
+ q,
136
+ limit,
137
+ indexUids,
138
+ attributesToRetrieve,
139
+ });
140
+ }
82
141
  return {
83
142
  content: [
84
143
  { type: "text", text: JSON.stringify(response.data, null, 2) },
@@ -116,6 +175,15 @@ export const registerSearchTools = (server) => {
116
175
  ],
117
176
  };
118
177
  }
178
+ const indexUids = await getIndexUids();
179
+ if (!indexUids.includes(search.indexUid)) {
180
+ return await globalSearch({
181
+ indexUids,
182
+ q: search.q,
183
+ limit: search.limit,
184
+ attributesToRetrieve: search.attributesToRetrieve,
185
+ });
186
+ }
119
187
  }
120
188
  const response = await apiClient.post("/multi-search", {
121
189
  queries,
@@ -142,52 +210,14 @@ export const registerSearchTools = (server) => {
142
210
  .optional()
143
211
  .default(["*"])
144
212
  .describe("Attributes to include in results"),
145
- }, { category: "meilisearch" }, async ({ q, limit, attributesToRetrieve }) => {
146
- try {
147
- const indexesResponse = await apiClient.get("/indexes", {
148
- params: { limit: 1000 },
149
- });
150
- const indexUids = indexesResponse.data.results.map((index) => index.uid);
151
- if (!indexUids?.length) {
152
- return {
153
- content: [
154
- {
155
- type: "text",
156
- text: JSON.stringify({ hits: [], message: "No indexes found in Meilisearch." }, null, 2),
157
- },
158
- ],
159
- };
160
- }
161
- const searchPromises = indexUids.map(async (uid) => {
162
- try {
163
- const searchResult = await apiClient.post(`/indexes/${uid}/search`, {
164
- q,
165
- limit,
166
- attributesToRetrieve,
167
- });
168
- return searchResult.data.hits.map((hit) => ({
169
- indexUid: uid,
170
- ...hit,
171
- }));
172
- }
173
- catch (searchError) {
174
- return [];
175
- }
176
- });
177
- const resultsPerIndex = await Promise.all(searchPromises);
178
- const hits = resultsPerIndex.flat();
179
- return {
180
- content: [
181
- {
182
- type: "text",
183
- text: JSON.stringify({ query: q, hits, limit }, null, 2),
184
- },
185
- ],
186
- };
187
- }
188
- catch (error) {
189
- return createErrorResponse(error);
190
- }
213
+ }, { category: "meilisearch" }, async ({ q, limit, attributesToRetrieve, }) => {
214
+ const indexUids = await getIndexUids();
215
+ return await globalSearch({
216
+ q,
217
+ limit,
218
+ indexUids,
219
+ attributesToRetrieve,
220
+ });
191
221
  });
192
222
  // Facet search
193
223
  server.tool("facet-search", "Search for facet values matching specific criteria", {
@@ -1 +1 @@
1
- {"version":3,"file":"ai-handler.d.ts","sourceRoot":"","sources":["../../src/utils/ai-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,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AU,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;IAe1B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAalB,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;YA0Df,iBAAiB;YA+DjB,iBAAiB;YA+BjB,sBAAsB;YA+DtB,sBAAsB;IAiCpC,OAAO,CAAC,mBAAmB;CAyD5B"}
@@ -135,22 +135,12 @@ export class AIService {
135
135
  if (chunks.length === 1) {
136
136
  return processTextMethod(messages);
137
137
  }
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
- }
149
- const error = results.find((result) => result.error);
150
- if (error) {
151
- return { error };
152
- }
153
- const summary = results.map((result) => result?.summary || "").join(" ");
138
+ const chunkPromises = chunks.map((content) => processTextMethod([messages[0], { role: "user", content }]));
139
+ const results = await Promise.all(chunkPromises);
140
+ const summary = results
141
+ .filter((result) => !result.error)
142
+ .map((result) => result?.summary || "")
143
+ .join(" ");
154
144
  return { summary };
155
145
  }
156
146
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-meilisearch",
3
- "version": "1.4.17",
3
+ "version": "1.4.19",
4
4
  "description": "Model Context Protocol (MCP) implementation for Meilisearch",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,14 +29,14 @@
29
29
  "prepublishOnly": "rm -rf dist && npm version patch && npm run build"
30
30
  },
31
31
  "dependencies": {
32
- "@huggingface/inference": "^3.13.2",
33
- "@modelcontextprotocol/sdk": "^1.11.4",
34
- "axios": "^1.9.0",
35
- "openai": "^4.100.0",
36
- "zod": "^3.25.7"
32
+ "@huggingface/inference": "^4.0.6",
33
+ "@modelcontextprotocol/sdk": "^1.13.0",
34
+ "axios": "^1.10.0",
35
+ "openai": "^5.5.1",
36
+ "zod": "^3.25.67"
37
37
  },
38
38
  "devDependencies": {
39
- "@types/node": "^22.15.19",
39
+ "@types/node": "^24.0.3",
40
40
  "typescript": "^5.8.3"
41
41
  },
42
42
  "engines": {