@imenam/xls-reader 2.4.0 → 2.4.3
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 +2 -2
- package/dist/index.js +7 -5
- package/dist/logger.js +5 -6
- package/dist/relay.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,7 +100,7 @@ Exports a workbook as a JSON file, with **no size limit**, and writes it **on th
|
|
|
100
100
|
| `destination_overwrite` | `boolean` | ❌ | Replace the destination file if it exists (default: `false`) |
|
|
101
101
|
| `destination_relay` | `boolean` | ❌ | Filled in by the relay, never by the agent |
|
|
102
102
|
|
|
103
|
-
The exported file never passes through the conversation. When this MCP runs next to the agent (stdio), it writes the file itself. Behind [`@imenam/mcp-http-gateway`](https://www.npmjs.com/package/@imenam/mcp-http-gateway) it runs on the gateway's machine and cannot reach the agent's disk: it then returns the bytes, and the relay — which *does* run on the agent machine — writes them at `destination_path`. That path requires `GATEWAY_INLINE_WRITE_ROOTS` in the relay's `env` block; without it the call fails explicitly rather than dropping the file on the wrong machine.
|
|
103
|
+
The exported file never passes through the conversation. When this MCP runs next to the agent (stdio), it writes the file itself. Behind [`@imenam/mcp-http-gateway`](https://www.npmjs.com/package/@imenam/mcp-http-gateway) it runs on the gateway's machine and cannot reach the agent's disk: it then returns the bytes, and the relay — which *does* run on the agent machine — writes them at `destination_path`. The relay keeps that path to itself and never forwards it, which is why the tool schema declares it optional; the tool rejects a call that lacks it when it has to write the file itself. That path requires `GATEWAY_INLINE_WRITE_ROOTS` in the relay's `env` block; without it the call fails explicitly rather than dropping the file on the wrong machine.
|
|
104
104
|
|
|
105
105
|
The file content is:
|
|
106
106
|
|
|
@@ -144,7 +144,7 @@ Or point to a local build:
|
|
|
144
144
|
|
|
145
145
|
## Configuration
|
|
146
146
|
|
|
147
|
-
No environment variables are required. Optionally, set `MCP_LOG_DIR` to change where logs are written (default:
|
|
147
|
+
No environment variables are required. Optionally, set `MCP_LOG_DIR` to change where logs are written (default: `.xls-reader/logs` in the home directory of the user running the server). When the log file cannot be written, each log line is reported on stderr as `Critical: Failed to write to log file <path>: <reason>` and the server keeps running.
|
|
148
148
|
|
|
149
149
|
```env
|
|
150
150
|
# .env
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { listSheets, readSheet, readWorkbook } from "./excel.js";
|
|
|
10
10
|
import { deliverFile, RELAY_SHAPE_DESCRIPTIONS } from "./relay.js";
|
|
11
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
const rootDir = path.resolve(__dirname, "..");
|
|
13
|
-
dotenv.config({ path: path.join(rootDir, ".env"), override: true });
|
|
13
|
+
dotenv.config({ path: path.join(rootDir, ".env"), override: true, quiet: true });
|
|
14
14
|
setupLogging("MASTER");
|
|
15
15
|
const server = new McpServer({
|
|
16
16
|
name: "xls-reader",
|
|
@@ -107,9 +107,6 @@ server.tool("get_sheet", [
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
// ─── export_workbook ──────────────────────────────────────────────────────────
|
|
110
|
-
// L'export est un outil à part, et non un `format` de get_sheet : le relais rend
|
|
111
|
-
// obligatoire tout `<x>_path` dont il voit la paire, donc porter `destination_path` dans
|
|
112
|
-
// get_sheet forcerait une destination sur chaque simple lecture de feuille.
|
|
113
110
|
server.tool("export_workbook", [
|
|
114
111
|
"Export an Excel workbook as a JSON file written on the agent machine, with no size limit.",
|
|
115
112
|
"Exports the whole workbook, or only sheet_name when provided.",
|
|
@@ -125,7 +122,12 @@ server.tool("export_workbook", [
|
|
|
125
122
|
.boolean()
|
|
126
123
|
.optional()
|
|
127
124
|
.describe("Treat the first row as a column header (default: true)"),
|
|
128
|
-
|
|
125
|
+
// Optionnel au niveau du schéma : le relais retient ce chemin et ne le transmet pas.
|
|
126
|
+
// deliverFile l'exige quand l'écriture a lieu ici.
|
|
127
|
+
destination_path: z
|
|
128
|
+
.string()
|
|
129
|
+
.optional()
|
|
130
|
+
.describe(`${RELAY_SHAPE_DESCRIPTIONS.destination_path}. Required`),
|
|
129
131
|
filename: z.string().describe(RELAY_SHAPE_DESCRIPTIONS.filename),
|
|
130
132
|
destination_overwrite: z
|
|
131
133
|
.boolean()
|
package/dist/logger.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
+
import os from "os";
|
|
2
3
|
import path from "path";
|
|
3
4
|
let currentPrefix = "";
|
|
4
5
|
export function logToFile(message, prefix = "") {
|
|
5
|
-
const
|
|
6
|
-
? "C:\\var\\log\\xls-reader"
|
|
7
|
-
: "/var/log/xls-reader";
|
|
8
|
-
const logDir = process.env.MCP_LOG_DIR ?? defaultLogDir;
|
|
6
|
+
const logDir = process.env.MCP_LOG_DIR ?? path.join(os.homedir(), ".xls-reader", "logs");
|
|
9
7
|
const logFile = path.join(logDir, "server.log");
|
|
10
8
|
const now = new Date().toLocaleString("fr-FR", {
|
|
11
9
|
year: "numeric",
|
|
@@ -24,8 +22,9 @@ export function logToFile(message, prefix = "") {
|
|
|
24
22
|
}
|
|
25
23
|
fs.appendFileSync(logFile, logEntry);
|
|
26
24
|
}
|
|
27
|
-
catch {
|
|
28
|
-
|
|
25
|
+
catch (error) {
|
|
26
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
27
|
+
process.stderr.write(`Critical: Failed to write to log file ${logFile}: ${reason}\n`);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
export function setupLogging(prefix) {
|
package/dist/relay.js
CHANGED
|
@@ -50,6 +50,9 @@ export function deliverFile(data, mimeType, target) {
|
|
|
50
50
|
];
|
|
51
51
|
}
|
|
52
52
|
// Pas de relais : le MCP tourne à côté de l'agent, son disque est le bon.
|
|
53
|
+
if (!target.destination_path) {
|
|
54
|
+
throw new Error("destination_path is required: the absolute directory where the file is written.");
|
|
55
|
+
}
|
|
53
56
|
if (!path.isAbsolute(target.destination_path)) {
|
|
54
57
|
throw new Error(`destination_path must be an absolute directory path: ${target.destination_path}`);
|
|
55
58
|
}
|
package/package.json
CHANGED