🥥 Coco - Context Coder MCP 标志

🥥 Coco - Context Coder MCP

社区
khromov

MCP for agentic full-context coding

发布者khromov
代码仓库context-coder
语言TypeScript
复刻数
1
星标数
17
可用工具
3
传输类型stdio, streamable-http
分类
链接
  • 将工具接入 AI 工作流

    🥥 Coco - Context Coder MCP 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 3 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 17 个 Star 和 1 个 Fork。

🥥 Context Coder MCP

Context Coder (aka. Coco) provides AI models with an MCP tools to load your entire codebase into the LLM context. This gives AI assistants everything they need to write code that fits your existing patterns and architecture.

📦 Available on npm

Demo

One-shot complex redesign with a vague prompt not mentioning any specific files.

https://github.com/user-attachments/assets/7eb4c39b-f069-47b5-b81a-d3d40c506f61

Quick Start

Context Coder supports three main ways of running it:

  1. Via Claude Desktop
  2. Via Claude Code
  3. Via other clients

Claude Desktop + npx

Start a terminal in your current project folder and run:

npx context-coder

For line-based partial editing instead of complete file rewrites, use:

npx context-coder --edit-file-mode

Then add this to the Claude Desktop config and restart Claude Desktop afterwards:

json
{
  "mcpServers": {
    "context-coder": {
      "command": "npx",
      "args": ["-y", "supergateway", "--streamableHttp", "http://localhost:3001/mcp"]
    }
  }
}

Next, create a Claude Project and insert the recommended starting prompt just below this section.

Claude Desktop + Docker

Running via Docker provides better isolation since the container won't be able to write things outside of your project directory.

Create a docker-compose.yml file in the project(s) you want to work on.

yaml
services:
  context-coder:
    image: ghcr.io/khromov/context-coder:full
    ports:
      - '3001:3001'
    volumes:
      - ./:/app
    working_dir: /app

For the edit variant (line-based partial edits):

yaml
services:
  context-coder:
    image: ghcr.io/khromov/context-coder:edit
    ports:
      - '3001:3001'
    volumes:
      - ./:/app
    working_dir: /app

Start the service:

bash
docker-compose up

Then add this to the Claude Desktop config and restart Claude Desktop afterwards:

json
{
  "mcpServers": {
    "context-coder": {
      "command": "npx",
      "args": ["-y", "supergateway", "--streamableHttp", "http://localhost:3001/mcp"]
    }
  }
}

Since docker-compose up already knows which folder it's running in, we can easily switch between projects by launching docker-compose up in different directories. Don't forget to switch between Claude Projects when you do this!

Next, create a Claude Project and insert the recommended starting prompt just below this section.

Claude Desktop starting prompt

Recommended setup and starting prompt: Create a Claude Project and add this to your project instructions:

Use the Context Coder MCP to edit files. Remember that partial edits are not allowed, always write out the edited files in full through the MCP. You MUST call the get_codebase_size and get_codebase MCP tools at the start of every new chat. Do not call read_file, as you already have the codebase via get_codebase - use this reference instead. ONLY call read_file if you can't find the file in your context. Do not create any artifacts unless the user asks for it, just call the write_file tool directly with the updated code. If you get cut off when writing code and the user asks you to continue, continue from the last successfully written file to not omit anything.

If you're using --edit-file-mode, use this prompt instead:

Use the Context Coder MCP to edit files. You have access to both edit_file (for line-based partial edits) and write_file (for complete file rewrites) tools. Use edit_file when making small, targeted changes and write_file when rewriting entire files or making extensive changes. Always use write_file if writing with edit_file fails. You MUST call the get_codebase_size and get_codebase MCP tools at the start of every new chat. Do not call read_file, as you already have the codebase via get_codebase - use this reference instead. ONLY call read_file if you can't find the file in your context. Do not create any artifacts unless the user asks for it, just call the MCP tools directly with the updated code. If you get cut off when writing code and the user asks you to continue, continue from the last successfully written file to not omit anything.

Claude Code

Option 1: npx

Create .mcp.json in your project root:

json
{
  "mcpServers": {
    "context-coder": {
      "command": "npx",
      "args": ["-y", "context-coder", "--mini", "--stdio"]
    }
  }
}

For line-based partial editing instead of complete file rewrites, use:

json
{
  "mcpServers": {
    "context-coder": {
      "command": "npx",
      "args": ["-y", "context-coder", "--mini", "--stdio", "--edit-file-mode"]
    }
  }
}

You're done!

Option 2: Docker

Running via Docker provides better isolation since the container won't be able to write things outside of your project directory.

Create .mcp.json in your project root:

json
{
  "mcpServers": {
    "context-coder": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-v",
        "./:/app",
        "-w",
        "/app",
        "-e",
        "COCO_MCP_TRANSPORT=stdio",
        "ghcr.io/khromov/context-coder:mini"
      ]
    }
  }
}

