Chakotay-Lee/mcp-source-server
If you are the rightful owner of mcp-source-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This MCP Server allows AI assistants to interact with your codebase, providing intelligent suggestions and automating repetitive tasks.
read_source_file
Read file content
write_source_file
Write content to file
list_source_files
List files in directory
stream_write_source_file
Stream write for large files
delete_source_file
Delete file with backup option
rename_source_file
Rename or move file with backup
partial_write_source_file
Update specific file content (LLM optimized)
get_server_stats
Get server status and statistics
Preface
Want to do Vibe Coding with AI assistance but tired of being limited to tools like Cursor or Windsurf with additional API costs? Why not leverage the AI assistants you're already paying for, like Claude Desktop, for your development workflow? With this mindset, I developed this MCP Server (or rather, I had Claude help me develop this tool). Once you set up this MCP Server, your AI assistant can automatically search through relevant files in your project, analyze the codebase, and provide intelligent correction suggestions. While you'll still need to handle building and running your project manually and paste error messages back into the conversation, this approach can significantly reduce repetitive copy-paste work for users who are already subscribed to AI services, making the development process much more streamlined.
โจ Features
Core File Operations
- Read Files: Securely read source code files with size limits
- Write Files: Create and update files with optional backup
- List Files: Browse directory contents with metadata
- Stream Writing: Efficient handling of large file writes
๐ Enhanced Operations (v0.2.1)
- Delete Files: Safely delete files with automatic backup
- Rename/Move Files: Rename files or move them between directories
- Partial Write: LLM-optimized feature to update specific file sections without rewriting entire files
๐ Security Features
- Directory Traversal Protection: Prevents access outside workspace
- File Extension Whitelist: Only allows approved file types
- Path Blacklisting: Blocks access to sensitive directories
- Size Limits: Prevents excessive file operations
- Concurrent Operation Limits: Protects system resources
๐ Quick Start
Installation
# Clone the repository
git clone git@hgithub.com/Chakotay-Lee/mcp-source-server
cd mcp-source-server
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
Claude Desktop Configuration
Add the following configuration to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"source-code-server": {
"command": "node",
"args": ["/path/to/your/mcp-source-server/dist/index.js"],
"env": {
"MCP_WORKSPACE_DIR": "/path/to/your/workspace"
}
}
}
}
Replace /path/to/your/mcp-source-server
with the actual path to this project, and /path/to/your/workspace
with your desired workspace directory.
๐ Available Tools
Basic Operations
read_source_file
- Read file contentwrite_source_file
- Write content to filelist_source_files
- List files in directorystream_write_source_file
- Stream write for large files
๐ Enhanced Operations
delete_source_file
- Delete file with backup optionrename_source_file
- Rename or move file with backuppartial_write_source_file
- Update specific file content (LLM optimized)
Utility
get_server_stats
- Get server status and statistics
๐ง Configuration
Environment Variables
MCP_WORKSPACE_DIR
: Set the workspace directory (default:./workspace
)
Security Configuration
The server includes built-in security configurations:
Allowed File Extensions
- Programming:
.js
,.ts
,.jsx
,.tsx
,.py
,.cpp
,.c
,.h
, etc. - Web:
.html
,.css
,.scss
,.json
,.xml
,.yaml
, etc. - Documentation:
.md
,.txt
,.rst
,.adoc
- Templates:
.template
,.example
,.sample
,.config
- No extension:
Dockerfile
,Makefile
,.gitignore
, etc.
Blacklisted Paths
..
- Directory traversal prevention.git/
- Git repository filesnode_modules/
- Dependencies directory.env.
- Environment files (except templates)secrets/
- Secrets directory- System files (
.DS_Store
,Thumbs.db
)
๐ก Usage Examples
Basic File Operations
// Read a file
await callTool('read_source_file', { filePath: 'src/index.js' });
// Write a file
await callTool('write_source_file', {
filePath: 'src/new-file.js',
content: 'console.log("Hello World");',
createBackup: true
});
// List files
await callTool('list_source_files', { dirPath: 'src' });
๐ Enhanced Operations
// Delete a file (with backup)
await callTool('delete_source_file', {
filePath: 'old-file.js',
createBackup: true
});
// Rename/move a file
await callTool('rename_source_file', {
oldPath: 'old-name.js',
newPath: 'src/new-name.js',
createBackup: true
});
// LLM-optimized partial update
await callTool('partial_write_source_file', {
filePath: 'utils.js',
oldContent: 'function oldFunction() { return "old"; }',
newContent: 'function newFunction() { return "updated"; }'
});
๐ก๏ธ Security Notes
Allowed Development Files
โ
.gitignore
, .env.template
, Dockerfile
, Makefile
, package.json
, tsconfig.json
Protected Files
๐ .env
, .env.local
, .env.production
, .git/config
, node_modules/
, secrets/
๐งช Testing
# Run all tests
npm test
# Run specific test
npm test -- --testNamePattern="should allow development configuration files"
# Run with coverage
npm run test:coverage
๐ Backup System
The server automatically creates backups in the .backups
directory with timestamps:
- Format:
filename.timestamp.backup
- Location:
workspace/.backups/
- Automatic cleanup recommended
๐ Performance Features
- Concurrent Operation Limits: Prevents system overload
- File Size Limits: Default 10MB per file
- LLM Optimization: Partial write reduces file I/O for small changes
- Stream Processing: Efficient handling of large files
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
๐ License
[Your License Here]
๐ Changelog
v0.2.1
- โจ Added file deletion functionality
- โจ Added file rename/move functionality
- โจ Added LLM-optimized partial write functionality
- ๐ง Fixed .env.template file access
- ๐ง Enhanced security with precise pattern matching
- ๐งช Comprehensive test suite (21 tests)
v0.1.0
- ๐ Initial release with basic file operations
- ๐ Security features and path validation
- ๐ MCP protocol implementation