@ecommaps/mcp 1.0.7 → 1.0.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.
- package/README.md +6 -12
- package/cli.js +48 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,22 +7,12 @@ Streamable HTTP endpoint (`/api/v1/mcp`) while speaking stdio locally.
|
|
|
7
7
|
|
|
8
8
|
## Quick Start
|
|
9
9
|
|
|
10
|
-
Run
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
npx @ecommaps/mcp <YOUR_STORE_MCP_KEY>
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Use a custom endpoint (production or local):
|
|
10
|
+
Run with your store key and the official endpoint:
|
|
17
11
|
|
|
18
12
|
```bash
|
|
19
13
|
npx @ecommaps/mcp <YOUR_STORE_MCP_KEY> --url https://api.ecommaps.com/api/v1/mcp
|
|
20
14
|
```
|
|
21
15
|
|
|
22
|
-
```bash
|
|
23
|
-
npx @ecommaps/mcp <YOUR_STORE_MCP_KEY> --url http://127.0.0.1:8001/api/v1/mcp
|
|
24
|
-
```
|
|
25
|
-
|
|
26
16
|
## CLI Options
|
|
27
17
|
|
|
28
18
|
- `--url <MCP_URL>`: Override the MCP endpoint URL.
|
|
@@ -43,6 +33,7 @@ Use the following shape in any editor that supports stdio MCP servers:
|
|
|
43
33
|
{
|
|
44
34
|
"command": "npx",
|
|
45
35
|
"args": [
|
|
36
|
+
"-y",
|
|
46
37
|
"@ecommaps/mcp",
|
|
47
38
|
"sk_eco_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
48
39
|
"--url",
|
|
@@ -56,13 +47,16 @@ Or with env var:
|
|
|
56
47
|
```json
|
|
57
48
|
{
|
|
58
49
|
"command": "npx",
|
|
59
|
-
"args": ["@ecommaps/mcp", "--url", "https://api.ecommaps.com/api/v1/mcp"],
|
|
50
|
+
"args": ["-y", "@ecommaps/mcp", "--url", "https://api.ecommaps.com/api/v1/mcp"],
|
|
60
51
|
"env": {
|
|
61
52
|
"MCP_BEARER_TOKEN": "sk_eco_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
62
53
|
}
|
|
63
54
|
}
|
|
64
55
|
```
|
|
65
56
|
|
|
57
|
+
Important: keep `--url https://api.ecommaps.com/api/v1/mcp` in editor/server configs to avoid falling back to any outdated transport defaults.
|
|
58
|
+
Also make sure `--url` comes **after** `@ecommaps/mcp` in `args`; otherwise `npx` treats it as an npm flag and fails.
|
|
59
|
+
|
|
66
60
|
## Transport Notes
|
|
67
61
|
|
|
68
62
|
- Recommended endpoint: `POST /api/v1/mcp`
|
package/cli.js
CHANGED
|
@@ -11,17 +11,18 @@ function parseCliArgs(argv) {
|
|
|
11
11
|
let showHelp = false;
|
|
12
12
|
|
|
13
13
|
for (let i = 0; i < args.length; i += 1) {
|
|
14
|
-
const
|
|
14
|
+
const rawArg = args[i];
|
|
15
|
+
const arg = typeof rawArg === 'string' ? rawArg.replace(/[–—−]/g, '-') : rawArg;
|
|
15
16
|
if (arg === '--help' || arg === '-h') {
|
|
16
17
|
showHelp = true;
|
|
17
18
|
continue;
|
|
18
19
|
}
|
|
19
|
-
if (arg === '--url' && args[i + 1]) {
|
|
20
|
+
if ((arg === '--url' || arg === '-url') && args[i + 1]) {
|
|
20
21
|
mcpUrl = args[i + 1];
|
|
21
22
|
i += 1;
|
|
22
23
|
continue;
|
|
23
24
|
}
|
|
24
|
-
if (arg === '--api-key' && args[i + 1]) {
|
|
25
|
+
if ((arg === '--api-key' || arg === '-api-key') && args[i + 1]) {
|
|
25
26
|
apiKey = args[i + 1];
|
|
26
27
|
i += 1;
|
|
27
28
|
continue;
|
|
@@ -71,14 +72,14 @@ function normalizeResponsePayload(rawBody, contentType) {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
async function postRpc(mcpUrl, apiKey, rpcPayload) {
|
|
75
|
+
async function postRpc(mcpUrl, apiKey, rpcPayload, protocolVersion) {
|
|
75
76
|
const response = await fetch(mcpUrl, {
|
|
76
77
|
method: 'POST',
|
|
77
78
|
headers: {
|
|
78
79
|
Authorization: `Bearer ${apiKey}`,
|
|
79
80
|
'Content-Type': 'application/json',
|
|
80
81
|
Accept: 'application/json, text/event-stream',
|
|
81
|
-
'MCP-Protocol-Version': '2025-06-18',
|
|
82
|
+
'MCP-Protocol-Version': protocolVersion || '2025-06-18',
|
|
82
83
|
},
|
|
83
84
|
body: JSON.stringify(rpcPayload),
|
|
84
85
|
});
|
|
@@ -92,6 +93,11 @@ async function postRpc(mcpUrl, apiKey, rpcPayload) {
|
|
|
92
93
|
|
|
93
94
|
const payload = normalizeResponsePayload(rawBody, contentType);
|
|
94
95
|
if (payload === null) {
|
|
96
|
+
const isNotification = !Object.prototype.hasOwnProperty.call(rpcPayload ?? {}, 'id');
|
|
97
|
+
if (isNotification) {
|
|
98
|
+
// JSON-RPC notifications legitimately have no response body.
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
95
101
|
throw new Error('MCP response was empty.');
|
|
96
102
|
}
|
|
97
103
|
|
|
@@ -122,6 +128,7 @@ async function main() {
|
|
|
122
128
|
});
|
|
123
129
|
|
|
124
130
|
let queue = Promise.resolve();
|
|
131
|
+
let negotiatedProtocolVersion = '2025-06-18';
|
|
125
132
|
|
|
126
133
|
rl.on('line', (line) => {
|
|
127
134
|
const trimmed = line.trim();
|
|
@@ -137,16 +144,46 @@ async function main() {
|
|
|
137
144
|
}
|
|
138
145
|
|
|
139
146
|
try {
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
// Some MCP clients may send params as [] or omit them for list methods.
|
|
148
|
+
// Ecommaps MCP expects params to be an object, so normalize empty variants.
|
|
149
|
+
if (payload && typeof payload === 'object') {
|
|
150
|
+
if (
|
|
151
|
+
payload.params == null ||
|
|
152
|
+
(Array.isArray(payload.params) && payload.params.length === 0)
|
|
153
|
+
) {
|
|
154
|
+
payload.params = {};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const requestedVersion =
|
|
159
|
+
payload?.method === 'initialize' && typeof payload?.params?.protocolVersion === 'string'
|
|
160
|
+
? payload.params.protocolVersion
|
|
161
|
+
: negotiatedProtocolVersion;
|
|
162
|
+
|
|
163
|
+
const result = await postRpc(mcpUrl, apiKey, payload, requestedVersion);
|
|
164
|
+
if (
|
|
165
|
+
payload?.method === 'initialize' &&
|
|
166
|
+
result &&
|
|
167
|
+
typeof result === 'object' &&
|
|
168
|
+
result.result &&
|
|
169
|
+
typeof result.result.protocolVersion === 'string'
|
|
170
|
+
) {
|
|
171
|
+
negotiatedProtocolVersion = result.result.protocolVersion;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (result !== null) {
|
|
175
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
176
|
+
}
|
|
142
177
|
} catch (error) {
|
|
143
178
|
const message = error && error.message ? error.message : String(error);
|
|
144
179
|
console.error(message);
|
|
145
180
|
// Best-effort JSON-RPC error response so MCP clients stay synchronized.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
181
|
+
// Notifications do not expect responses.
|
|
182
|
+
if (payload && Object.prototype.hasOwnProperty.call(payload, 'id')) {
|
|
183
|
+
process.stdout.write(
|
|
184
|
+
`${JSON.stringify({ jsonrpc: '2.0', id: payload.id, error: { code: -32000, message } })}\n`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
150
187
|
}
|
|
151
188
|
});
|
|
152
189
|
});
|