Option 3: Via HTTP + mcp-remote

For Claude Code, create .mcp.json in your project root:

json
{
  "mcpServers": {
    "context-coder": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "supergateway", "--streamableHttp", "http://localhost:3001/mcp"]
    }
  }
}

And create docker-compose.yml in your project:

yaml
services:
  context-coder:
    image: ghcr.io/khromov/context-coder:mini
    ports:
      - '3001:3001'
    volumes:
      - ./:/app
    working_dir: /app
    environment:
      - COCO_MCP_TRANSPORT=http
    restart: unless-stopped

Start Context Coder with docker-compose up and Claude Code will automatically connect.

The reason for using the mini build is that Claude Code already comes with file editing tools built-in.

Recommended starting prompt: Add this at the start of your CLAUDE.md file.

You have access to both Claude Code's built-in file tools and the Context Coder MCP for enhanced codebase analysis. Follow this workflow:

1. ALWAYS start every new chat by calling get_codebase_size and get_codebase MCP tools to ingest and understand the full project context
2. Use Context Coders's codebase analysis as your primary reference - avoid reading files since you already have the complete codebase, only read file if you are missing something or if the user specifically requests it.
3. Remember: Context Coder gives you full codebase context, Claude Code gives you precise editing control - use both strategically

Limiting which files are including when fetching the codebase

Context Coder works best in small and medium-sized repositories, as it's limited to the maximum context of your LLM (in the case of Claude Sonnet/Opus 4, that's 200,000 tokens). Your whole codebase might not fit, and for this case you have two options.

Excluding Files (.cocoignore)

Create a .cocoignore file in the root of your project. This file works similarly to .gitignore, allowing you to specify files and directories that should be excluded from the command to aggregate your code - this could be test fixtures, snapshots, large test files or other secondary information that isn't useful to the LLM.

Minifying Files (.cocominify)

Create a .cocominify file in the root of your project to include files with placeholder content instead of excluding them entirely. This saves tokens while still informing the AI that the files exist and allows the AI to read them with the read_file tool if necessary. This is useful for large generated files, compiled assets, or files that don't need their full content in the AI context.

Many common build artifacts and folders are already automatically excluded (such as node_modules). The LLM can also help you with this - ask it to run the get_codebase_top_largest_files tool and suggest files that are large and/or suitable for inclusion in a .cocoignore or .cocominify file.

Combining

You can have both a .cocoignore and a .cocominify file in the same repo.

Configuration

Volume Mounts

Mount a specific directory:

yaml
volumes:
  - ./src:/app # Only expose src directory

Environment Variables

  • COCO_DEV: "true" or "false" to mount the ./mount folder instead of using /app
  • COCO_MCP_TRANSPORT: Set to stdio or http (default: http)
  • COCO_PORT: Override default port 3001 (HTTP mode only)
  • CONTEXT_CODER_EDIT_MODE: Set to "true" to enable edit_file tool (equivalent to --edit-file-mode flag)

Available Tools

ToolPurpose
get_codebase_sizeCheck codebase size and token counts - LLMs should call this first to ensure codebase isn't too large
get_codebaseGenerate AI-digestible summary of entire codebase (paginated) - Call after checking size
get_codebase_top_largest_filesGet top X largest files in codebase - helpful for identifying files to add to .cocoignore/.cocominify
read_fileRead file contents (only use when specifically asked to re-read or for debugging)
write_fileCreate or overwrite files
edit_fileMake line-based partial edits to files (available when --edit-file-mode is enabled)
create_directoryCreate directories
list_directoryList directory contents (only use when specifically asked or for debugging)
directory_treeGet directory structure as JSON (only use when specifically asked or for debugging)
move_fileMove or rename files
search_filesSearch by pattern
execute_commandRun shell commands

Available Prompts

Context Coder provides MCP prompts that help configure Claude properly for your development workflow:

PromptPurpose
context-coder-claude-desktopDefault starting prompt for Claude Desktop - configures proper MCP tool usage
context-coder-claude-codeDefault starting prompt for Claude Code - explains how to use both tool sets together

To use these prompts in Claude Code:

  1. Type / to open the prompt menu
  2. Find "context-coder" in the list, then "Context Coder: Claude Code Setup"
  3. The prompt will be inserted automatically
  4. You may directly add a task after the prompt, eg /context-coder:Context Coder: Claude Code Setup (MCP) Add a new endpoint that returns a random number

To use these prompts in Claude Desktop:

Use the "plus" button just below the chat text box, the Add from <name of server>.

CLI Commands

Context Coder also provides a convenient CLI command to inspect your codebase:

List Files Command

bash
npx context-coder ls [options]

