mcp-meilisearch 1.4.25 → 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 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(({ annotations }) => annotations?.category !== "core")
198
+ .filter(({ _meta }) => _meta?.category !== "core")
199
199
  .map((tool) => ({
200
200
  name: tool.name,
201
- parameters: tool.parameters || {},
201
+ parameters: tool.inputSchema || {},
202
202
  description: tool.description ?? "",
203
203
  }));
204
204
  }
@@ -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,O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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;AAoCpE;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,SAAS,SAqEhD,CAAC;AAEF,eAAe,eAAe,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 registeredTools = Object.entries(server._registeredTools);
7
+ const serverAny = server;
8
+ const registeredTools = Object.entries(serverAny._registeredTools);
8
9
  const availableTools = registeredTools
9
- .filter(([_, { annotations }]) => annotations?.category !== "core")
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.tool("process-ai-tool", "Process a natural language query using AI to determine which tool to use", {
26
- query: z.string().describe("The natural language query to process"),
27
- specificTools: z
28
- .array(z.string())
29
- .optional()
30
- .describe("Optional array of specific tool names to consider"),
31
- }, { category: "core" }, async ({ query, specificTools }) => {
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.tool("process-ai-text", "Process a summary text using AI to describe the data result from a tool", { query: z.string().describe("The natural language query to process") }, { category: "core" }, async ({ query }) => {
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,SAyQtD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
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.tool("get-documents", "Get documents from a Meilisearch index", {
12
- indexUid: z.string().describe("Unique identifier of the index"),
13
- limit: z
14
- .number()
15
- .min(1)
16
- .max(1000)
17
- .optional()
18
- .describe("Maximum number of documents to return (default: 20)"),
19
- offset: z
20
- .number()
21
- .min(0)
22
- .optional()
23
- .describe("Number of documents to skip (default: 0)"),
24
- fields: z
25
- .array(z.string())
26
- .optional()
27
- .describe("Fields to return in the documents"),
28
- filter: z.string().optional().describe("Filter query to apply"),
29
- }, { category: "meilisearch" }, async ({ indexUid, limit, offset, fields, filter }) => {
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.tool("get-document", "Get a document by its ID from a Meilisearch index", {
51
- indexUid: z.string().describe("Unique identifier of the index"),
52
- documentId: z.string().describe("ID of the document to retrieve"),
53
- fields: z
54
- .array(z.string())
55
- .optional()
56
- .describe("Fields to return in the document"),
57
- }, { category: "meilisearch" }, async ({ indexUid, documentId, fields }) => {
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.tool("add-documents", "Add documents to a Meilisearch index", {
76
- indexUid: z.string().describe("Unique identifier of the index"),
77
- documents: z.string().describe("JSON array of documents to add"),
78
- primaryKey: z
79
- .string()
80
- .optional()
81
- .describe("Primary key for the documents"),
82
- }, { category: "meilisearch" }, async ({ indexUid, documents, primaryKey }) => {
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.tool("update-documents", "Update documents in a Meilisearch index", {
112
- indexUid: z.string().describe("Unique identifier of the index"),
113
- documents: z.string().describe("JSON array of documents to update"),
114
- primaryKey: z
115
- .string()
116
- .optional()
117
- .describe("Primary key for the documents"),
118
- }, { category: "meilisearch" }, async ({ indexUid, documents, primaryKey }) => {
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.tool("delete-document", "Delete a document by its ID from a Meilisearch index", {
148
- indexUid: z.string().describe("Unique identifier of the index"),
149
- documentId: z.string().describe("ID of the document to delete"),
150
- }, { category: "meilisearch" }, async ({ indexUid, documentId }) => {
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.tool("delete-documents", "Delete multiple documents by their IDs from a Meilisearch index", {
165
- indexUid: z.string().describe("Unique identifier of the index"),
166
- documentIds: z.string().describe("JSON array of document IDs to delete"),
167
- }, { category: "meilisearch" }, async ({ indexUid, documentIds }) => {
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.tool("delete-all-documents", "Delete all documents in a Meilisearch index", {
193
- indexUid: z.string().describe("Unique identifier of the index"),
194
- }, { category: "meilisearch" }, async ({ indexUid }) => {
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,SAmLnD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
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.tool("list-indexes", "List all indexes in the Meilisearch instance", {
12
- limit: z
13
- .number()
14
- .min(1)
15
- .max(100)
16
- .optional()
17
- .describe("Maximum number of indexes to return"),
18
- offset: z
19
- .number()
20
- .min(0)
21
- .optional()
22
- .describe("Number of indexes to skip"),
23
- }, { category: "meilisearch" }, async ({ limit, offset }) => {
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 information
42
- server.tool("get-index", "Get information about a specific Meilisearch index", {
43
- indexUid: z.string().describe("Unique identifier of the index"),
44
- }, { category: "meilisearch" }, async ({ indexUid }) => {
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.tool("create-index", "Create a new Meilisearch index", {
59
- indexUid: z.string().describe("Unique identifier for the new index"),
60
- primaryKey: z.string().optional().describe("Primary key for the index"),
61
- }, { category: "meilisearch" }, async ({ indexUid, primaryKey }) => {
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.tool("update-index", "Update a Meilisearch index (currently only supports updating the primary key)", {
79
- indexUid: z.string().describe("Unique identifier of the index"),
80
- primaryKey: z.string().describe("New primary key for the index"),
81
- }, { category: "meilisearch" }, async ({ indexUid, primaryKey }) => {
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.tool("delete-index", "Delete a Meilisearch index", {
98
- indexUid: z.string().describe("Unique identifier of the index to delete"),
99
- }, { category: "meilisearch" }, async ({ indexUid }) => {
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.tool("swap-indexes", "Swap two or more indexes in Meilisearch", {
114
- indexes: z
115
- .string()
116
- .describe('JSON array of index pairs to swap, e.g. [["movies", "movies_new"]]'),
117
- }, { category: "meilisearch" }, async ({ indexes }) => {
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,SAwMpD,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;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 (searchError) {
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.tool("search", "Search for documents in a Meilisearch index", SearchParamsSchema, { category: "meilisearch" }, async ({ indexUid, q, limit, offset, filter, sort, facets, attributesToRetrieve, attributesToCrop, cropLength, attributesToHighlight, highlightPreTag, highlightPostTag, showMatchesPosition, matchingStrategy, }) => {
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.tool("multi-search", "Perform multiple searches in one request", {
156
- queries: z
157
- .array(z.object(SearchParamsSchema))
158
- .describe("JSON array of search queries, each containing the same parameters as the `search` tool"),
159
- }, { category: "meilisearch" }, async ({ queries }) => {
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
- server.tool("global-search", "Search for a term across all available Meilisearch indexes and return combined results", {
205
- q: z.string().describe("Search query"),
206
- limit: z
207
- .number()
208
- .min(1)
209
- .optional()
210
- .describe("Maximum number of results to return per index (default: 20)"),
211
- attributesToRetrieve: z
212
- .array(z.string())
213
- .optional()
214
- .default(["*"])
215
- .describe("Attributes to include in results"),
216
- }, { category: "meilisearch" }, async ({ q, limit, attributesToRetrieve, }) => {
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.tool("facet-search", "Search for facet values matching specific criteria", {
227
- indexUid: z.string().describe("Unique identifier of the index"),
228
- facetName: z.string().describe("Name of the facet to search"),
229
- facetQuery: z
230
- .string()
231
- .optional()
232
- .describe("Query to match against facet values"),
233
- filter: z
234
- .string()
235
- .optional()
236
- .describe("Filter to apply to the base search"),
237
- }, { category: "meilisearch" }, async ({ indexUid, facetName, facetQuery, filter }) => {
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,SA2uCtD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
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"}