mcp-meilisearch 1.4.18 → 1.4.20
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/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;
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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,EAAE,MAAM,qBAAqB,CAAC;AAK5D,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,O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;IACtC,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0B;IACjD,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,MAAM,CAAyC;IAEvD;;;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;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-meilisearch",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.20",
|
|
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": "^
|
|
33
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
34
|
-
"axios": "^1.
|
|
35
|
-
"openai": "^
|
|
36
|
-
"zod": "^3.25.
|
|
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": "^
|
|
39
|
+
"@types/node": "^24.0.3",
|
|
40
40
|
"typescript": "^5.8.3"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|