mcp-meilisearch 1.3.8 → 1.3.10

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.
Files changed (46) hide show
  1. package/README.md +2 -2
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +3 -1
  4. package/dist/server.d.ts.map +1 -1
  5. package/dist/server.js +8 -8
  6. package/dist/tools/core/ai-tools.d.ts.map +1 -0
  7. package/dist/tools/{ai-tools.js → core/ai-tools.js} +4 -4
  8. package/dist/tools/meilisearch/document-tools.d.ts.map +1 -0
  9. package/dist/tools/{document-tools.js → meilisearch/document-tools.js} +9 -9
  10. package/dist/tools/meilisearch/index-tools.d.ts.map +1 -0
  11. package/dist/tools/{index-tools.js → meilisearch/index-tools.js} +8 -8
  12. package/dist/tools/meilisearch/search-tools.d.ts.map +1 -0
  13. package/dist/tools/{search-tools.js → meilisearch/search-tools.js} +68 -69
  14. package/dist/tools/meilisearch/settings-tools.d.ts.map +1 -0
  15. package/dist/tools/meilisearch/settings-tools.js +798 -0
  16. package/dist/tools/meilisearch/system-tools.d.ts.map +1 -0
  17. package/dist/tools/{system-tools.js → meilisearch/system-tools.js} +12 -32
  18. package/dist/tools/meilisearch/task-tools.d.ts.map +1 -0
  19. package/dist/tools/{task-tools.js → meilisearch/task-tools.js} +8 -8
  20. package/dist/tools/meilisearch/vector-tools.d.ts.map +1 -0
  21. package/dist/tools/{vector-tools.js → meilisearch/vector-tools.js} +8 -8
  22. package/dist/types/enums.d.ts +5 -0
  23. package/dist/types/enums.d.ts.map +1 -0
  24. package/dist/types/enums.js +5 -0
  25. package/dist/utils/ai-handler.d.ts +2 -1
  26. package/dist/utils/ai-handler.d.ts.map +1 -1
  27. package/dist/utils/ai-handler.js +11 -8
  28. package/dist/utils/response-handler.js +30 -1
  29. package/package.json +4 -4
  30. package/dist/tools/ai-tools.d.ts.map +0 -1
  31. package/dist/tools/document-tools.d.ts.map +0 -1
  32. package/dist/tools/index-tools.d.ts.map +0 -1
  33. package/dist/tools/search-tools.d.ts.map +0 -1
  34. package/dist/tools/settings-tools.d.ts.map +0 -1
  35. package/dist/tools/settings-tools.js +0 -309
  36. package/dist/tools/system-tools.d.ts.map +0 -1
  37. package/dist/tools/task-tools.d.ts.map +0 -1
  38. package/dist/tools/vector-tools.d.ts.map +0 -1
  39. /package/dist/tools/{ai-tools.d.ts → core/ai-tools.d.ts} +0 -0
  40. /package/dist/tools/{document-tools.d.ts → meilisearch/document-tools.d.ts} +0 -0
  41. /package/dist/tools/{index-tools.d.ts → meilisearch/index-tools.d.ts} +0 -0
  42. /package/dist/tools/{search-tools.d.ts → meilisearch/search-tools.d.ts} +0 -0
  43. /package/dist/tools/{settings-tools.d.ts → meilisearch/settings-tools.d.ts} +0 -0
  44. /package/dist/tools/{system-tools.d.ts → meilisearch/system-tools.d.ts} +0 -0
  45. /package/dist/tools/{task-tools.d.ts → meilisearch/task-tools.d.ts} +0 -0
  46. /package/dist/tools/{vector-tools.d.ts → meilisearch/vector-tools.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/system-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,SAAS,SAmNpD,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import apiClient from "../utils/api-handler.js";
3
- import { createErrorResponse } from "../utils/error-handler.js";
2
+ import apiClient from "../../utils/api-handler.js";
3
+ import { createErrorResponse } from "../../utils/error-handler.js";
4
4
  /**
5
5
  * Meilisearch System Tools
6
6
  *
@@ -12,22 +12,8 @@ import { createErrorResponse } from "../utils/error-handler.js";
12
12
  * @param server - The MCP server instance
13
13
  */
14
14
  export const registerSystemTools = (server) => {
15
- // Get health status
16
- server.tool("health", "Check if the Meilisearch server is healthy", {}, async () => {
17
- try {
18
- const response = await apiClient.get("/health");
19
- return {
20
- content: [
21
- { type: "text", text: JSON.stringify(response.data, null, 2) },
22
- ],
23
- };
24
- }
25
- catch (error) {
26
- return createErrorResponse(error);
27
- }
28
- });
29
- // Get version information
30
- server.tool("version", "Get the version information of the Meilisearch server", {}, async () => {
15
+ // Get Meilisearch version
16
+ server.tool("get-version", "Get the version of the Meilisearch instance", {}, { category: "meilisearch" }, async () => {
31
17
  try {
32
18
  const response = await apiClient.get("/version");
33
19
  return {
@@ -40,10 +26,10 @@ export const registerSystemTools = (server) => {
40
26
  return createErrorResponse(error);
41
27
  }
42
28
  });
43
- // Get system information
44
- server.tool("info", "Get the system information of the Meilisearch server", {}, async () => {
29
+ // Get Meilisearch health status
30
+ server.tool("get-health", "Get the health status of the Meilisearch instance", {}, { category: "meilisearch" }, async () => {
45
31
  try {
46
- const response = await apiClient.get("/");
32
+ const response = await apiClient.get("/health");
47
33
  return {
48
34
  content: [
49
35
  { type: "text", text: JSON.stringify(response.data, null, 2) },
@@ -54,16 +40,10 @@ export const registerSystemTools = (server) => {
54
40
  return createErrorResponse(error);
55
41
  }
56
42
  });
57
- // Get statistics
58
- server.tool("stats", "Get statistics about all indexes or a specific index", {
59
- indexUid: z
60
- .string()
61
- .optional()
62
- .describe("Unique identifier of the index (optional, if not provided stats for all indexes will be returned)"),
63
- }, async ({ indexUid }) => {
43
+ // Get Meilisearch server stats
44
+ server.tool("get-stats", "Get statistics about the Meilisearch server", {}, { category: "meilisearch" }, async () => {
64
45
  try {
65
- const endpoint = indexUid ? `/indexes/${indexUid}/stats` : "/stats";
66
- const response = await apiClient.get(endpoint);
46
+ const response = await apiClient.get("/");
67
47
  return {
68
48
  content: [
69
49
  { type: "text", text: JSON.stringify(response.data, null, 2) },
@@ -108,7 +88,7 @@ export const registerSystemTools = (server) => {
108
88
  .array(z.string())
109
89
  .optional()
110
90
  .describe("UIDs of the indexes on which tasks were performed"),
111
- }, async ({ limit, from, status, type, indexUids }) => {
91
+ }, { category: "meilisearch" }, async ({ limit, from, status, type, indexUids }) => {
112
92
  try {
113
93
  const params = {};
114
94
  if (limit !== undefined)
@@ -176,7 +156,7 @@ export const registerSystemTools = (server) => {
176
156
  .string()
177
157
  .optional()
178
158
  .describe("Delete tasks that finished processing before this date (ISO 8601 format)"),
179
- }, async ({ statuses, types, indexUids, uids, canceledBy, beforeUid, beforeStartedAt, beforeFinishedAt, }) => {
159
+ }, { category: "meilisearch" }, async ({ statuses, types, indexUids, uids, canceledBy, beforeUid, beforeStartedAt, beforeFinishedAt, }) => {
180
160
  try {
181
161
  const body = {};
182
162
  if (statuses && statuses.length > 0)
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/task-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAmCpE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,SAAS,SA6NlD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,14 +1,14 @@
1
1
  import { z } from "zod";
2
- import apiClient from "../utils/api-handler.js";
3
- import { createErrorResponse } from "../utils/error-handler.js";
2
+ import apiClient from "../../utils/api-handler.js";
3
+ import { createErrorResponse } from "../../utils/error-handler.js";
4
4
  /**
5
5
  * Register task management tools with the MCP server
6
6
  *
7
7
  * @param server - The MCP server instance
8
8
  */
9
9
  export const registerTaskTools = (server) => {
10
- // Get all tasks
11
- server.tool("list-tasks", "List tasks with optional filtering", {
10
+ // List all tasks
11
+ server.tool("list-tasks", "List all tasks in the Meilisearch instance", {
12
12
  limit: z
13
13
  .number()
14
14
  .min(0)
@@ -45,7 +45,7 @@ export const registerTaskTools = (server) => {
45
45
  .array(z.number())
46
46
  .optional()
47
47
  .describe("UIDs of specific tasks to return"),
48
- }, async ({ limit, from, statuses, types, indexUids, uids, }) => {
48
+ }, { category: "meilisearch" }, async ({ limit, from, statuses, types, indexUids, uids, }) => {
49
49
  try {
50
50
  const params = {};
51
51
  if (limit !== undefined)
@@ -74,7 +74,7 @@ export const registerTaskTools = (server) => {
74
74
  // Get a specific task
75
75
  server.tool("get-task", "Get information about a specific task", {
76
76
  taskUid: z.number().describe("Unique identifier of the task"),
77
- }, async ({ taskUid }) => {
77
+ }, { category: "meilisearch" }, async ({ taskUid }) => {
78
78
  try {
79
79
  const response = await apiClient.get(`/tasks/${taskUid}`);
80
80
  return {
@@ -115,7 +115,7 @@ export const registerTaskTools = (server) => {
115
115
  .array(z.number())
116
116
  .optional()
117
117
  .describe("UIDs of the tasks to cancel"),
118
- }, async ({ statuses, types, indexUids, uids }) => {
118
+ }, { category: "meilisearch" }, async ({ statuses, types, indexUids, uids }) => {
119
119
  try {
120
120
  const body = {};
121
121
  if (statuses && statuses.length > 0)
@@ -150,7 +150,7 @@ export const registerTaskTools = (server) => {
150
150
  .min(100)
151
151
  .optional()
152
152
  .describe("Polling interval in milliseconds (default: 500)"),
153
- }, async ({ taskUid, timeoutMs = 5000, intervalMs = 500, }) => {
153
+ }, { category: "meilisearch" }, async ({ taskUid, timeoutMs = 5000, intervalMs = 500, }) => {
154
154
  try {
155
155
  const startTime = Date.now();
156
156
  let taskCompleted = false;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/meilisearch/vector-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE;;;;;GAKG;AAEH;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,SAAS,SAyQpD,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import apiClient from "../utils/api-handler.js";
3
- import { createErrorResponse } from "../utils/error-handler.js";
2
+ import apiClient from "../../utils/api-handler.js";
3
+ import { createErrorResponse } from "../../utils/error-handler.js";
4
4
  /**
5
5
  * Meilisearch Vector Search Tools
6
6
  *
@@ -14,7 +14,7 @@ import { createErrorResponse } from "../utils/error-handler.js";
14
14
  */
15
15
  export const registerVectorTools = (server) => {
16
16
  // Enable vector search experimental feature
17
- server.tool("enable-vector-search", "Enable the vector search experimental feature in Meilisearch", {}, async () => {
17
+ server.tool("enable-vector-search", "Enable the vector search experimental feature in Meilisearch", {}, { category: "meilisearch" }, async () => {
18
18
  try {
19
19
  const response = await apiClient.post("/experimental-features", {
20
20
  vectorStore: true,
@@ -30,7 +30,7 @@ export const registerVectorTools = (server) => {
30
30
  }
31
31
  });
32
32
  // Get experimental features status
33
- server.tool("get-experimental-features", "Get the status of experimental features in Meilisearch", {}, async () => {
33
+ server.tool("get-experimental-features", "Get the status of experimental features in Meilisearch", {}, { category: "meilisearch" }, async () => {
34
34
  try {
35
35
  const response = await apiClient.get("/experimental-features");
36
36
  return {
@@ -49,7 +49,7 @@ export const registerVectorTools = (server) => {
49
49
  embedders: z
50
50
  .string()
51
51
  .describe("JSON object containing embedder configurations"),
52
- }, async ({ indexUid, embedders }) => {
52
+ }, { category: "meilisearch" }, async ({ indexUid, embedders }) => {
53
53
  try {
54
54
  // Parse the embedders string to ensure it's valid JSON
55
55
  const parsedEmbedders = JSON.parse(embedders);
@@ -78,7 +78,7 @@ export const registerVectorTools = (server) => {
78
78
  // Get embedders configuration
79
79
  server.tool("get-embedders", "Get the embedders configuration for an index", {
80
80
  indexUid: z.string().describe("Unique identifier of the index"),
81
- }, async ({ indexUid }) => {
81
+ }, { category: "meilisearch" }, async ({ indexUid }) => {
82
82
  try {
83
83
  const response = await apiClient.get(`/indexes/${indexUid}/settings/embedders`);
84
84
  return {
@@ -94,7 +94,7 @@ export const registerVectorTools = (server) => {
94
94
  // Reset embedders configuration
95
95
  server.tool("reset-embedders", "Reset the embedders configuration for an index", {
96
96
  indexUid: z.string().describe("Unique identifier of the index"),
97
- }, async ({ indexUid }) => {
97
+ }, { category: "meilisearch" }, async ({ indexUid }) => {
98
98
  try {
99
99
  const response = await apiClient.delete(`/indexes/${indexUid}/settings/embedders`);
100
100
  return {
@@ -150,7 +150,7 @@ export const registerVectorTools = (server) => {
150
150
  .max(1)
151
151
  .optional()
152
152
  .describe("Ratio of vector vs text search in hybrid search (0-1, default: 0.5)"),
153
- }, async ({ indexUid, vector, limit, offset, filter, embedder, attributes, query, hybrid, hybridRatio, }) => {
153
+ }, { category: "meilisearch" }, async ({ indexUid, vector, limit, offset, filter, embedder, attributes, query, hybrid, hybridRatio, }) => {
154
154
  try {
155
155
  const searchParams = {};
156
156
  // Add required vector parameter
@@ -0,0 +1,5 @@
1
+ export declare enum OPEN_ROUTER_API {
2
+ baseURL = "https://openrouter.ai/api/v1",
3
+ keys = "https://openrouter.ai/api/v1/keys"
4
+ }
5
+ //# sourceMappingURL=enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/types/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,OAAO,iCAAiC;IACxC,IAAI,sCAAoB;CACzB"}
@@ -0,0 +1,5 @@
1
+ export var OPEN_ROUTER_API;
2
+ (function (OPEN_ROUTER_API) {
3
+ OPEN_ROUTER_API["baseURL"] = "https://openrouter.ai/api/v1";
4
+ OPEN_ROUTER_API["keys"] = "https://openrouter.ai/api/v1/keys";
5
+ })(OPEN_ROUTER_API || (OPEN_ROUTER_API = {}));
@@ -16,6 +16,7 @@ interface AIToolResponse {
16
16
  * to use based on the user's query
17
17
  */
18
18
  export declare class AIService {
19
+ private apiKey;
19
20
  private model;
20
21
  private static instance;
21
22
  private static serverInitialized;
@@ -40,7 +41,7 @@ export declare class AIService {
40
41
  * @param provider AI provider name (defaults to openai)
41
42
  * @param model Optional model to use (defaults to gpt-3.5-turbo)
42
43
  */
43
- initialize(apiKey: string, provider?: AiProviderNameOptions, model?: string): void;
44
+ initialize(apiKey: string, provider?: AiProviderNameOptions, model?: string, forceNewInit?: boolean): void;
44
45
  /**
45
46
  * Set the available tools that can be used by the AI
46
47
  * @param tools Array of tools with name, description, and parameters
@@ -1 +1 @@
1
- {"version":3,"file":"ai-handler.d.ts","sourceRoot":"","sources":["../../src/utils/ai-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,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,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
+ {"version":3,"file":"ai-handler.d.ts","sourceRoot":"","sources":["../../src/utils/ai-handler.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,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,MAAM,CAAc;IAC5B,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,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,EACd,YAAY,GAAE,OAAe,GAC5B,IAAI;IA6BP;;;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,5 +1,6 @@
1
1
  import { OpenAI } from "openai";
2
2
  import systemPrompt from "../prompts/system.js";
3
+ import { OPEN_ROUTER_API } from "../types/enums.js";
3
4
  import { markdownToJson } from "./response-handler.js";
4
5
  import { InferenceClient } from "@huggingface/inference";
5
6
  /**
@@ -9,6 +10,7 @@ import { InferenceClient } from "@huggingface/inference";
9
10
  * to use based on the user's query
10
11
  */
11
12
  export class AIService {
13
+ apiKey = "";
12
14
  model = "gpt-3.5-turbo";
13
15
  static instance = null;
14
16
  static serverInitialized = false;
@@ -38,26 +40,27 @@ export class AIService {
38
40
  * @param provider AI provider name (defaults to openai)
39
41
  * @param model Optional model to use (defaults to gpt-3.5-turbo)
40
42
  */
41
- initialize(apiKey, provider = "openai", model) {
42
- if (AIService.serverInitialized) {
43
+ initialize(apiKey, provider = "openai", model, forceNewInit = false) {
44
+ if (AIService.serverInitialized && !forceNewInit) {
43
45
  console.warn("AIService has already been initialized by the server.");
44
46
  return;
45
47
  }
48
+ this.apiKey = apiKey;
46
49
  this.provider = provider;
47
50
  if (model)
48
51
  this.model = model;
49
52
  switch (this.provider) {
50
53
  case "openai":
51
- this.client = new OpenAI({ apiKey });
54
+ this.client = new OpenAI({ apiKey: this.apiKey });
52
55
  break;
53
56
  case "openrouter":
54
57
  this.client = new OpenAI({
55
- apiKey,
56
- baseURL: "https://openrouter.ai/api/v1",
58
+ apiKey: this.apiKey,
59
+ baseURL: OPEN_ROUTER_API.baseURL,
57
60
  });
58
61
  break;
59
62
  case "huggingface":
60
- this.client = new InferenceClient(apiKey);
63
+ this.client = new InferenceClient(this.apiKey);
61
64
  break;
62
65
  default:
63
66
  throw new Error(`Unsupported AI provider: ${this.provider}`);
@@ -126,9 +129,9 @@ export class AIService {
126
129
  { role: "user", content: query },
127
130
  ];
128
131
  if (this.provider === "huggingface") {
129
- return this.processHuggingFaceQuery(tools, messages);
132
+ return await this.processHuggingFaceQuery(tools, messages);
130
133
  }
131
- return this.processOpenAIQuery(tools, messages);
134
+ return await this.processOpenAIQuery(tools, messages);
132
135
  }
133
136
  async processOpenAIQuery(tools, messages) {
134
137
  const client = this.client;
@@ -23,7 +23,7 @@ export function markdownToJson(markdownJsonString) {
23
23
  S = S.replace(/,\s*([}\]])/g, "$1");
24
24
  try {
25
25
  const parsedJson = JSON.parse(S);
26
- return parsedJson;
26
+ return parseNestedJsonStrings(parsedJson);
27
27
  }
28
28
  catch (error) {
29
29
  console.error("Failed to parse JSON after transformations.");
@@ -33,3 +33,32 @@ export function markdownToJson(markdownJsonString) {
33
33
  return null;
34
34
  }
35
35
  }
36
+ function tryParseJsonString(str) {
37
+ try {
38
+ if (typeof str === "string" &&
39
+ ((str.startsWith("[") && str.endsWith("]")) ||
40
+ (str.startsWith("{") && str.endsWith("}")))) {
41
+ return JSON.parse(str);
42
+ }
43
+ return str;
44
+ }
45
+ catch {
46
+ return str;
47
+ }
48
+ }
49
+ function parseNestedJsonStrings(obj) {
50
+ if (Array.isArray(obj)) {
51
+ return obj.map((item) => parseNestedJsonStrings(item));
52
+ }
53
+ else if (obj !== null && typeof obj === "object") {
54
+ const result = {};
55
+ for (const key of Object.keys(obj)) {
56
+ result[key] = parseNestedJsonStrings(obj[key]);
57
+ }
58
+ return result;
59
+ }
60
+ else if (typeof obj === "string") {
61
+ return tryParseJsonString(obj);
62
+ }
63
+ return obj;
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-meilisearch",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "description": "Model Context Protocol (MCP) implementation for Meilisearch",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,15 +24,15 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "build": "tsc && tsc -p tsconfig.types.json",
27
- "demo": "npm run build & npm run dev --workspace=demo",
27
+ "demo": "npm run build & npm run preview --workspace=demo",
28
28
  "server": "npm run build && node --env-file=.env dist/index.js",
29
29
  "prepublishOnly": "rm -rf dist && npm version patch && npm run build"
30
30
  },
31
31
  "dependencies": {
32
32
  "@huggingface/inference": "^3.13.1",
33
- "@modelcontextprotocol/sdk": "^1.11.2",
33
+ "@modelcontextprotocol/sdk": "^1.11.4",
34
34
  "axios": "^1.9.0",
35
- "openai": "^4.98.0",
35
+ "openai": "^4.100.0",
36
36
  "zod": "^3.24.4"
37
37
  },
38
38
  "devDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-tools.d.ts","sourceRoot":"","sources":["../../src/tools/ai-tools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAapE;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,SAAS,SAwEhD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"document-tools.d.ts","sourceRoot":"","sources":["../../src/tools/document-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiDpE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,SAkQtD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-tools.d.ts","sourceRoot":"","sources":["../../src/tools/index-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAoCpE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,SAAS,SA6KnD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"search-tools.d.ts","sourceRoot":"","sources":["../../src/tools/search-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAkCpE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,SAAS,SAgRpD,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings-tools.d.ts","sourceRoot":"","sources":["../../src/tools/settings-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,SA0VtD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}