Lists all files that will be included in the codebase analysis, showing file sizes and respecting .cocoignore and .cocominify patterns.

Options:

  • --sort-by <type> - Sort by "size" or "path" (default: "size")
  • -r, --reverse - Reverse sort order (ascending instead of descending)
  • -d, --directory <dir> - Directory to analyze (default: current directory)
  • --help - Show usage information

Examples:

bash
npx context-coder ls                           # Default: sort by size descending
npx context-coder ls --sort-by path            # Sort alphabetically by path
npx context-coder ls -r                        # Sort by size ascending
npx context-coder ls --sort-by path --reverse  # Sort by path Z-A
npx context-coder ls -d ./src                  # Analyze specific directory

The command shows:

  • Total file count and token estimates for Claude and ChatGPT
  • Whether .cocoignore and .cocominify files are being used
  • Formatted list of all files with sizes

Runtime Options

Context Coder supports several runtime options to modify its behavior:

bash
npx context-coder [options]

Options:

  • -m, --mini - Run in mini mode (only core tools)
  • -f, --full - Run in full mode (all tools) - this is the default
  • -s, --stdio - Use stdio transport instead of HTTP
  • -e, --edit - Enable the edit_file tool for line-based partial edits instead of requiring complete file rewrites with write_file
  • --edit-file-mode - Same as -e, --edit (legacy flag)
  • -p, --port <number> - Port to listen on (default: 3001)
  • -c, --claude-token-limit <number> - Set Claude token limit - useful for models with larger context windows (default: 150000)
  • -g, --gpt-token-limit <number> - Set GPT token limit - useful for models with larger context windows (default: 128000)

Examples:

bash
npx context-coder                           # Default: full mode with HTTP transport
npx context-coder -m                        # Mini mode with core tools only
npx context-coder -s                        # Use stdio transport (for Claude Code)
npx context-coder -e                        # Enable partial file editing
npx context-coder -p 8080                   # Use port 8080 instead of 3001
npx context-coder -m -s                     # Combine options for mini mode with stdio
npx context-coder -s -e -p 8080             # stdio transport with edit mode enabled and custom port

Token Limit Examples:

Context Coder helps detect when your codebase might exceed your model's context window. You can adjust these limits based on the model you're using:

bash
# For Claude Enterprise with 500k context window
npx context-coder -c 500000

# For GPT-4 Turbo with 128k context
npx context-coder -g 128000

# For models with very large context windows
npx context-coder -c 1000000 -g 1000000

# Combine with other options
npx context-coder --edit-file-mode -c 300000 -p 8080

Model Context Window Reference:

  • Claude Sonnet 3.5: ~200k tokens
  • Claude Enterprise: ~500k tokens
  • GPT-4: ~128k tokens
  • GPT-4 Turbo: ~128k tokens
  • Custom/Local Models: Varies widely

Setting appropriate token limits helps Context Coder provide better warnings when your codebase might not fit in your model's context window.

Development

Clone and install dependencies:

bash
npm install

Build and run:

bash
npm run build
npm start  # HTTP mode
npm start -- --stdio  # stdio mode

Development mode with auto-reload:

bash
npm run dev

In development mode, file operations are sandboxed to the ./mount directory.

Docker Variants

Context Coder provides three Docker variants:

VariantImageDescription
Fullghcr.io/khromov/context-coder:fullFull mode with all tools using write_file (complete file rewrites)
Minighcr.io/khromov/context-coder:miniCore analysis tools only (get_codebase_size, get_codebase, get_codebase_top_largest_files)
Editghcr.io/khromov/context-coder:editFull mode with edit_file tool for line-based partial edits in addition to write_file

Docker Build

Build all versions:

bash
./build-all.sh

Or build individually:

bash
# Full version
docker build -t context-coder:latest .

# Mini version
docker build --build-arg COCO_BUILD_TYPE=mini -t context-coder:mini .

# Edit version
docker build --build-arg COCO_BUILD_TYPE=edit -t context-coder:edit .

Build a custom image:

dockerfile
FROM ghcr.io/khromov/context-coder:full
# Add customizations

Or build from source:

bash
docker build -t my-coco .

License

MIT

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "khromov-context-coder": {
      "command": "npx",
      "args": [
        "-y",
        "context-coder"
      ]
    }
  }
}

可用工具

  • get_codebase_size

    Check the codebase size and token counts before processing. Returns token counts for Claude and ChatGPT, warns if the codebase is too large, and shows the largest files. IMPORTANT: You should ALWAYS run this tool at the start of EVERY NEW CONVERSATION before any other operations. After running this tool, you should then call get_codebase to retrieve the actual code.

  • get_codebase

    Generate a a merged markdown file of the entire codebase.Results are paginated.If more content exists, a message will prompt to call again with the next page number. Leave the _pageSize variable empty UNLESS you are running under Claude Code, in that case set it to 30000 to work around the Claude Code limits.

  • get_codebase_top_largest_files

    Returns the top X largest files in the codebase. Use this tool when users want to see more large files beyond the initial 10 shown in get_codebase_size. Helpful for identifying which files to add to .cocoignore for large codebases.

