sap-wm-mcp 0.2.3 → 0.2.4

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
@@ -26,6 +26,7 @@ The **npm package** ships 18 tools covering core operations, analytics, shift ma
26
26
  - [MCP Client Setup](#mcp-client-setup)
27
27
  - [Option A — npx (Claude Desktop, Claude Code, Cursor)](#option-a--npx-recommended)
28
28
  - [Option B — Clone locally](#option-b--clone-locally-for-developers)
29
+ - [Windows troubleshooting (Claude Code)](#windows-claude-code)
29
30
  - [Verify it's working](#verify-its-working)
30
31
  - [Example conversations](#example-conversations)
31
32
  - [Tools Reference](#tools-reference)
@@ -194,6 +195,75 @@ The sap-wm-mcp tools appear automatically in the tools panel. You'll see a hamme
194
195
 
195
196
  > **`.mcp.json` is project-scoped.** Add it to `.gitignore` — it contains credentials.
196
197
 
198
+ > **Windows users:** If the server doesn't appear after restart, see [Windows troubleshooting](#windows-claude-code) below.
199
+
200
+ ---
201
+
202
+ #### Claude Code — Windows
203
+
204
+ On Windows, Claude Code may silently fail to launch `npx` or `node` directly (known issue with process spawning). If the server doesn't appear in `/mcp`, use this pattern instead.
205
+
206
+ **Step 1 — Create a wrapper script** (requires [Git for Windows](https://gitforwindows.org)):
207
+
208
+ Save as `scripts/run-sap-wm-mcp.sh` in your project:
209
+
210
+ ```bash
211
+ #!/bin/bash
212
+ SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)"
213
+ ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
214
+
215
+ exec npx --prefix "$ROOT_DIR" sap-wm-mcp
216
+ ```
217
+
218
+ Or to load credentials from a `.env` file instead of inline in `.mcp.json`:
219
+
220
+ ```bash
221
+ #!/bin/bash
222
+ SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)"
223
+ ENV_FILE="$(cd "$SCRIPT_DIR/.." && pwd)/.env"
224
+
225
+ if [ -f "$ENV_FILE" ]; then
226
+ set -a; source "$ENV_FILE"; set +a
227
+ else
228
+ echo "ERROR: .env not found" >&2; exit 1
229
+ fi
230
+
231
+ exec npx sap-wm-mcp
232
+ ```
233
+
234
+ **Step 2 — Update `.mcp.json`** to use `bash.exe` as the command:
235
+
236
+ ```json
237
+ {
238
+ "mcpServers": {
239
+ "sap-wm-mcp": {
240
+ "command": "C:/Program Files/Git/usr/bin/bash.exe",
241
+ "args": [
242
+ "C:/absolute/path/to/your/project/scripts/run-sap-wm-mcp.sh"
243
+ ]
244
+ }
245
+ }
246
+ }
247
+ ```
248
+
249
+ Use an absolute path with forward slashes. No `env` block needed if credentials are in `.env`.
250
+
251
+ **Step 3 — Skip the approval dialog** (optional but recommended):
252
+
253
+ Create `.claude/settings.local.json` in your project root:
254
+
255
+ ```json
256
+ {
257
+ "enableAllProjectMcpServers": true
258
+ }
259
+ ```
260
+
261
+ This prevents a silently-dismissed approval prompt from blocking the server on every restart.
262
+
263
+ **Step 4 — Restart Claude Code.** Run `/mcp` to verify the tools are loaded.
264
+
265
+ > **Note:** If the server was previously rejected in the approval dialog, run `claude mcp reset-project-choices` before restarting.
266
+
197
267
  ---
198
268
 
199
269
  #### Cursor, Windsurf, and other MCP clients
@@ -232,7 +302,7 @@ node index.js
232
302
 
233
303
  Then point your MCP client at the local file:
234
304
 
235
- **Claude Desktop:**
305
+ **Claude Desktop / macOS / Linux:**
236
306
  ```json
237
307
  {
238
308
  "mcpServers": {
@@ -244,6 +314,8 @@ Then point your MCP client at the local file:
244
314
  }
245
315
  ```
246
316
 
317
+ **Claude Code on Windows** — use the bash wrapper pattern (see [Windows troubleshooting](#windows-claude-code)) with `exec node "$ROOT_DIR/index.js"` in the script instead of `npx`.
318
+
247
319
  ---
248
320
 
249
321
  ### Verify it's working
package/lib/s4hClient.js CHANGED
@@ -130,8 +130,25 @@ export async function s4hPost(path, body) {
130
130
 
131
131
  if (!response.ok) {
132
132
  const text = await response.text();
133
- log('error', 'odata_post_http_error', { url, status: response.status, ms: Date.now() - start });
134
- throw new Error(`OData POST failed [${response.status}] — see server log for details`);
133
+ log('error', 'odata_post_http_error', { url, status: response.status, body: text, ms: Date.now() - start });
134
+
135
+ // Extract the SAP business error message from the OData V4 error body.
136
+ // RAP surfaces reported[] messages in error.innererror.errordetails[].
137
+ // Only the message string is returned — the raw body stays in the log.
138
+ let sapMessage = null;
139
+ try {
140
+ const errJson = JSON.parse(text);
141
+ const details = errJson?.error?.innererror?.errordetails;
142
+ if (Array.isArray(details) && details.length > 0) {
143
+ sapMessage = details.find(d => d.severity === 'error')?.message ?? details[0]?.message;
144
+ }
145
+ sapMessage = sapMessage ?? errJson?.error?.message ?? null;
146
+ } catch { /* non-JSON body — fall through to generic message */ }
147
+
148
+ const msg = sapMessage
149
+ ? `OData POST failed [${response.status}]: ${sapMessage}`
150
+ : `OData POST failed [${response.status}] — see server log for details`;
151
+ throw new Error(msg);
135
152
  }
136
153
 
137
154
  log('debug', 'odata_post_ok', { url, ms: Date.now() - start });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sap-wm-mcp",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "MCP server for SAP Classic Warehouse Management — connects AI agents to S/4HANA WM via a custom RAP OData V4 service. For systems where EWM is not active.",
5
5
  "type": "module",
6
6
  "main": "index.js",