Win-10-MCP-Server---Simple-persistant-logging
by trevorwilkerson
This server modification provides persistent logging for MCP Servers, specifically addressing issues with incomplete file writes. It creates backups of files before writing and logs file activity to aid in debugging and auditing.
Last updated: N/A
What is Win-10-MCP-Server---Simple-persistant-logging?
This is a modified version of an MCP server (likely @modelcontextprotocol/server-filesystem) that adds persistent logging and file backup functionality. It aims to address issues where the server might not completely write files, leading to data loss or corruption.
How to use Win-10-MCP-Server---Simple-persistant-logging?
- Create
logger.mjs
in your project root (as provided in the README). - Modify the
index.js
file (located inC:\Users\TrevorW\AppData\Roaming\npm\node_modules\@modelcontextprotocol\server-filesystem\dist
on the author's system) with the code provided in the README, specifically thewrite_file
case within thehandleOperation
function. - Ensure the necessary dependencies (fs, path, url) are available in your Node.js environment.
Key features of Win-10-MCP-Server---Simple-persistant-logging
Automatic file backups before writing
Detailed logging of file operations (writes, backups)
Validation of file paths to prevent unauthorized access
JSON response format for compatibility with Claude Desktop App
Error handling and logging for failed operations
Use cases of Win-10-MCP-Server---Simple-persistant-logging
Debugging file writing issues in MCP servers
Auditing file modifications
Protecting against data loss due to incomplete writes
Providing a history of file changes
Integrating with Claude Desktop App for improved feedback
FAQ from Win-10-MCP-Server---Simple-persistant-logging
Why create backups?
Why create backups?
To prevent data loss or corruption if the server fails to write the entire file.
Where are the logs stored?
Where are the logs stored?
Logs are stored in a logs
directory relative to the logger.mjs
file, in a file named KAN_server.log
.
What does the validatePath
function do?
What does the validatePath
function do?
It validates the provided file path to prevent unauthorized access and directory traversal.
Why is the response formatted as JSON?
Why is the response formatted as JSON?
To ensure compatibility with the Claude Desktop App, which expects responses in JSON format.
What happens if the log file cannot be written to?
What happens if the log file cannot be written to?
The error is logged to console.error
without disrupting the main flow of the application.