Skip to content

Commit e08e5cb

Browse files
committed
initialize file operations server with configuration and entry point
0 parents  commit e08e5cb

20 files changed

+9481
-0
lines changed

.gitignore

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Dependencies
2+
node_modules/
3+
.pnp/
4+
.pnp.js
5+
6+
# Build output
7+
build/
8+
dist/
9+
out/
10+
*.tsbuildinfo
11+
12+
# Environment variables
13+
.env
14+
.env.local
15+
.env.*.local
16+
17+
# IDE and editor files
18+
.idea/
19+
.vscode/
20+
*.swp
21+
*.swo
22+
*~
23+
24+
# Logs
25+
logs/
26+
*.log
27+
npm-debug.log*
28+
yarn-debug.log*
29+
yarn-error.log*
30+
31+
# Testing
32+
coverage/
33+
.nyc_output/
34+
35+
# Operating System
36+
.DS_Store
37+
Thumbs.db
38+
39+
# Temporary files
40+
*.tmp
41+
*.temp
42+
.cache/
43+
44+
# Debug files
45+
.debug/
46+
*.debug
47+
48+
# TypeScript source maps
49+
*.map
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional REPL history
58+
.node_repl_history
59+
60+
# Output of 'npm pack'
61+
*.tgz
62+
63+
# Yarn Integrity file
64+
.yarn-integrity
65+
66+
# dotenv environment variable files
67+
.env
68+
.env.test
69+
.env.production
70+
71+
# parcel-bundler cache (https://parceljs.org/)
72+
.cache
73+
.parcel-cache
74+
75+
# Next.js build output
76+
.next
77+
out
78+
79+
# Nuxt.js build / generate output
80+
.nuxt
81+
dist
82+
83+
# Gatsby files
84+
.cache/
85+
# Comment in the public line in if your project uses Gatsby and not Next.js
86+
# public
87+
88+
# vuepress build output
89+
.vuepress/dist
90+
91+
# Serverless directories
92+
.serverless/
93+
94+
# FuseBox cache
95+
.fusebox/
96+
97+
# DynamoDB Local files
98+
.dynamodb/
99+
100+
# TernJS port file
101+
.tern-port
102+
103+
# Stores VSCode versions used for testing VSCode extensions
104+
.vscode-test
105+
106+
# yarn v2
107+
.yarn/cache
108+
.yarn/unplugged
109+
.yarn/build-state.yml
110+
.yarn/install-state.gz
111+
.pnp.*
112+
113+
# Local backup files
114+
*.bak

.prettierrc

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 4,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"quoteProps": "as-needed",
8+
"jsxSingleQuote": false,
9+
"trailingComma": "es5",
10+
"bracketSpacing": true,
11+
"bracketSameLine": false,
12+
"arrowParens": "always",
13+
"endOfLine": "lf",
14+
"embeddedLanguageFormatting": "auto",
15+
"singleAttributePerLine": false,
16+
"proseWrap": "preserve",
17+
"htmlWhitespaceSensitivity": "css",
18+
"overrides": [
19+
{
20+
"files": [
21+
"*.ts",
22+
"*.tsx"
23+
],
24+
"options": {
25+
"parser": "typescript"
26+
}
27+
},
28+
{
29+
"files": [
30+
"*.json",
31+
"*.jsonc"
32+
],
33+
"options": {
34+
"parser": "json"
35+
}
36+
}
37+
]
38+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 File Operations MCP Server Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# File Operations MCP Server
2+
3+
A Model Context Protocol (MCP) server that provides enhanced file operation capabilities with streaming, patching, and change tracking support.
4+
5+
## Features
6+
7+
- **Basic File Operations**: Copy, read, write, move, and delete files
8+
- **Directory Operations**: Create, remove, and copy directories
9+
- **File Watching**: Monitor files and directories for changes
10+
- **Patch Operations**: Apply patches to files with various strategies
11+
- **Change Tracking**: Track and query file operation history
12+
- **Streaming Support**: Handle large files efficiently with streaming
13+
- **Robust Error Handling**: Comprehensive error handling and reporting
14+
- **Type Safety**: Full TypeScript support with strict type checking
15+
16+
## Installation
17+
18+
```bash
19+
npm install
20+
```
21+
22+
## Usage
23+
24+
### Starting the Server
25+
26+
```bash
27+
npm start
28+
```
29+
30+
For development with auto-reloading:
31+
32+
```bash
33+
npm run dev
34+
```
35+
36+
### Available Tools
37+
38+
#### Basic File Operations
39+
40+
- `copy_file`: Copy a file to a new location
41+
- `read_file`: Read content from a file
42+
- `write_file`: Write content to a file
43+
- `move_file`: Move/rename a file
44+
- `delete_file`: Delete a file
45+
- `append_file`: Append content to a file
46+
47+
#### Directory Operations
48+
49+
- `make_directory`: Create a directory
50+
- `remove_directory`: Remove a directory
51+
- `copy_directory`: Copy a directory recursively
52+
53+
#### Watch Operations
54+
55+
- `watch_directory`: Start watching a directory for changes
56+
- `unwatch_directory`: Stop watching a directory
57+
58+
#### Patch Operations
59+
60+
- `apply_patch`: Apply a patch to a file with various strategies:
61+
- Line-based patching
62+
- Block-based patching
63+
- Diff-based patching
64+
- Complete file replacement
65+
66+
#### Change Tracking
67+
68+
- `get_changes`: Get the list of recorded changes
69+
- `clear_changes`: Clear all recorded changes
70+
71+
### Example Usage
72+
73+
```typescript
74+
// Copy a file
75+
await fileOperations.copyFile({
76+
source: 'source.txt',
77+
destination: 'destination.txt',
78+
overwrite: false
79+
});
80+
81+
// Watch a directory
82+
await fileOperations.watchDirectory({
83+
path: './watched-dir',
84+
recursive: true
85+
});
86+
87+
// Apply a patch
88+
await fileOperations.applyPatch({
89+
operation: {
90+
type: 'line',
91+
filePath: 'file.txt',
92+
search: 'old line',
93+
replace: 'new line',
94+
createBackup: true,
95+
whitespaceConfig: {
96+
ignoreIndentation: true,
97+
ignoreLineEndings: true
98+
}
99+
}
100+
});
101+
```
102+
103+
## Development
104+
105+
### Building
106+
107+
```bash
108+
npm run build
109+
```
110+
111+
### Linting
112+
113+
```bash
114+
npm run lint
115+
```
116+
117+
### Formatting
118+
119+
```bash
120+
npm run format
121+
```
122+
123+
### Testing
124+
125+
```bash
126+
npm test
127+
```
128+
129+
## Configuration
130+
131+
The server can be configured through various settings:
132+
133+
- **Batch Processing**: Control chunk sizes and parallel processing
134+
- **Whitespace Handling**: Configure indentation and line ending handling
135+
- **Change Tracking**: Set retention periods and storage options
136+
- **Watch Settings**: Configure debounce times and recursive watching
137+
138+
## Error Handling
139+
140+
The server provides detailed error information through the `FileOperationError` class, including:
141+
142+
- Error codes for specific failure types
143+
- Detailed error messages
144+
- File paths involved in the error
145+
- Stack traces for debugging
146+
147+
## Contributing
148+
149+
1. Fork the repository
150+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
151+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
152+
4. Push to the branch (`git push origin feature/amazing-feature`)
153+
5. Open a Pull Request
154+
155+
## License
156+
157+
This project is licensed under the MIT License - see the LICENSE file for details.

0 commit comments

Comments
 (0)