@vendemass/mcp-client 0.1.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.
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * VendeMass MCP Client — Thin stdio proxy to VendeMass Gateway
4
+ *
5
+ * Zero dependencies on the VendeMass repo. Install from npm:
6
+ * npx @vendemass/mcp-client
7
+ *
8
+ * All business logic, credentials, and security (7 layers) live on the server.
9
+ * This client only forwards MCP tool calls via HTTPS.
10
+ *
11
+ * Config (env vars):
12
+ * VENDEMASS_TOKEN — Your MCP token (get it from /dashboard/integraciones/mcp)
13
+ * VENDEMASS_URL — Gateway URL (default: production endpoint)
14
+ */
15
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * VendeMass MCP Client — Thin stdio proxy to VendeMass Gateway
4
+ *
5
+ * Zero dependencies on the VendeMass repo. Install from npm:
6
+ * npx @vendemass/mcp-client
7
+ *
8
+ * All business logic, credentials, and security (7 layers) live on the server.
9
+ * This client only forwards MCP tool calls via HTTPS.
10
+ *
11
+ * Config (env vars):
12
+ * VENDEMASS_TOKEN — Your MCP token (get it from /dashboard/integraciones/mcp)
13
+ * VENDEMASS_URL — Gateway URL (default: production endpoint)
14
+ */
15
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
16
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
17
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
18
+ const ENDPOINT = process.env.VENDEMASS_URL ??
19
+ process.env.VDTT_ENDPOINT ??
20
+ 'https://vdtt-mcp-gateway.massenterprises-develop.workers.dev';
21
+ const TOKEN = process.env.VENDEMASS_TOKEN ??
22
+ process.env.VDTT_TOKEN;
23
+ if (!TOKEN) {
24
+ console.error('[VendeMass] VENDEMASS_TOKEN is required.\n' +
25
+ 'Get yours at: https://vendemass.com/dashboard/integraciones/mcp');
26
+ process.exit(1);
27
+ }
28
+ // --- Fetch tools dynamically from server ---
29
+ async function fetchTools() {
30
+ try {
31
+ const res = await fetch(`${ENDPOINT}/tools`, {
32
+ headers: { Authorization: `Bearer ${TOKEN}` },
33
+ });
34
+ if (!res.ok)
35
+ throw new Error(`HTTP ${res.status}`);
36
+ const data = (await res.json());
37
+ return data.tools ?? [];
38
+ }
39
+ catch (err) {
40
+ console.error('[VendeMass] Failed to fetch tools:', err);
41
+ return [];
42
+ }
43
+ }
44
+ // --- RPC call to server ---
45
+ async function rpc(op, payload) {
46
+ const res = await fetch(`${ENDPOINT}/rpc`, {
47
+ method: 'POST',
48
+ headers: {
49
+ Authorization: `Bearer ${TOKEN}`,
50
+ 'Content-Type': 'application/json',
51
+ },
52
+ body: JSON.stringify({ op, payload }),
53
+ });
54
+ if (res.status === 401)
55
+ return { success: false, error: 'Token inválido. Regenera tu token en /dashboard/integraciones/mcp' };
56
+ if (res.status === 429)
57
+ return { success: false, error: 'Límite de solicitudes excedido. Intenta en unos segundos.' };
58
+ if (!res.ok)
59
+ return { success: false, error: `Error del gateway: HTTP ${res.status}` };
60
+ return (await res.json());
61
+ }
62
+ // --- MCP Server ---
63
+ const server = new Server({ name: 'vendemass', version: '0.1.0' }, { capabilities: { tools: {} } });
64
+ // Tools are fetched dynamically from the server — no hardcoded mapping needed.
65
+ // The server returns tool names that match operation names directly.
66
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
67
+ const tools = await fetchTools();
68
+ return { tools };
69
+ });
70
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
71
+ const { name, arguments: args } = request.params;
72
+ try {
73
+ // Tool name IS the operation name (server uses dot notation: product.list, etc.)
74
+ const response = await rpc(name, args ?? {});
75
+ if (!response.success) {
76
+ return {
77
+ content: [
78
+ {
79
+ type: 'text',
80
+ text: JSON.stringify({ error: response.error, requestId: response.requestId }, null, 2),
81
+ },
82
+ ],
83
+ isError: true,
84
+ };
85
+ }
86
+ return {
87
+ content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }],
88
+ };
89
+ }
90
+ catch (err) {
91
+ return {
92
+ content: [
93
+ {
94
+ type: 'text',
95
+ text: `Gateway inalcanzable: ${err instanceof Error ? err.message : String(err)}`,
96
+ },
97
+ ],
98
+ isError: true,
99
+ };
100
+ }
101
+ });
102
+ // --- Start ---
103
+ async function main() {
104
+ const transport = new StdioServerTransport();
105
+ await server.connect(transport);
106
+ }
107
+ main().catch((err) => {
108
+ console.error('[VendeMass MCP] Fatal:', err);
109
+ process.exit(1);
110
+ });
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@vendemass/mcp-client",
3
+ "version": "0.1.0",
4
+ "description": "Conecta tu IA a VendeMass via MCP. Proxy ligero al gateway seguro.",
5
+ "private": false,
6
+ "type": "module",
7
+ "bin": {
8
+ "vendemass-mcp": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "start": "node dist/index.js",
15
+ "build": "tsc",
16
+ "prepublishOnly": "npm run build"
17
+ },
18
+ "keywords": ["mcp", "vendemass", "ai", "marketplace", "claude", "cursor", "windsurf"],
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/ROCHER1025/vdtt.git",
23
+ "directory": "apps/mcp-client"
24
+ },
25
+ "engines": {
26
+ "node": ">=18"
27
+ },
28
+ "dependencies": {
29
+ "@modelcontextprotocol/sdk": "^1.27.1"
30
+ }
31
+ }