Skip to content

Commit a4a792d

Browse files
committed
feat: Initial release of MCP-Filesystem with comprehensive test suite
This initial release delivers a complete filesystem server built on the Model Context Protocol (MCP) that enables secure file operations from AI agents: Core Features: - Secure filesystem access with path validation and allowed directory enforcement - Rich file operations including read, write, edit, move, and search - Advanced grep functionality with regex support and contextual results - Directory traversal with configurable depth and pattern matching - End-to-end API for AI agent integration Testing Infrastructure: - Comprehensive behavior-driven test suite with 75 passing tests - Unit, integration, and end-to-end test coverage (46% overall) - Real filesystem fixtures for realistic testing scenarios - Cross-platform compatibility for path handling - Resilient assertions focused on behavior, not implementation The codebase is structured with clean separation of concerns: - security.py: Path validation and safety checks - operations.py: Core file operations - grep.py: Text search capabilities - advanced.py: Enhanced filesystem operations - server.py: FastMCP API endpoints This implementation provides a secure and feature-rich filesystem interface for AI tools and agents to safely interact with local files.
1 parent a17591f commit a4a792d

25 files changed

+8008
-148
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ docker/.env
1616
.ruff_cache/*
1717
.aider*
1818
CLAUDE.md
19+
docs/**

CHANGELOG.md

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Added
11-
- Integration with uv for dependency management
12-
- Modern Python development tools:
13-
- ruff for linting and formatting
14-
- mypy for type checking
15-
- pytest with coverage reporting
16-
- GitHub Actions workflow for automated testing
17-
- Docker development environment improvements
11+
- Grep functionality exposed through MCP
12+
- Support for ripgrep with Python fallback
13+
- Comprehensive search with regex, context, and pattern exclusion
14+
- Enhanced context control with separate before/after line parameters (like grep's -A/-B options)
15+
- Results pagination with offset/limit parameters
16+
- Line-targeted file operations
17+
- `read_file_lines` with offset/limit paradigm for precise line access
18+
- `edit_file_at_line` with content verification and relative line number support
19+
- Integration between grep and targeted operations for efficient workflow
20+
- Documentation of type safety issues and guidance in CLAUDE.md
21+
- Comprehensive test suite following pragmatic test-driven development approach
22+
- Smoke tests for critical user paths (read, write, grep, edit)
23+
- Integration tests with real temporary filesystem
24+
- End-to-end tests verifying server API to filesystem flow
25+
- Test data factories for sample data generation
26+
- Clean fixtures with proper dependency isolation
27+
- Mocks at external boundaries for faster test execution
28+
- Verification of actual functionality with real files
1829

1930
### Changed
20-
- Switched from pip/venv to uv for environment management
21-
- Updated example code to pass mypy type checking
22-
- Modernized project structure and development workflow
23-
- Updated Python version to 3.12
24-
25-
### Removed
26-
- Legacy dependency management approach
27-
- Outdated Docker configuration elements
31+
- Improved Python compatibility (requires 3.10+)
32+
- Enhanced server file operations with more granular edit capability
33+
- Changed line-targeting API from 1-based to 0-based indexing with offset/limit paradigm
34+
- Added content verification to file editing operations
35+
- Added relative line numbers support for more flexible line editing
36+
- Enhanced grep functionality with better context control and pagination
37+
- Improved code safety with proper null checks for Context parameters
38+
- Enhanced type safety with proper use of Optional types
2839

2940
### Fixed
30-
- Type hints in example code to pass mypy checks
31-
- Docker environment management
32-
- Development workflow and quality checks
33-
34-
## [0.1.0] - 2024-04-14
35-
- Initial fork from eugeneyan/python-collab-template
36-
- Added Docker environment management
37-
- Setup package installation configuration
41+
- Integrated targeted operations and grep functionality into the main codebase
42+
- Connected all components in the server implementation
43+
- Fixed unsafe comparison between int and None
44+
- Improved anyio.to_thread.run_sync usage with functools.partial
45+
- Fixed context_before type mismatch in grep.py
46+
- Properly typed transport parameter with Literal
47+
- Fixed all type errors in server.py, operations.py, advanced.py, and grep.py
48+
- Added type annotations for result variables and function parameters
49+
- Fixed `Dict` type incompatibility issue in advanced.py
50+
- Added missing imports from typing module (Any, Mapping)
51+
- Fixed read_file_lines bug that caused it to read beyond the requested line range
52+
- Fixed edit_file_at_line to properly handle content verification and relative line numbers
53+
- Fixed grep pagination to properly slice result sets
54+
- Improved test reliability by focusing on behavior rather than implementation details
55+
- Fixed inconsistent test expectations to match actual API semantics
56+
57+
## [0.1.0] - 2025-03-02
58+
- Initial project setup
59+
- Basic file operations implementation
60+
- Security framework for file access
61+
- Server structure and MCP integration

PUBLISHING.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Publishing Guide
2+
3+
This document contains instructions for publishing the package to PyPI.
4+
5+
## Prerequisites
6+
7+
1. Create accounts on [PyPI](https://pypi.org/) and [TestPyPI](https://test.pypi.org/) (optional for testing)
8+
2. Install build tools:
9+
```bash
10+
uv pip install --upgrade build twine
11+
```
12+
13+
## Build the Package
14+
15+
1. Ensure the version number is updated in `pyproject.toml`
16+
2. Build the distribution packages:
17+
```bash
18+
python -m build
19+
```
20+
This will create both source and wheel distributions in the `dist/` directory.
21+
22+
## Test the Package (Optional)
23+
24+
1. Upload to TestPyPI:
25+
```bash
26+
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
27+
```
28+
2. Install and test from TestPyPI:
29+
```bash
30+
uv pip install --index-url https://test.pypi.org/simple/ --no-deps mcp-filesystem
31+
```
32+
33+
## Publish to PyPI
34+
35+
1. Upload to PyPI:
36+
```bash
37+
twine upload dist/*
38+
```
39+
40+
## Create GitHub Release
41+
42+
1. Create a git tag for the version:
43+
```bash
44+
git tag -a v0.2.0 -m "Version 0.2.0"
45+
git push origin v0.2.0
46+
```
47+
2. Create a new release on GitHub:
48+
- Go to the repository page on GitHub
49+
- Click on "Releases"
50+
- Click "Create a new release"
51+
- Select the tag you just created
52+
- Add release notes (use the relevant section from CHANGELOG.md)
53+
- Publish the release
54+
55+
## Verify Package Installation
56+
57+
After publishing, verify that the package can be installed:
58+
59+
```bash
60+
uv pip install mcp-filesystem
61+
```
62+
63+
## Troubleshooting
64+
65+
If you encounter issues when publishing:
66+
67+
1. **Upload errors**: Verify that the package name is not already in use on PyPI
68+
2. **Invalid credentials**: Check your PyPI credentials in `~/.pypirc`
69+
3. **Build errors**: Make sure `pyproject.toml` is correctly formatted

0 commit comments

Comments
 (0)