vendure-mcp-graphql 1.2.0 → 1.3.1
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/index.js +32 -7
- package/dist/src/client.js +1 -8
- package/package.json +2 -2
- package/dist/src/types.d.ts +0 -45
- package/dist/src/types.js +0 -4
package/dist/index.js
CHANGED
|
@@ -7,15 +7,13 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
7
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
8
|
import { CallToolRequestSchema, ListToolsRequestSchema, ErrorCode, McpError, } from "@modelcontextprotocol/sdk/types.js";
|
|
9
9
|
import { config } from "dotenv";
|
|
10
|
-
import { resolve
|
|
11
|
-
import { fileURLToPath } from "url";
|
|
10
|
+
import { resolve } from "path";
|
|
12
11
|
import { existsSync } from "fs";
|
|
13
|
-
// Load environment variables
|
|
14
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
// Load environment variables from the project root (CWD)
|
|
15
13
|
// 1. Try to load from project root .env.local
|
|
16
|
-
config({ path: resolve(
|
|
14
|
+
config({ path: resolve(process.cwd(), ".env.local") });
|
|
17
15
|
// 2. Also try to load from specific vendure-api-key.env if it exists
|
|
18
|
-
const apiKeyPath = resolve(
|
|
16
|
+
const apiKeyPath = resolve(process.cwd(), "vendure-api-key.env");
|
|
19
17
|
if (existsSync(apiKeyPath)) {
|
|
20
18
|
const envConfig = config({ path: apiKeyPath });
|
|
21
19
|
if (envConfig.parsed?.VENDURE_API_KEY) {
|
|
@@ -23,9 +21,33 @@ if (existsSync(apiKeyPath)) {
|
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
import { adminQuery, adminMutation, adminBatchMutation, getAdminSchema, getAdminOperations, shopQuery, shopMutation, shopBatchMutation, getShopSchema, getShopOperations, } from "./src/tools/index.js";
|
|
24
|
+
// Singleton pattern for shared resources
|
|
25
|
+
class SharedResources {
|
|
26
|
+
static instance = null;
|
|
27
|
+
static initializing = false;
|
|
28
|
+
constructor() { }
|
|
29
|
+
static async getInstance() {
|
|
30
|
+
if (this.instance)
|
|
31
|
+
return this.instance;
|
|
32
|
+
while (this.initializing) {
|
|
33
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
34
|
+
}
|
|
35
|
+
if (this.instance)
|
|
36
|
+
return this.instance;
|
|
37
|
+
this.initializing = true;
|
|
38
|
+
try {
|
|
39
|
+
// Initialize any shared resources here if needed
|
|
40
|
+
this.instance = new SharedResources();
|
|
41
|
+
return this.instance;
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
this.initializing = false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
26
48
|
const server = new Server({
|
|
27
49
|
name: "vendure-mcp-graphql",
|
|
28
|
-
version: "1.
|
|
50
|
+
version: "1.3.1",
|
|
29
51
|
}, {
|
|
30
52
|
capabilities: {
|
|
31
53
|
tools: {},
|
|
@@ -285,9 +307,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
285
307
|
});
|
|
286
308
|
// Start the server
|
|
287
309
|
async function main() {
|
|
310
|
+
// Initialize shared resources (singleton pattern)
|
|
311
|
+
await SharedResources.getInstance();
|
|
288
312
|
const transport = new StdioServerTransport();
|
|
289
313
|
await server.connect(transport);
|
|
290
314
|
console.error("Vendure GraphQL MCP server running on stdio");
|
|
315
|
+
console.error("Memory optimization: GraphQL client shared via singleton");
|
|
291
316
|
console.error(`API Key: ${process.env.VENDURE_API_KEY ? "Present" : "Missing"}`);
|
|
292
317
|
console.error(`Admin URL: ${process.env.ADMIN_API_URL || "default"}`);
|
|
293
318
|
console.error(`Shop URL: ${process.env.SHOP_API_URL || "default"}`);
|
package/dist/src/client.js
CHANGED
|
@@ -33,15 +33,8 @@ export class GraphQLClient {
|
|
|
33
33
|
return result.data;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
// Singleton instance
|
|
37
|
-
let clientInstance = null;
|
|
38
36
|
export function getClient() {
|
|
39
|
-
|
|
40
|
-
return clientInstance;
|
|
41
|
-
}
|
|
42
|
-
const apiKey = process.env.VENDURE_API_KEY || null;
|
|
43
|
-
clientInstance = new GraphQLClient(apiKey);
|
|
44
|
-
return clientInstance;
|
|
37
|
+
return new GraphQLClient(process.env.VENDURE_API_KEY || null);
|
|
45
38
|
}
|
|
46
39
|
export function getAdminUrl() {
|
|
47
40
|
return process.env.ADMIN_API_URL || "http://localhost:3000/admin-api";
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vendure-mcp-graphql",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "MCP server for Vendure Admin and Shop GraphQL APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"vendure-mcp-graphql": "
|
|
7
|
+
"vendure-mcp-graphql": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"files": [
|
package/dist/src/types.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for GraphQL entities
|
|
3
|
-
*/
|
|
4
|
-
export interface Archetype {
|
|
5
|
-
id: string;
|
|
6
|
-
code: string;
|
|
7
|
-
name: string;
|
|
8
|
-
coreDrive: string;
|
|
9
|
-
primaryFear: string;
|
|
10
|
-
languageSignature: string;
|
|
11
|
-
psychologicalTriggers: string[];
|
|
12
|
-
}
|
|
13
|
-
export type PulseScriptType = 'OPENING' | 'RESPONSE' | 'RESOLUTION' | 'CUSTOM';
|
|
14
|
-
export interface PulseScript {
|
|
15
|
-
id: string;
|
|
16
|
-
code: string;
|
|
17
|
-
name: string;
|
|
18
|
-
type: PulseScriptType;
|
|
19
|
-
description?: string;
|
|
20
|
-
archetypeId: string;
|
|
21
|
-
archetype?: Archetype;
|
|
22
|
-
}
|
|
23
|
-
export interface CreatePulseScriptInput {
|
|
24
|
-
code: string;
|
|
25
|
-
name: string;
|
|
26
|
-
type: PulseScriptType;
|
|
27
|
-
description?: string;
|
|
28
|
-
archetypeId: string;
|
|
29
|
-
}
|
|
30
|
-
export interface UpdatePulseScriptInput {
|
|
31
|
-
id: string;
|
|
32
|
-
code?: string;
|
|
33
|
-
name?: string;
|
|
34
|
-
type?: PulseScriptType;
|
|
35
|
-
description?: string;
|
|
36
|
-
archetypeId?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface Pulse {
|
|
39
|
-
id: string;
|
|
40
|
-
code: string;
|
|
41
|
-
status: string;
|
|
42
|
-
currentState: string;
|
|
43
|
-
initiatorArchetype?: Archetype;
|
|
44
|
-
targetArchetype?: Archetype;
|
|
45
|
-
}
|
package/dist/src/types.js
DELETED