mcp-meilisearch 1.4.23 → 1.4.26
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 +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -4
- package/dist/tools/core/ai-tools.d.ts.map +1 -1
- package/dist/tools/core/ai-tools.js +22 -11
- package/dist/tools/meilisearch/document-tools.d.ts.map +1 -1
- package/dist/tools/meilisearch/document-tools.js +84 -54
- package/dist/tools/meilisearch/index-tools.d.ts.map +1 -1
- package/dist/tools/meilisearch/index-tools.js +59 -35
- package/dist/tools/meilisearch/search-tools.d.ts.map +1 -1
- package/dist/tools/meilisearch/search-tools.js +50 -35
- package/dist/tools/meilisearch/settings-tools.d.ts.map +1 -1
- package/dist/tools/meilisearch/settings-tools.js +384 -241
- package/dist/tools/meilisearch/system-tools.d.ts.map +1 -1
- package/dist/tools/meilisearch/system-tools.js +101 -85
- package/dist/tools/meilisearch/task-tools.d.ts.map +1 -1
- package/dist/tools/meilisearch/task-tools.js +106 -88
- package/dist/tools/meilisearch/vector-tools.d.ts.map +1 -1
- package/dist/tools/meilisearch/vector-tools.js +81 -68
- package/dist/utils/ai-handler.d.ts.map +1 -1
- package/dist/utils/ai-handler.js +3 -2
- package/package.json +7 -7
package/dist/client.js
CHANGED
|
@@ -195,10 +195,10 @@ export class MCPClient {
|
|
|
195
195
|
}
|
|
196
196
|
else if (toolsResult.tools && Array.isArray(toolsResult.tools)) {
|
|
197
197
|
this.tools = toolsResult.tools
|
|
198
|
-
.filter(({
|
|
198
|
+
.filter(({ _meta }) => _meta?.category !== "core")
|
|
199
199
|
.map((tool) => ({
|
|
200
200
|
name: tool.name,
|
|
201
|
-
parameters: tool.
|
|
201
|
+
parameters: tool.inputSchema || {},
|
|
202
202
|
description: tool.description ?? "",
|
|
203
203
|
}));
|
|
204
204
|
}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAOvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAWnD,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAGzF;;GAEG;AACH,UAAU,cAAc;IACtB,SAAS,EAAE,SAAS,CAAC;CACtB;AASD,eAAO,MAAM,cAAc;;;;;;;CAO1B,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAoB;IAE3D,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,QAAQ,CAAuC;IAEvD;;;;OAIG;gBACS,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM;IAO1E;;;;;OAKG;IACG,iBAAiB,CACrB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,WAAW,GAAE,MAAmC,GAC/C,OAAO,CAAC,IAAI,CAAC;IA+ChB;;;;OAIG;IACG,gBAAgB,CACpB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC;IA+BhB;;;;;OAKG;IACG,iBAAiB,CACrB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,IAAI,CAAC;IA+BhB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAqBhB;;;;;OAKG;YACW,uBAAuB;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAOvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAWnD,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAGzF;;GAEG;AACH,UAAU,cAAc;IACtB,SAAS,EAAE,SAAS,CAAC;CACtB;AASD,eAAO,MAAM,cAAc;;;;;;;CAO1B,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAoB;IAE3D,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,QAAQ,CAAuC;IAEvD;;;;OAIG;gBACS,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM;IAO1E;;;;;OAKG;IACG,iBAAiB,CACrB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,WAAW,GAAE,MAAmC,GAC/C,OAAO,CAAC,IAAI,CAAC;IA+ChB;;;;OAIG;IACG,gBAAgB,CACpB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC;IA+BhB;;;;;OAKG;IACG,iBAAiB,CACrB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,IAAI,CAAC;IA+BhB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAqBhB;;;;;OAKG;YACW,uBAAuB;IAsCrC;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAWvC;;OAEG;YACW,gBAAgB;IAmB9B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAO7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;OAEG;IACH,OAAO,CAAC,sBAAsB;CA2B/B;AAyDD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,YAAW,MAAM,GAAG,OAAgB,EACpC,SAAS,OAAO,CAAC,aAAa,CAAC,KAC9B,OAAO,CAAC,cAAc,CAcxB,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -172,21 +172,21 @@ export class MCPServer {
|
|
|
172
172
|
const transport = new StreamableHTTPServerTransport({
|
|
173
173
|
sessionIdGenerator: () => newSessionId,
|
|
174
174
|
});
|
|
175
|
-
transport.sessionId = newSessionId;
|
|
176
175
|
try {
|
|
177
176
|
await this.server.connect(transport);
|
|
178
|
-
res.setHeader(this.SESSION_ID_HEADER_NAME, newSessionId);
|
|
179
|
-
res.setHeader("Access-Control-Expose-Headers", this.SESSION_ID_HEADER_NAME);
|
|
180
|
-
await transport.handleRequest(req, res, body);
|
|
181
177
|
this.sessions.set(newSessionId, {
|
|
182
178
|
transport,
|
|
183
179
|
lastActivity: Date.now(),
|
|
184
180
|
});
|
|
181
|
+
res.setHeader(this.SESSION_ID_HEADER_NAME, newSessionId);
|
|
182
|
+
res.setHeader("Access-Control-Expose-Headers", this.SESSION_ID_HEADER_NAME);
|
|
183
|
+
await transport.handleRequest(req, res, body);
|
|
185
184
|
this.sendToolListChangedNotification(transport);
|
|
186
185
|
console.info(`New session established: ${newSessionId}`);
|
|
187
186
|
}
|
|
188
187
|
catch (error) {
|
|
189
188
|
console.error("Error handling initialize request:", error);
|
|
189
|
+
this.sessions.delete(newSessionId);
|
|
190
190
|
transport.close();
|
|
191
191
|
this.sendErrorResponse(res, 500, `Failed to initialize: ${error}`);
|
|
192
192
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/core/ai-tools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/core/ai-tools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAqCpE;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,SAAS,SA6EhD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -4,11 +4,12 @@ import { AIService } from "../../utils/ai-handler.js";
|
|
|
4
4
|
import { createErrorResponse } from "../../utils/error-handler.js";
|
|
5
5
|
import { convertNullToUndefined } from "../../utils/response-handler.js";
|
|
6
6
|
const setAvailableTools = (aiService, server) => {
|
|
7
|
-
const
|
|
7
|
+
const serverAny = server;
|
|
8
|
+
const registeredTools = Object.entries(serverAny._registeredTools);
|
|
8
9
|
const availableTools = registeredTools
|
|
9
|
-
.filter(([_, {
|
|
10
|
+
.filter(([_, { _meta }]) => _meta?.category !== "core")
|
|
10
11
|
.map(([name, { description, inputSchema }]) => {
|
|
11
|
-
const { definitions } = zodToJsonSchema(inputSchema, "parameters");
|
|
12
|
+
const { definitions } = zodToJsonSchema(z.object(inputSchema), "parameters");
|
|
12
13
|
return {
|
|
13
14
|
name,
|
|
14
15
|
description,
|
|
@@ -22,13 +23,17 @@ const setAvailableTools = (aiService, server) => {
|
|
|
22
23
|
* @param server - The MCP server instance
|
|
23
24
|
*/
|
|
24
25
|
export const registerAITools = (server) => {
|
|
25
|
-
server.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
server.registerTool("process-ai-tool", {
|
|
27
|
+
description: "Process a natural language query using AI to determine which tool to use",
|
|
28
|
+
inputSchema: {
|
|
29
|
+
query: z.string().describe("The natural language query to process"),
|
|
30
|
+
specificTools: z
|
|
31
|
+
.array(z.string())
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Optional array of specific tool names to consider"),
|
|
34
|
+
},
|
|
35
|
+
_meta: { category: "core" },
|
|
36
|
+
}, async ({ query, specificTools }) => {
|
|
32
37
|
try {
|
|
33
38
|
const aiService = AIService.getInstance();
|
|
34
39
|
setAvailableTools(aiService, server);
|
|
@@ -54,7 +59,13 @@ export const registerAITools = (server) => {
|
|
|
54
59
|
return createErrorResponse(error);
|
|
55
60
|
}
|
|
56
61
|
});
|
|
57
|
-
server.
|
|
62
|
+
server.registerTool("process-ai-text", {
|
|
63
|
+
description: "Process a summary text using AI to describe the data result from a tool",
|
|
64
|
+
inputSchema: {
|
|
65
|
+
query: z.string().describe("The natural language query to process"),
|
|
66
|
+
},
|
|
67
|
+
_meta: { category: "core" },
|
|
68
|
+
}, async ({ query }) => {
|
|
58
69
|
try {
|
|
59
70
|
const aiService = AIService.getInstance();
|
|
60
71
|
const response = await aiService.setupAIProcess(query, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/document-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiDpE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,
|
|
1
|
+
{"version":3,"file":"document-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/document-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiDpE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,SA0RtD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -8,25 +8,29 @@ import { createErrorResponse } from "../../utils/error-handler.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export const registerDocumentTools = (server) => {
|
|
10
10
|
// Get documents from an index
|
|
11
|
-
server.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
server.registerTool("get-documents", {
|
|
12
|
+
description: "Get documents from a Meilisearch index",
|
|
13
|
+
inputSchema: {
|
|
14
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
15
|
+
limit: z
|
|
16
|
+
.number()
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(1000)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Maximum number of documents to return (default: 20)"),
|
|
21
|
+
offset: z
|
|
22
|
+
.number()
|
|
23
|
+
.min(0)
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Number of documents to skip (default: 0)"),
|
|
26
|
+
fields: z
|
|
27
|
+
.array(z.string())
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Fields to return in the documents"),
|
|
30
|
+
filter: z.string().optional().describe("Filter query to apply"),
|
|
31
|
+
},
|
|
32
|
+
_meta: { category: "meilisearch" },
|
|
33
|
+
}, async ({ indexUid, limit, offset, fields, filter }) => {
|
|
30
34
|
try {
|
|
31
35
|
const response = await apiClient.get(`/indexes/${indexUid}/documents`, {
|
|
32
36
|
params: {
|
|
@@ -47,14 +51,18 @@ export const registerDocumentTools = (server) => {
|
|
|
47
51
|
}
|
|
48
52
|
});
|
|
49
53
|
// Get a single document by ID
|
|
50
|
-
server.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
server.registerTool("get-document", {
|
|
55
|
+
description: "Get a document by its ID from a Meilisearch index",
|
|
56
|
+
inputSchema: {
|
|
57
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
58
|
+
documentId: z.string().describe("ID of the document to retrieve"),
|
|
59
|
+
fields: z
|
|
60
|
+
.array(z.string())
|
|
61
|
+
.optional()
|
|
62
|
+
.describe("Fields to return in the document"),
|
|
63
|
+
},
|
|
64
|
+
_meta: { category: "meilisearch" },
|
|
65
|
+
}, async ({ indexUid, documentId, fields }) => {
|
|
58
66
|
try {
|
|
59
67
|
const response = await apiClient.get(`/indexes/${indexUid}/documents/${documentId}`, {
|
|
60
68
|
params: {
|
|
@@ -72,14 +80,18 @@ export const registerDocumentTools = (server) => {
|
|
|
72
80
|
}
|
|
73
81
|
});
|
|
74
82
|
// Add documents to an index
|
|
75
|
-
server.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
.string()
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
server.registerTool("add-documents", {
|
|
84
|
+
description: "Add documents to a Meilisearch index",
|
|
85
|
+
inputSchema: {
|
|
86
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
87
|
+
documents: z.string().describe("JSON array of documents to add"),
|
|
88
|
+
primaryKey: z
|
|
89
|
+
.string()
|
|
90
|
+
.optional()
|
|
91
|
+
.describe("Primary key for the documents"),
|
|
92
|
+
},
|
|
93
|
+
_meta: { category: "meilisearch" },
|
|
94
|
+
}, async ({ indexUid, documents, primaryKey }) => {
|
|
83
95
|
try {
|
|
84
96
|
// Parse the documents string to ensure it's valid JSON
|
|
85
97
|
const parsedDocuments = JSON.parse(documents);
|
|
@@ -108,14 +120,18 @@ export const registerDocumentTools = (server) => {
|
|
|
108
120
|
}
|
|
109
121
|
});
|
|
110
122
|
// Update documents in an index
|
|
111
|
-
server.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.string()
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
server.registerTool("update-documents", {
|
|
124
|
+
description: "Update documents in a Meilisearch index",
|
|
125
|
+
inputSchema: {
|
|
126
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
127
|
+
documents: z.string().describe("JSON array of documents to update"),
|
|
128
|
+
primaryKey: z
|
|
129
|
+
.string()
|
|
130
|
+
.optional()
|
|
131
|
+
.describe("Primary key for the documents"),
|
|
132
|
+
},
|
|
133
|
+
_meta: { category: "meilisearch" },
|
|
134
|
+
}, async ({ indexUid, documents, primaryKey }) => {
|
|
119
135
|
try {
|
|
120
136
|
// Parse the documents string to ensure it's valid JSON
|
|
121
137
|
const parsedDocuments = JSON.parse(documents);
|
|
@@ -144,10 +160,14 @@ export const registerDocumentTools = (server) => {
|
|
|
144
160
|
}
|
|
145
161
|
});
|
|
146
162
|
// Delete a document by ID
|
|
147
|
-
server.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
163
|
+
server.registerTool("delete-document", {
|
|
164
|
+
description: "Delete a document by its ID from a Meilisearch index",
|
|
165
|
+
inputSchema: {
|
|
166
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
167
|
+
documentId: z.string().describe("ID of the document to delete"),
|
|
168
|
+
},
|
|
169
|
+
_meta: { category: "meilisearch" },
|
|
170
|
+
}, async ({ indexUid, documentId }) => {
|
|
151
171
|
try {
|
|
152
172
|
const response = await apiClient.delete(`/indexes/${indexUid}/documents/${documentId}`);
|
|
153
173
|
return {
|
|
@@ -161,10 +181,16 @@ export const registerDocumentTools = (server) => {
|
|
|
161
181
|
}
|
|
162
182
|
});
|
|
163
183
|
// Delete multiple documents by ID
|
|
164
|
-
server.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
184
|
+
server.registerTool("delete-documents", {
|
|
185
|
+
description: "Delete multiple documents by their IDs from a Meilisearch index",
|
|
186
|
+
inputSchema: {
|
|
187
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
188
|
+
documentIds: z
|
|
189
|
+
.string()
|
|
190
|
+
.describe("JSON array of document IDs to delete"),
|
|
191
|
+
},
|
|
192
|
+
_meta: { category: "meilisearch" },
|
|
193
|
+
}, async ({ indexUid, documentIds }) => {
|
|
168
194
|
try {
|
|
169
195
|
// Parse the document IDs string to ensure it's valid JSON
|
|
170
196
|
const parsedDocumentIds = JSON.parse(documentIds);
|
|
@@ -189,9 +215,13 @@ export const registerDocumentTools = (server) => {
|
|
|
189
215
|
}
|
|
190
216
|
});
|
|
191
217
|
// Delete all documents in an index
|
|
192
|
-
server.
|
|
193
|
-
|
|
194
|
-
|
|
218
|
+
server.registerTool("delete-all-documents", {
|
|
219
|
+
description: "Delete all documents in a Meilisearch index",
|
|
220
|
+
inputSchema: {
|
|
221
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
222
|
+
},
|
|
223
|
+
_meta: { category: "meilisearch" },
|
|
224
|
+
}, async ({ indexUid }) => {
|
|
195
225
|
try {
|
|
196
226
|
const response = await apiClient.delete(`/indexes/${indexUid}/documents`);
|
|
197
227
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/index-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAoCpE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,SAAS,
|
|
1
|
+
{"version":3,"file":"index-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/index-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAoCpE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,SAAS,SAgMnD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -8,19 +8,23 @@ import { createErrorResponse } from "../../utils/error-handler.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export const registerIndexTools = (server) => {
|
|
10
10
|
// List all indexes
|
|
11
|
-
server.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
server.registerTool("list-indexes", {
|
|
12
|
+
description: "List all indexes in the Meilisearch instance",
|
|
13
|
+
inputSchema: {
|
|
14
|
+
limit: z
|
|
15
|
+
.number()
|
|
16
|
+
.min(1)
|
|
17
|
+
.max(100)
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Maximum number of indexes to return"),
|
|
20
|
+
offset: z
|
|
21
|
+
.number()
|
|
22
|
+
.min(0)
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Number of indexes to skip"),
|
|
25
|
+
},
|
|
26
|
+
_meta: { category: "meilisearch" },
|
|
27
|
+
}, async ({ limit, offset }) => {
|
|
24
28
|
try {
|
|
25
29
|
const response = await apiClient.get("/indexes", {
|
|
26
30
|
params: {
|
|
@@ -38,10 +42,14 @@ export const registerIndexTools = (server) => {
|
|
|
38
42
|
return createErrorResponse(error);
|
|
39
43
|
}
|
|
40
44
|
});
|
|
41
|
-
// Get index
|
|
42
|
-
server.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
// Get a specific index
|
|
46
|
+
server.registerTool("get-index", {
|
|
47
|
+
description: "Get information about a specific Meilisearch index",
|
|
48
|
+
inputSchema: {
|
|
49
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
50
|
+
},
|
|
51
|
+
_meta: { category: "meilisearch" },
|
|
52
|
+
}, async ({ indexUid }) => {
|
|
45
53
|
try {
|
|
46
54
|
const response = await apiClient.get(`/indexes/${indexUid}`);
|
|
47
55
|
return {
|
|
@@ -55,10 +63,14 @@ export const registerIndexTools = (server) => {
|
|
|
55
63
|
}
|
|
56
64
|
});
|
|
57
65
|
// Create a new index
|
|
58
|
-
server.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
server.registerTool("create-index", {
|
|
67
|
+
description: "Create a new Meilisearch index",
|
|
68
|
+
inputSchema: {
|
|
69
|
+
indexUid: z.string().describe("Unique identifier for the new index"),
|
|
70
|
+
primaryKey: z.string().optional().describe("Primary key for the index"),
|
|
71
|
+
},
|
|
72
|
+
_meta: { category: "meilisearch" },
|
|
73
|
+
}, async ({ indexUid, primaryKey }) => {
|
|
62
74
|
try {
|
|
63
75
|
const response = await apiClient.post("/indexes", {
|
|
64
76
|
uid: indexUid,
|
|
@@ -75,10 +87,14 @@ export const registerIndexTools = (server) => {
|
|
|
75
87
|
}
|
|
76
88
|
});
|
|
77
89
|
// Update an index
|
|
78
|
-
server.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
90
|
+
server.registerTool("update-index", {
|
|
91
|
+
description: "Update a Meilisearch index (currently only supports updating the primary key)",
|
|
92
|
+
inputSchema: {
|
|
93
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
94
|
+
primaryKey: z.string().describe("New primary key for the index"),
|
|
95
|
+
},
|
|
96
|
+
_meta: { category: "meilisearch" },
|
|
97
|
+
}, async ({ indexUid, primaryKey }) => {
|
|
82
98
|
try {
|
|
83
99
|
const response = await apiClient.patch(`/indexes/${indexUid}`, {
|
|
84
100
|
primaryKey,
|
|
@@ -94,9 +110,15 @@ export const registerIndexTools = (server) => {
|
|
|
94
110
|
}
|
|
95
111
|
});
|
|
96
112
|
// Delete an index
|
|
97
|
-
server.
|
|
98
|
-
|
|
99
|
-
|
|
113
|
+
server.registerTool("delete-index", {
|
|
114
|
+
description: "Delete a Meilisearch index",
|
|
115
|
+
inputSchema: {
|
|
116
|
+
indexUid: z
|
|
117
|
+
.string()
|
|
118
|
+
.describe("Unique identifier of the index to delete"),
|
|
119
|
+
},
|
|
120
|
+
_meta: { category: "meilisearch" },
|
|
121
|
+
}, async ({ indexUid }) => {
|
|
100
122
|
try {
|
|
101
123
|
const response = await apiClient.delete(`/indexes/${indexUid}`);
|
|
102
124
|
return {
|
|
@@ -110,15 +132,17 @@ export const registerIndexTools = (server) => {
|
|
|
110
132
|
}
|
|
111
133
|
});
|
|
112
134
|
// Swap indexes
|
|
113
|
-
server.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
135
|
+
server.registerTool("swap-indexes", {
|
|
136
|
+
description: "Swap two or more indexes in Meilisearch",
|
|
137
|
+
inputSchema: {
|
|
138
|
+
indexes: z
|
|
139
|
+
.string()
|
|
140
|
+
.describe('JSON array of index pairs to swap, e.g. [["movies", "movies_new"]]'),
|
|
141
|
+
},
|
|
142
|
+
_meta: { category: "meilisearch" },
|
|
143
|
+
}, async ({ indexes }) => {
|
|
118
144
|
try {
|
|
119
|
-
// Parse the indexes string to ensure it's valid JSON
|
|
120
145
|
const parsedIndexes = JSON.parse(indexes);
|
|
121
|
-
// Ensure indexes is an array of arrays
|
|
122
146
|
if (!Array.isArray(parsedIndexes) ||
|
|
123
147
|
!parsedIndexes.every((pair) => Array.isArray(pair) && pair.length === 2)) {
|
|
124
148
|
return {
|
|
@@ -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;AA8JpE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,SAAS,
|
|
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;AA8JpE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,SAAS,SAgNpD,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -88,7 +88,7 @@ const globalSearch = async ({ q, limit, indexUids, attributesToRetrieve, }) => {
|
|
|
88
88
|
...hit,
|
|
89
89
|
}));
|
|
90
90
|
}
|
|
91
|
-
catch
|
|
91
|
+
catch {
|
|
92
92
|
return [];
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -113,8 +113,12 @@ const globalSearch = async ({ q, limit, indexUids, attributesToRetrieve, }) => {
|
|
|
113
113
|
* @param server - The MCP server instance
|
|
114
114
|
*/
|
|
115
115
|
export const registerSearchTools = (server) => {
|
|
116
|
-
// Search in an index
|
|
117
|
-
server.
|
|
116
|
+
// Search for documents in an index
|
|
117
|
+
server.registerTool("search", {
|
|
118
|
+
description: "Search for documents in a Meilisearch index",
|
|
119
|
+
inputSchema: SearchParamsSchema,
|
|
120
|
+
_meta: { category: "meilisearch" },
|
|
121
|
+
}, async ({ indexUid, q, limit, offset, filter, sort, facets, attributesToRetrieve, attributesToCrop, cropLength, attributesToHighlight, highlightPreTag, highlightPostTag, showMatchesPosition, matchingStrategy, }) => {
|
|
118
122
|
try {
|
|
119
123
|
const response = await apiClient.post(`/indexes/${indexUid}/search`, {
|
|
120
124
|
q,
|
|
@@ -152,20 +156,22 @@ export const registerSearchTools = (server) => {
|
|
|
152
156
|
}
|
|
153
157
|
});
|
|
154
158
|
// Multi-search across multiple indexes
|
|
155
|
-
server.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
server.registerTool("multi-search", {
|
|
160
|
+
description: "Perform multiple searches in one request",
|
|
161
|
+
inputSchema: {
|
|
162
|
+
queries: z
|
|
163
|
+
.array(z.object(SearchParamsSchema))
|
|
164
|
+
.describe("JSON array of search queries, each containing the same parameters as the `search` tool"),
|
|
165
|
+
},
|
|
166
|
+
_meta: { category: "meilisearch" },
|
|
167
|
+
}, async ({ queries }) => {
|
|
160
168
|
try {
|
|
161
|
-
// Ensure queries is an array
|
|
162
169
|
if (!Array.isArray(queries)) {
|
|
163
170
|
return {
|
|
164
171
|
isError: true,
|
|
165
172
|
content: [{ type: "text", text: "Queries must be a JSON array" }],
|
|
166
173
|
};
|
|
167
174
|
}
|
|
168
|
-
// Ensure each search has at least indexUid
|
|
169
175
|
for (const search of queries) {
|
|
170
176
|
if (!search.indexUid) {
|
|
171
177
|
return {
|
|
@@ -201,19 +207,24 @@ export const registerSearchTools = (server) => {
|
|
|
201
207
|
return createErrorResponse(error);
|
|
202
208
|
}
|
|
203
209
|
});
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
// Global search across all indexes
|
|
211
|
+
server.registerTool("global-search", {
|
|
212
|
+
description: "Search for a term across all available Meilisearch indexes and return combined results",
|
|
213
|
+
inputSchema: {
|
|
214
|
+
q: z.string().describe("Search query"),
|
|
215
|
+
limit: z
|
|
216
|
+
.number()
|
|
217
|
+
.min(1)
|
|
218
|
+
.optional()
|
|
219
|
+
.describe("Maximum number of results to return per index (default: 20)"),
|
|
220
|
+
attributesToRetrieve: z
|
|
221
|
+
.array(z.string())
|
|
222
|
+
.optional()
|
|
223
|
+
.default(["*"])
|
|
224
|
+
.describe("Attributes to include in results"),
|
|
225
|
+
},
|
|
226
|
+
_meta: { category: "meilisearch" },
|
|
227
|
+
}, async ({ q, limit, attributesToRetrieve, }) => {
|
|
217
228
|
const indexUids = await getIndexUids();
|
|
218
229
|
return await globalSearch({
|
|
219
230
|
q,
|
|
@@ -223,18 +234,22 @@ export const registerSearchTools = (server) => {
|
|
|
223
234
|
});
|
|
224
235
|
});
|
|
225
236
|
// Facet search
|
|
226
|
-
server.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
.string()
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
server.registerTool("facet-search", {
|
|
238
|
+
description: "Search for facet values matching specific criteria",
|
|
239
|
+
inputSchema: {
|
|
240
|
+
indexUid: z.string().describe("Unique identifier of the index"),
|
|
241
|
+
facetName: z.string().describe("Name of the facet to search"),
|
|
242
|
+
facetQuery: z
|
|
243
|
+
.string()
|
|
244
|
+
.optional()
|
|
245
|
+
.describe("Query to match against facet values"),
|
|
246
|
+
filter: z
|
|
247
|
+
.string()
|
|
248
|
+
.optional()
|
|
249
|
+
.describe("Filter to apply to the base search"),
|
|
250
|
+
},
|
|
251
|
+
_meta: { category: "meilisearch" },
|
|
252
|
+
}, async ({ indexUid, facetName, facetQuery, filter }) => {
|
|
238
253
|
try {
|
|
239
254
|
const params = {
|
|
240
255
|
facetName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/settings-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,
|
|
1
|
+
{"version":3,"file":"settings-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/settings-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,SA8yCtD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|