将 🥥 Coco - Context Coder MCP MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 🥥 Coco - Context Coder MCP 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 您可以在自己的设备上本地运行 MCP,也可以通过 URL 连接远程 MCP 服务器。

方式 1:使用本地连接器

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 🥥 Coco - Context Coder MCP 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 🥥 Coco - Context Coder MCP MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "khromov-context-coder": {
      "command": "npx",
      "args": [
        "-y",
        "context-coder"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 🥥 Coco - Context Coder MCP MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 🥥 Coco - Context Coder MCP MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 🥥 Coco - Context Coder MCP 帮我完成这项任务吗?
🥥 Coco - Context Coder MCP
当然。我已阅读。
以下是我使用 🥥 Coco - Context Coder MCP 得到的结果。

方式 2:添加 MCP 服务器 URL

如果 🥥 Coco - Context Coder MCP 已托管在远程服务器上,或您的团队希望让多个用户共用一个连接器,请选择此方式。

1

打开 MCP 连接器

在 TypingMind 中,前往“插件”,打开“MCP 连接器”,然后选择“添加 URL”。

  1. 在您的浏览器中打开 TypingMind。
  2. 进入“插件”。
  3. 打开“MCP 连接器”。
  4. 点击“添加 URL”。
TypingMind 的“添加自定义 MCP 服务器 URL”表单
2

粘贴服务器 URL

在“服务器 URL”字段中输入 您的服务器 URL。根据服务器要求,添加连接名称、描述、图标、自定义 HTTP 请求头或 OAuth 客户端设置。

  1. 将 您的服务器 URL 粘贴到“服务器 URL”字段中。
  2. 为 🥥 Coco - Context Coder MCP 输入连接名称。
  3. 您可以添加描述和图标,以便更容易识别此连接。
  4. 如果服务器需要身份验证,请添加自定义 HTTP 请求头或 OAuth 客户端信息。
3

创建连接

点击“创建连接”,然后返回插件列表,确认新的 MCP 连接显示为“有效”。

  1. 点击“创建连接”。
  2. 返回 MCP 连接器列表。
  3. 确认 🥥 Coco - Context Coder MCP 连接显示为“有效”。
  4. 如果连接未立即出现,请刷新插件列表。
4

切换模型,无需重新连接

使用您偏好的模型开始聊天,在“插件”中启用 🥥 Coco - Context Coder MCP 工具,并根据需要随时切换到其他模型。该 MCP 连接在 TypingMind 工作区中仍然可用。

  1. 在 TypingMind 中开始新聊天。
  2. 选择您想使用的 AI 模型。
  3. 在“插件”中启用 🥥 Coco - Context Coder MCP 工具。
  4. 需要时,请让模型使用该工具。
  5. 切换到其他 AI 模型,继续使用同一个 MCP 连接。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 🥥 Coco - Context Coder MCP 帮我完成这项任务吗?
🥥 Coco - Context Coder MCP
当然。我已阅读。
以下是我使用 🥥 Coco - Context Coder MCP 得到的结果。

常见问题

🥥 Coco - Context Coder MCP MCP 服务器有什么用途?

🥥 Coco - Context Coder MCP 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 🥥 Coco - Context Coder MCP MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 🥥 Coco - Context Coder MCP,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 🥥 Coco - Context Coder MCP MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 🥥 Coco - Context Coder MCP 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 🥥 Coco - Context Coder MCP MCP 连接到 TypingMind?

您可以通过本地 MCP 连接器,或添加远程 MCP 服务器 URL,在 TypingMind 中连接 🥥 Coco - Context Coder MCP。当服务器需要访问您设备上的文件、应用或私有资源时,请使用本地连接器;当 MCP 服务器托管在远程时,请使用服务器 URL。

🥥 Coco - Context Coder MCP MCP 在 TypingMind 中提供哪些工具?

🥥 Coco - Context Coder MCP 提供 3 个 MCP 工具,您可以在 TypingMind 的插件页面启用这些工具,然后在聊天中使用,或将其分配给 AI 智能体。

使用 🥥 Coco - Context Coder MCP MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 🥥 Coco - Context Coder MCP 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

context-coder-claude-desktop

Default starting prompt for using Context Coder with Claude Desktop. This prompt configures Claude to use the Context Coder MCP tools properly and establishes the workflow.

context-coder-claude-code

Default starting prompt for using Context Coder with Claude Code. This prompt explains how to use both Claude Code's built-in tools and Context Coder together.

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