@imenam/xls-reader 2.4.1 → 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 +1 -1
- package/dist/index.js +1 -4
- package/dist/logger.js +5 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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.",
|
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/package.json
CHANGED