DocsDeveloper Referenceoverview
DOCUMENTATION & SPECIFICATION / V0.1.0

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.

Core Philosophy: Keep Code Where It Belongs
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 codemcp

Upon starting, CodeMCP outputs connection details:

Terminal Output
┌─────────────────────────────────────────────────────────────┐
│  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.

The Request-Response Loop
  1. Client sends JSON-RPC tool call (e.g. read_file).
  2. CodeMCP verifies path sandboxing and protected path rules.
  3. If modification or command execution is requested, approval prompt is evaluated.
  4. 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.

Claude Desktop

Connect Anthropic's Claude Desktop app over local stdio to read and edit your projects.

View Claude guide
Cursor IDE

Equip Cursor's Agent with direct tools to browse, search, and edit your local repo.

View Cursor guide
VS Code / Cline

Configure Cline, Continue, or Roo Code in VS Code using standard MCP configuration.

View VS Code guide
Windsurf Cascade

Attach CodeMCP to Windsurf Cascade for deep local context alongside Codeium.

View Windsurf guide

05 / 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
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 MCPAdd New MCP Server:

  • Name: codemcp
  • Type: command
  • Command: npx -y codemcp

Or configure via project .cursor/mcp.json:

.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:

cline_mcp_settings.json
{
  "mcpServers": {
    "codemcp": {
      "command": "npx",
      "args": ["-y", "codemcp"],
      "disabled": false,
      "autoApprove": []
    }
  }
}

08 / CLIENT SETUP

Windsurf Cascade Setup

In Windsurf, open Cascade settings → External Tools (MCP):

~/.codeium/windsurf/mcp_config.json
{
  "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.

ToolActionSafety Level
list_filesList files & subdirectories matching patternsRead-Only
read_fileInspect contents of a specific fileRead-Only
search_codePerform regex / pattern search across repoRead-Only
write_fileCreate a new file or full overwriteApproval
edit_fileTargeted replacement of code blocksApproval
execute_commandRun tests, linters, or build scripts in shellApproval

10 / TOOLS REFERENCE

list_files

Inspects directory contents within the project tree. Automatically respects .gitignore and protected path configurations.

ParameterTypeRequiredDescription
pathstringOptionalRelative directory path to inspect. Defaults to root (".").
recursivebooleanOptionalWhether to crawl subdirectories recursively. Default: false.
ignorePatternsstring[]OptionalExtra 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.

ParameterTypeRequiredDescription
pathstringRequiredRelative file path within project root (e.g. "src/utils.ts").
startLinenumberOptional1-indexed starting line number for slice reading.
endLinenumberOptional1-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.

ParameterTypeRequiredDescription
querystringRequiredThe text pattern or search term to locate.
isRegexbooleanOptionalTreat query as regular expression. Default: false.
includeGlobstringOptionalFilter 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.

ParameterTypeRequiredDescription
pathstringRequiredTarget file path relative to project root.
contentstringRequiredExact content to write.
overwritebooleanOptionalAllow 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.

ParameterTypeRequiredDescription
pathstringRequiredTarget file path to modify.
targetContentstringRequiredExact contiguous block of existing code to replace.
replacementContentstringRequiredReplacement 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.

Security Guarantee: Never Silent Execution
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.
ParameterTypeRequiredDescription
commandstringRequiredShell command to run (e.g. "pnpm test" or "cargo check").
timeoutMsnumberOptionalMax 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.

codemcp.json
{
  "$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"
  }
}
FieldTypeDefaultDescription
projectPathstring"."Root path exposed to the MCP client. Relative or absolute.
permissionModestring"approval"One of: "read-only", "approval", or "automated".
protectedPathsstring[][".env*"]List of glob patterns hidden from tools. Reading or writing results in access denial.
allowedCommandsstring[][]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.

CONTEXT.md
# 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

Read Only

Absolute safety. The AI can read files and search code, but write tools and terminal commands are completely disabled.

approval (default)

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

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:

FlagTypeDefaultDescription
--project, -pstring"."Path to project directory to expose.
--mode, -mstring"approval"Permission mode: read-only | approval | automated.
--portnumber4173Port for HTTP / SSE transport.
--tunnelbooleanfalseSpin up an encrypted HTTPS tunnel for remote web clients.
--allow-execbooleanfalseEnable command execution tool (execute_command).
--config, -cstring"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:

Terminal
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

Q: Why is Claude Desktop showing "Could not connect to MCP server"?

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.

Q: How do I stop CodeMCP from exposing secret environment files?

CodeMCP automatically blocks .env* by default. You can add additional files or directories (like secrets/**) to the protectedPaths array in codemcp.json.

Q: What transport should I use: stdio or SSE?

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).