Content
# MCP-Code
MCP-Code is an API framework specifically designed for programming purposes, providing a secure interface for AI to perform file operations through API requests.
## Main Features
### File Operations
- **File Reading**: Retrieve the contents of a file
- **File Writing**: Create new files or overwrite existing files
- **Line Editing**: Edit specific lines or ranges
- **Line Insertion**: Insert new lines at specified positions
- **Line Deletion**: Delete specified lines or ranges
- **File Deletion**: Remove files
- **Directory Tree**: Tree view of project structure (exclusion patterns can be specified)
- **File Listing**: Retrieve a list of files in a specified directory (regular expression filtering is possible)
### Script Execution
- Only scripts defined in the configuration file can be executed
- Security is ensured by restricting shell access
### Security Features
- Global and project-specific exclusion file settings
- Prevention of directory traversal attacks through path normalization
- Access restrictions outside the project root
### Data Format Support
- Automatically parses various data formats such as JSON, YAML, XML, CSV, TOML, etc.
### Logging
- Outputs system logs and request logs (`~/.local/state/mcp-code/logs/mcp-{YYYY-MM-DD}.log`)
- Manages log files by date
- Automatically cleans up old log files (default 30 days)
## Configuration File
MCP-Code places the configuration file at `~/.config/mcp-code/config.yaml`.
```yaml
log_path: "/path/to/logs"
excluded_files:
- "**/*.pem"
- "**/*.key"
current_project: "project1"
projects:
project1:
src: "/path/to/project1/src"
scripts:
build: "npm run build"
test: "npm run test"
excluded_files:
- "**/.env"
- "logs/**/*.log"
```
## Log Path
Log files are saved at the following path:
- System logs and request logs: `~/.local/state/mcp-code/logs/mcp-{YYYY-MM-DD}.log`
- Log files are created by date, and files older than 30 days are automatically deleted.
## Usage
### Installation
Install here
### Command Line
```bash
# Build
npm run build
# Development mode (using inspector)
npx @modelcontextprotocol/inspector npx tsx src/server.ts
```
### Programmatic Use
MCP-Code is designed to interact with LLM (Large Language Model) using the Model Context Protocol (MCP) SDK. The following tools are available:
- directoryTree: Displays the project's files in a tree format
- fileList: Retrieves a list of files in a specified directory
- fileRead: Retrieves the contents of a specified file
- fileWrite: Writes to a specified file
- fileDelete: Deletes a specified file
- fileInsertLine: Appends to a specified line in a specified file
- fileEditLines: Edits specified lines in a specified file
- fileDeleteLines: Deletes specific lines in a specified file
- script_[name]: Executes scripts defined in the configuration file
## Technology Stack
- TypeScript
- Model Context Protocol SDK
- Node.js
## Security Considerations
- Protection of sensitive files through exclusion file settings
- Ensured safety through restrictions on script execution
- Vulnerability mitigation through path normalization
## Contribution
If you are interested in contributing to the project, please refer to [CONTRIBUTING.md](CONTRIBUTING.md).
## License
MCP-Code is provided under the Apache License 2.0. For more details, please refer to the [LICENSE](LICENSE) file.
### License Features
- Includes explicit patent rights grant provisions
- Provides clear rules regarding code modifications and contributions
- Suitable for use in corporate environments
### Major Dependency Libraries
- [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk): MIT License
- Other dependency libraries are also under MIT or ISC (MIT-compatible) licenses, and the Apache License 2.0 is compatible with these.
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.
rust-docs-mcp
An MCP server for accessing Rust crate documentation and insights.
facebook-mcp-server
Automate Facebook Page management with MCP server using Graph API.
mcp-hono-stateless
Stateless Hono MCP Server example deployable on Cloudflare Workers.