An MCP (Model Context Protocol) server that watches a directory for CSV files, exposes them as resources, and converts them to markdown tables automatically.
- Automatic CSV Detection: Monitors a directory for new CSV files
- Resource Management: Exposes CSV files as MCP resources
- Consume-and-Process Model: Files are automatically deleted after processing
- Smart Analysis: Analyzes CSV structure and data types
- Markdown Conversion: Converts CSV data to properly formatted markdown tables
- Instructional Prompting: Guides Claude Desktop to automatically process files
- Clone this repository:
git clone <repository-url>
cd csv-markdown-mcp-server- Install dependencies:
npm install- Configure environment variables:
cp .env.example .env
# Edit .env to set your input and output directoriesEdit the .env file to configure:
WATCH_DIRECTORY: Directory to monitor for CSV filesOUTPUT_DIRECTORY: Directory where markdown files will be savedLOG_LEVEL: Logging level (debug, info, warn, error)MAX_FILE_SIZE_MB: Maximum file size to processDEBOUNCE_MS: Debounce time for file changes
npm run devnpm startnpm run debug- File Detection: The server watches the input directory for CSV files
- Resource Registration: New CSV files are registered as MCP resources
- Automatic Processing: When Claude Desktop accesses a CSV resource:
- The file is read and analyzed
- Complete CSV data is embedded in the response
- An instructional prompt directs Claude to convert it immediately
- The source file is deleted after reading
- Markdown Generation: Claude executes the conversion tool to create a markdown file
- Output: The markdown file is saved to the output directory
Add this server to your Claude Desktop configuration:
{
"mcpServers": {
"csv-markdown": {
"command": "node",
"args": ["/path/to/csv-md-server/src/index.js"]
}
}
}- Place a CSV file in the watched directory
- Claude Desktop detects the new resource
- Access the resource to trigger automatic processing
- The CSV is converted to markdown and saved
- Source file is automatically removed
- No console output: The server does not output to console to avoid interfering with MCP stdio communication
- File-based logging: All logs are written to files in the
logs/directory - Check
logs/combined.logfor all server activity - Check
logs/error.logfor errors only
├── src/
│ ├── index.js # Main server entry
│ ├── config/ # Configuration management
│ ├── services/ # Core services
│ ├── handlers/ # MCP handlers
│ └── utils/ # Utilities
├── logs/ # Log files
├── input/ # Watch directory (configurable)
└── output/ # Output directory (configurable)
npm testnpm run lintThe MCP server is fully functional with the following features working:
- ✅ CSV file detection and monitoring
- ✅ Resource registration and management
- ✅ Automatic file consumption (files are deleted after processing)
- ✅ CSV to Markdown conversion
- ✅ Proper output directory handling
- ✅ Instructional prompting for Claude Desktop
⚠️ Resource change notifications (implemented but may require manual refresh in Claude Desktop)
- Improve resource change notification support (currently requires manual refresh in Claude Desktop)
- Add support for custom CSV delimiters (semicolon, tab, etc.)
- Add configuration for keeping source files instead of deleting them
- Implement batch processing for multiple CSV files
- Add support for CSV files with special characters in filenames
- Create unit tests for core functionality
- Add GitHub Actions for automated testing
- Publish to npm registry
- Resource notifications (
notifications/resources/list_changed) are sent but may not trigger automatic refresh in current Claude Desktop versions - Large CSV files may cause memory issues (consider streaming for files > 50MB)
MIT