mcp-meilisearch 1.0.21 → 1.0.25

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/README.md CHANGED
@@ -94,7 +94,7 @@ This project uses:
94
94
  #### MCP Server Options
95
95
 
96
96
  - `transport`: Transport type for MCP server ("http" | "stdio") (Default: "http")
97
- - `httpPort`: HTTP port for MCP server (Default: 8080)
97
+ - `httpPort`: HTTP port for MCP server (Default: 4995)
98
98
  - `mcpEndpoint`: MCP endpoint path (Default: "/mcp")
99
99
 
100
100
  #### Session Options
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,aAGR,GACA,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAmGtB;AAqCD,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,aAGR,GACA,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAqGtB;AAkCD,eAAe,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -15,13 +15,13 @@ export async function mcpMeilisearchServer(options = {
15
15
  configHandler.setMeilisearchHost(options.meilisearchHost);
16
16
  configHandler.setMeilisearchApiKey(options.meilisearchApiKey);
17
17
  let mcpServerInstance = null;
18
- const httpPort = options.httpPort || 8080;
18
+ const httpPort = options.httpPort || 4995;
19
19
  const transport = options.transport || "http";
20
20
  const mcpEndpoint = options.mcpEndpoint || "/mcp";
21
21
  const server = createServer(async (req, res) => {
22
22
  res.setHeader("Access-Control-Allow-Origin", "*");
23
23
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
24
- res.setHeader("Access-Control-Allow-Headers", `Origin, X-Requested-With, Content-Type, Accept, mcp-session-id`);
24
+ res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, mcp-session-id");
25
25
  if (req.method === "OPTIONS") {
26
26
  res.statusCode = 200;
27
27
  res.end();
@@ -29,43 +29,41 @@ export async function mcpMeilisearchServer(options = {
29
29
  }
30
30
  const parsedUrl = parseUrl(req.url || "/", true);
31
31
  const pathname = parsedUrl.pathname || "/";
32
- if (pathname.startsWith(mcpEndpoint)) {
33
- if (!mcpServerInstance) {
34
- console.error("MCP server not initialized yet");
35
- res.statusCode = 503;
36
- res.setHeader("Content-Type", "application/json");
37
- res.end(JSON.stringify(createErrorResponse("MCP server not initialized yet")));
38
- return;
39
- }
40
- if (req.method === "GET") {
41
- await mcpServerInstance.handleGetRequest(req, res);
42
- }
43
- else if (req.method === "POST") {
44
- let body = "";
45
- req.on("data", (chunk) => {
46
- body += chunk.toString();
47
- });
48
- req.on("end", async () => {
49
- try {
50
- const jsonBody = JSON.parse(body);
51
- await mcpServerInstance.handlePostRequest(req, res, jsonBody);
52
- }
53
- catch (error) {
54
- console.error("Error parsing request body:", error);
55
- res.statusCode = 400;
56
- res.end(JSON.stringify(createErrorResponse("Invalid JSON body")));
57
- }
58
- });
59
- }
60
- else {
61
- res.statusCode = 405;
62
- res.end(JSON.stringify(createErrorResponse("Method not allowed")));
63
- }
64
- }
65
- else {
32
+ if (!pathname.startsWith(mcpEndpoint)) {
66
33
  res.statusCode = 404;
67
34
  res.end(JSON.stringify({ error: "Not found" }));
35
+ return;
36
+ }
37
+ if (!mcpServerInstance) {
38
+ console.error("MCP server not initialized yet");
39
+ res.statusCode = 503;
40
+ res.setHeader("Content-Type", "application/json");
41
+ res.end(JSON.stringify(createErrorResponse("MCP server not initialized yet")));
42
+ return;
43
+ }
44
+ if (req.method === "GET") {
45
+ await mcpServerInstance.handleGetRequest(req, res);
46
+ return;
47
+ }
48
+ if (req.method === "POST") {
49
+ let body = "";
50
+ req.on("data", (chunk) => {
51
+ body += chunk.toString();
52
+ });
53
+ req.on("end", async () => {
54
+ try {
55
+ const jsonBody = JSON.parse(body);
56
+ await mcpServerInstance.handlePostRequest(req, res, jsonBody);
57
+ }
58
+ catch {
59
+ res.statusCode = 400;
60
+ res.end(JSON.stringify(createErrorResponse("Invalid JSON body")));
61
+ }
62
+ });
63
+ return;
68
64
  }
65
+ res.statusCode = 405;
66
+ res.end(JSON.stringify(createErrorResponse("Method not allowed")));
69
67
  });
70
68
  await new Promise((resolve) => {
71
69
  server.listen(httpPort, () => {
package/dist/server.js CHANGED
@@ -12,7 +12,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
12
12
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
13
13
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
14
14
  const DEFAULT_CONFIG = {
15
- httpPort: 8080,
15
+ httpPort: 4995,
16
16
  mcpEndpoint: "/mcp",
17
17
  sessionTimeout: 3600000,
18
18
  sessionCleanupInterval: 60000,
@@ -17,7 +17,7 @@ export interface ServerOptions {
17
17
  transport?: "http" | "stdio";
18
18
  /**
19
19
  * HTTP port for MCP server
20
- * @default 8080
20
+ * @default 4995
21
21
  */
22
22
  httpPort?: number;
23
23
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-meilisearch",
3
- "version": "1.0.21",
3
+ "version": "1.0.25",
4
4
  "description": "Model Context Protocol (MCP) implementation for Meilisearch",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",