CodeMCP Documentation
A comprehensive, battle-tested guide to connecting any MCP-compatible AI assistant directly to the codebase on your local machine with zero overhead and strict permission controls.
01 / GETTING STARTED
Overview
CodeMCP is a lightweight, local Model Context Protocol (MCP) server designed specifically for developer workspaces. Rather than uploading your entire source code to a cloud service or relying on opaque embeddings, CodeMCP turns your current directory into an intelligent, sandboxed environment that your assistant can explore on demand.
Your proprietary source code stays on your filesystem. AI assistants only read or edit files when explicitly permitted, and destructive operations can require real-time human authorization.
When an AI client (such as Claude Desktop, Cursor, or Cline) is paired with CodeMCP, it interacts through a standardized set of tools: searching symbols, inspecting project trees, reading source files, performing surgical edits, and running tests or build commands.
02 / GETTING STARTED
Quickstart
Launch CodeMCP directly inside any Git repository or project folder using your preferred package runner. No global install is required.
cd path/to/your-project
npx codemcpUpon starting, CodeMCP outputs connection details:
┌─────────────────────────────────────────────────────────────┐
│ CodeMCP Server v1.1.4 │
│ Project Root : C:\Users\azure\Documents\projects\CodeMCP │
│ Transport : stdio / SSE (http://localhost:4173/mcp) │
│ Permissions : approval (Ask before write/execute) │
│ Context File : CONTEXT.md (loaded) │
└─────────────────────────────────────────────────────────────┘
[mcp] Ready for AI client connections...03 / GETTING STARTED
Architecture & Protocol Flow
CodeMCP implements the open standard MCP specification using two interchangeable transports: stdio for local desktop agents and Server-Sent Events (SSE) over HTTP for remote or web-based clients.
- Client sends JSON-RPC tool call (e.g.
read_file). - CodeMCP verifies path sandboxing and protected path rules.
- If modification or command execution is requested, approval prompt is evaluated.
- Result or structured error returned to the AI assistant.
04 / CLIENT SETUP
Client Setup & Integrations
Connect your favorite AI assistant to CodeMCP. Most modern IDEs and clients support the Model Context Protocol natively.
Connect Anthropic's Claude Desktop app over local stdio to read and edit your projects.
View Claude guideEquip Cursor's Agent with direct tools to browse, search, and edit your local repo.
View Cursor guideConfigure Cline, Continue, or Roo Code in VS Code using standard MCP configuration.
View VS Code guideAttach CodeMCP to Windsurf Cascade for deep local context alongside Codeium.
View Windsurf guide05 / CLIENT SETUP
Claude Desktop Setup
Add CodeMCP to your claude_desktop_config.json:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"codemcp": {
"command": "npx",
"args": ["-y", "codemcp", "--project", "/absolute/path/to/project"]
}
}
}06 / CLIENT SETUP
Cursor IDE Setup
Open Cursor Settings → Features → MCP → Add New MCP Server:
- Name:
codemcp - Type:
command - Command:
npx -y codemcp
Or configure via project .cursor/mcp.json:
{
"mcpServers": {
"codemcp": {
"command": "npx",
"args": ["-y", "codemcp"]
}
}
}07 / CLIENT SETUP
VS Code & Cline Setup
In VS Code with the Cline or Continue extension installed, edit the MCP settings file:
{
"mcpServers": {
"codemcp": {
"command": "npx",
"args": ["-y", "codemcp"],
"disabled": false,
"autoApprove": []
}
}
}08 / CLIENT SETUP
Windsurf Cascade Setup
In Windsurf, open Cascade settings → External Tools (MCP):
{
"mcpServers": {
"codemcp": {
"command": "npx",
"args": ["-y", "codemcp"]
}
}
}09 / TOOLS REFERENCE
Tools Reference Overview
CodeMCP exposes 6 standard tools designed for granular, safe interactions. All filesystem actions are strictly confined within the configured projectPath.
| Tool | Action | Safety Level |
|---|---|---|
list_files | List files & subdirectories matching patterns | Read-Only |
read_file | Inspect contents of a specific file | Read-Only |
search_code | Perform regex / pattern search across repo | Read-Only |
write_file | Create a new file or full overwrite | Approval |
edit_file | Targeted replacement of code blocks | Approval |
execute_command | Run tests, linters, or build scripts in shell | Approval |
10 / TOOLS REFERENCE
list_files
Inspects directory contents within the project tree. Automatically respects .gitignore and protected path configurations.
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Optional | Relative directory path to inspect. Defaults to root ("."). |
recursive | boolean | Optional | Whether to crawl subdirectories recursively. Default: false. |
ignorePatterns | string[] | Optional | Extra glob patterns to filter out (e.g. ["dist/**", "*.log"]). |
11 / TOOLS REFERENCE
read_file
Reads textual content from an allowed file. Rejects paths that resolve outside the project root or match protectedPaths.
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Required | Relative file path within project root (e.g. "src/utils.ts"). |
startLine | number | Optional | 1-indexed starting line number for slice reading. |
endLine | number | Optional | 1-indexed ending line number (inclusive). |
12 / TOOLS REFERENCE
search_code
High-speed ripgrep-powered code search over the project. Enables your assistant to find symbol definitions, references, or strings in milliseconds.
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Required | The text pattern or search term to locate. |
isRegex | boolean | Optional | Treat query as regular expression. Default: false. |
includeGlob | string | Optional | Filter search to matching files (e.g. "*.tsx"). |
13 / TOOLS REFERENCE
write_file
Creates a new file or replaces existing contents. In approval mode, CodeMCP displays a diff prompt to the developer before committing changes.
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Required | Target file path relative to project root. |
content | string | Required | Exact content to write. |
overwrite | boolean | Optional | Allow replacing existing file. Default: true. |
14 / TOOLS REFERENCE
edit_file
Performs surgical find-and-replace edits on targeted code blocks. Minimizes hallucinations and preserves surrounding context.
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Required | Target file path to modify. |
targetContent | string | Required | Exact contiguous block of existing code to replace. |
replacementContent | string | Required | Replacement code to drop in. |
15 / TOOLS REFERENCE
execute_command
Executes a shell command inside the project directory. Requires explicit enabling via codemcp.json or the --allow-exec CLI flag.
By default, commands are blocked unless whitelisted or approved by the developer. Dangerous patterns (such as
rm -rf / or accessing credentials outside the tree) are denied automatically.| Parameter | Type | Required | Description |
|---|---|---|---|
command | string | Required | Shell command to run (e.g. "pnpm test" or "cargo check"). |
timeoutMs | number | Optional | Max execution time in milliseconds before cancellation. Default: 30000. |
16 / CONFIGURATION
codemcp.json Specification
Optional configuration file placed in the project root to define boundaries, permissions, and protected files.
{
"$schema": "https://codemcp.dev/schema.json",
"projectPath": ".",
"permissionMode": "approval",
"protectedPaths": [
".env*",
"**/*.pem",
"**/*.key",
"secrets/**"
],
"allowedCommands": [
"pnpm test",
"npm run lint",
"git status",
"git diff"
],
"tunnel": {
"enabled": false,
"provider": "cloudflare"
}
}| Field | Type | Default | Description |
|---|---|---|---|
projectPath | string | "." | Root path exposed to the MCP client. Relative or absolute. |
permissionMode | string | "approval" | One of: "read-only", "approval", or "automated". |
protectedPaths | string[] | [".env*"] | List of glob patterns hidden from tools. Reading or writing results in access denial. |
allowedCommands | string[] | [] | Whitelist of commands permitted to execute without prompt in automated mode. |
17 / CONFIGURATION
CONTEXT.md Guide
A CONTEXT.md file in your project root acts as the AI assistant's onboarding brief. CodeMCP automatically injects this context when the client initializes, preventing repeated prompting and aligning code generation with your architectural style.
# Project Context & Engineering Standards
## Technology Stack
- Next.js 15 (App Router), React 19, TypeScript
- Styling: Tailwind CSS v4 + Lucide Icons
## Architecture Rules
1. All client components must be marked with "use client" at top.
2. Use server actions for data mutations; never expose internal API tokens.
3. Every new component should include accessible ARIA labels.
## Testing & Verification
- Run `pnpm test` before submitting any proposed diff.
- Keep dependencies lean; avoid adding ad-hoc npm packages.18 / CONFIGURATION
Permission Modes
CodeMCP supports three distinct operational modes to match your confidence and workflow:
Read Only
Absolute safety. The AI can read files and search code, but write tools and terminal commands are completely disabled.
Interactive Approval
Ideal balance. The assistant can propose file edits and commands, but nothing touches your disk until you approve the diff in your terminal.
Automated Execution
Autonomous speed. File edits apply directly; commands in allowedCommands run immediately within the project sandbox.
19 / CLI REFERENCE
CLI Flags & Options
Customize runtime behavior when launching codemcp:
| Flag | Type | Default | Description |
|---|---|---|---|
--project, -p | string | "." | Path to project directory to expose. |
--mode, -m | string | "approval" | Permission mode: read-only | approval | automated. |
--port | number | 4173 | Port for HTTP / SSE transport. |
--tunnel | boolean | false | Spin up an encrypted HTTPS tunnel for remote web clients. |
--allow-exec | boolean | false | Enable command execution tool (execute_command). |
--config, -c | string | "codemcp.json" | Path to custom configuration file. |
20 / CLI REFERENCE
Connecting Remote Web Clients
Want to use a cloud assistant (such as Claude.ai or ChatGPT) with your local project? Launch CodeMCP with the --tunnel flag:
npx codemcp --tunnel
[tunnel] Establishing secure HTTPS bridge...
[tunnel] Public URL: https://codemcp-tunnel-74x9.trycloudflare.com/mcp
[tunnel] Auth token: cdmcp_sec_9941a87b320...
[mcp] Ready for remote client connections.The tunnel connects via end-to-end TLS directly to your machine. No code is stored on intermediary proxies.
21 / TROUBLESHOOTING
FAQ & Troubleshooting
Ensure the path in claude_desktop_config.json is absolute (e.g. C:\\Users\\... on Windows or /Users/... on macOS). Also verify that Node.js 18+ is installed in your system PATH.
CodeMCP automatically blocks .env* by default. You can add additional files or directories (like secrets/**) to the protectedPaths array in codemcp.json.
For desktop applications running on the same machine (Claude Desktop, Cursor, VS Code), use stdio. For web clients or multi-machine development, use HTTP/SSE (http://localhost:4173/mcp).