mcp-code
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-code list the files in the project root and read README.md"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-code
MCP server chạy trên máy của bạn, cho phép Claude đọc và tìm kiếm code trong một thư mục được chỉ định. Server chỉ có quyền đọc, không ghi file và không chạy lệnh.
Tính năng
Tool | Mô tả |
| Liệt kê file và thư mục |
| Đọc nội dung một file text |
| Tìm chuỗi trong code, trả về |
Các thư mục .git, node_modules, __pycache__, .venv bị bỏ qua. Các file .env, id_rsa, id_ed25519 bị chặn không cho đọc.
Related MCP server: claude-projects-mcp-server
Yêu cầu
Python 3.10 trở lên
Cài đặt
git clone https://github.com/itgiup/mcp-code.git
cd mcp-code
uv syncDự án dùng mcp bản 1.x (mcp[cli]<2). Bản 2.x đã đổi API (FastMCP thành MCPServer) nên chưa tương thích.
Chạy thử
MCP_CODE_ROOT=/path/to/your/project uv run mcp-codeServer dùng giao thức stdio nên sẽ đứng im chờ input, không in gì ra. Đó là bình thường, nhấn Ctrl+C để thoát. Nếu có traceback thì là lỗi cài đặt.
Muốn thử các tool qua giao diện web:
uv run mcp dev src/mcp_code/__init__.pyCấu hình Claude Desktop
Mở file cấu hình claude_desktop_config.json (trong Claude Desktop: Settings → Developer → Edit Config) và thêm:
{
"mcpServers": {
"mcp-code": {
"command": "/path/to/uv",
"args": [
"--directory",
"/path/to/mcp-code",
"run",
"mcp-code"
],
"env": {
"MCP_CODE_ROOT": "/path/to/your/project"
}
}
}
}Thay các đường dẫn cho đúng máy của bạn:
command: đường dẫn tuyệt đối tớiuv, lấy bằngwhich uv.--directory: thư mục chứa projectmcp-codenày. Bắt buộc, vì Claude Desktop không chạy lệnh trong thư mục project.MCP_CODE_ROOT: thư mục Claude được phép đọc. Nếu bỏ trống, server dùng thư mục làm việc hiện tại của tiến trình, thường không phải thứ bạn muốn.
Nếu file đã có sẵn nội dung khác, chỉ thêm khối mcpServers và nhớ dấu phẩy để JSON hợp lệ. Sau đó thoát hẳn Claude Desktop rồi mở lại.
Kiểm tra bằng cách mở chat mới và hỏi, ví dụ: "Liệt kê file trong thư mục gốc rồi đọc README.md".
Bảo mật
Server chỉ đọc được bên trong
MCP_CODE_ROOT. Mọi đường dẫn thoát ra ngoài (ví dụ../) đều bị từ chối.Hãy trỏ
MCP_CODE_ROOTvào một dự án cụ thể, không trỏ vào cả thư mục home.Nội dung các file Claude đọc sẽ được gửi tới Claude, nên đừng trỏ vào thư mục chứa bí mật.
Muốn chặn thêm file nhạy cảm, thêm tên file vào tập
BLOCKEDtrongsrc/mcp_code/__init__.py.
Xử lý lỗi
Hiện tượng | Cách xử lý |
| Sai đường dẫn |
| Đang dùng mcp 2.x. Chạy |
Server thoát ngay sau khi khởi động | Chạy tay |
Có tool nhưng không đọc được file | Kiểm tra |
Khi viết thêm code, không dùng print() ra stdout vì stdout dành cho giao thức MCP. Dùng print(..., file=sys.stderr) để debug.
Giấy phép
Available Tools
4 toolslist_dirC
Liệt kê file/thư mục.
Inputs: path. Returns: result
read_fileC
Đọc nội dung một file text.
Inputs: path (required), max_bytes. Returns: result
search_codeC
Tìm chuỗi trong code, trả về 'file:dòng: nội dung'.
Inputs: query (required), path, max_results. Returns: result
write_fileA
Tạo file text mới (tự tạo thư mục cha). Ghi đè file có sẵn chỉ khi overwrite=True.
Inputs: path (required), content (required), overwrite. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool maps to a distinct filesystem action: listing directories, reading a file, searching code, and writing a file. There is no plausible overlap between them, and the descriptions reinforce the boundaries (e.g. search_code returns file:line:content while read_file returns full contents).
All four names follow a clean verb_noun snake_case pattern (list_dir, read_file, search_code, write_file). The verb choice is consistent and predictable, and there is no mixing of conventions.
Four tools is on the lean side but every one earns its place for a code/filesystem agent. It is slightly under-scoped for the domain, since a typical code workflow also needs an edit/patch or delete operation, but nothing is redundant.
Read, list, search, and create/overwrite cover the core lifecycle for a text-file code server. Gaps exist for delete, rename/move, and surgical in-place edits (only full overwrite is available), but agents can work around these.
Related MCP Connectors
Safe folder access for ChatGPT and Claude: read, write and search files, risky tools opt-in.
Give Claude only the Google Drive files you choose. Every action logged.
Read and search folders on your own computer with explicit consent. Files are never uploaded.
Path-scoped team memories, rules and skills for Claude Code, Cursor, Codex and other MCP clients.
Related MCP Servers
- AlicenseAqualityBmaintenanceProvides Claude Desktop with direct access to your local file system for development tasks, enabling file operations (read, write, edit), directory browsing, command execution, and codebase search within a configured projects directory.6MIT
- AlicenseAqualityBmaintenanceEnables Claude Code to read, create, update, and delete Claude Cowork/claude.ai projects and their knowledge documents, including syncing local folders to projects, with safety features like backups and overwrite protection.17MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude Web to securely inspect, search, and modify local project files through a sandboxed MCP server with atomic writes, path traversal protection, and sensitive file blocking.MIT
- FlicenseAqualityDmaintenanceA read-only MCP server that lets Claude read and search source code from local project folders, with path containment security.4-