vendure-mcp-graphql 1.2.0 → 1.3.0

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 (2) hide show
  1. package/dist/index.js +27 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -23,6 +23,30 @@ if (existsSync(apiKeyPath)) {
23
23
  }
24
24
  }
25
25
  import { adminQuery, adminMutation, adminBatchMutation, getAdminSchema, getAdminOperations, shopQuery, shopMutation, shopBatchMutation, getShopSchema, getShopOperations, } from "./src/tools/index.js";
26
+ // Singleton pattern for shared resources
27
+ class SharedResources {
28
+ static instance = null;
29
+ static initializing = false;
30
+ constructor() { }
31
+ static async getInstance() {
32
+ if (this.instance)
33
+ return this.instance;
34
+ while (this.initializing) {
35
+ await new Promise((resolve) => setTimeout(resolve, 100));
36
+ }
37
+ if (this.instance)
38
+ return this.instance;
39
+ this.initializing = true;
40
+ try {
41
+ // Initialize any shared resources here if needed
42
+ this.instance = new SharedResources();
43
+ return this.instance;
44
+ }
45
+ finally {
46
+ this.initializing = false;
47
+ }
48
+ }
49
+ }
26
50
  const server = new Server({
27
51
  name: "vendure-mcp-graphql",
28
52
  version: "1.0.0",
@@ -285,9 +309,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
285
309
  });
286
310
  // Start the server
287
311
  async function main() {
312
+ // Initialize shared resources (singleton pattern)
313
+ await SharedResources.getInstance();
288
314
  const transport = new StdioServerTransport();
289
315
  await server.connect(transport);
290
316
  console.error("Vendure GraphQL MCP server running on stdio");
317
+ console.error("Memory optimization: GraphQL client shared via singleton");
291
318
  console.error(`API Key: ${process.env.VENDURE_API_KEY ? "Present" : "Missing"}`);
292
319
  console.error(`Admin URL: ${process.env.ADMIN_API_URL || "default"}`);
293
320
  console.error(`Shop URL: ${process.env.SHOP_API_URL || "default"}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vendure-mcp-graphql",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "MCP server for Vendure Admin and Shop GraphQL APIs",
5
5
  "type": "module",
6
6
  "bin": {