Show HN: Codemcp – Claude Pro用户专享的Claude代码工具 – 告别API账单
Show HN: Codemcp – Claude Code for Claude Pro subscribers – ditch API bills

原始链接: https://github.com/ezyang/codemcp

将Claude Desktop变成强大的结对编程助手,借助codemcp。这个工具允许Claude直接编辑文件、运行测试以及在本地Git仓库中重构代码,类似于其他AI编码工具,但它是为Claude Pro量身定制的。 开始使用: 1. **安装:** 确保已安装`uv`和`git`。 2. **配置Claude Desktop:** 使用提供的示例将codemcp添加到你的`claude_desktop_config.json`文件中,并相应地调整`uvx`的路径。 3. **创建`codemcp.toml`:** 在你的项目Git仓库中,创建一个`codemcp.toml`文件来定义项目特定的设置和命令,例如格式化或运行测试。 4. **项目说明:** 在Claude Desktop中,创建一个项目并将`$PROJECT_DIR`(项目路径)添加到项目说明中。 5. **聊天与审查:** 与Claude互动以进行更改;codemcp会为每次互动提交更改。根据需要进行审查和改进。 codemcp通过提供有限的安全工具和强制使用Git版本控制来促进安全的自主式AI。采用增量开发;每次互动后审查更改以有效地指导Claude。使用项目提示和特定工具的说明配置`codemcp.toml`,以实现最佳协作。

Hacker News 上的一个帖子讨论了 PyTorch 开发者 ezyang 在休育儿假期间创建的工具 Codemcp。它允许 Claude Pro 用户模拟 Claude Code 的功能,而无需支付额外的 API 成本。Codemcp 利用 MCP(消息通道协议)与 Claude Pro 交互。用户 0xcb0 成功地在 Linux 上运行了结合 Codemcp 的 Claude Desktop,并创建了详细的项目路线图和前端代码,但 Git 功能失效且遇到使用限制,建议 Anthropic 提供更清晰的错误信息而不是无限循环。他们称赞了代码质量和逻辑一致性。ezyang 对 Claude Desktop 能够在 Linux 上运行感到惊讶,建议不要使用单独的文件系统/Git MCP,而是依赖 Codemcp 内置的等效功能,并建议检查 codemcp.log 文件以查找 Git 支持问题。对于持续会话,建议为 Claude 提供旧对话的摘要以恢复工作,模拟 Claude Code 的“/compact”功能。该工具旨在让用户在不产生额外 API 成本的情况下获得 Claude Code 的体验。

原文

Make Claude Desktop a pair programming assistant by installing codemcp. With it, you can directly ask Claude to implement features, fix bugs and do refactors on a codebase on your computer; Claude will directly edit files and run tests. Say goodbye to copying code in and out of Claude's chat window!

Screenshot of Claude Desktop with codemcp

codemcp offers similar functionality to other AI coding software (Claude Code, Cursor, Cline, Aider), but it occupies a unique point in the design space:

  1. It's intended to be used with Claude Pro, Anthropic's $20/mo subscription offering. Say goodbye to giant API bills. (Say hello to time-based rate limits.)

  2. It's built around safe agentic AI by providing a limited set of tools that helpful, honest and harmless LLMs are unlikely to misuse, and enforcing best practices like use of Git version control to ensure all code changes can be rolled back. As a result, you can safely unleash the AI and only evaluate at the end if you want to accept the changes or not.

  3. It's IDE agnostic: you ask Claude to make changes, it makes them, and then you can use your favorite IDE setup to review the changes and make further edits.

First, install uv and install git, if they are not installed already (on Windows, if you installed Git, I recommend rebooting).

Then, in claude_desktop_config.json:

{
  "mcpServers": {
    "codemcp": {
      "command": "/Users/<username>/.local/bin/uvx",
      "args": [
        "--from",
        "git+https://github.com/ezyang/codemcp@prod",
        "codemcp"
      ]
    }
  }
}

On Windows, double backslashes are necessary for the path:

C:\\Users\\<username>\\.local\\bin\\uvx.exe

If the MCP successfully loaded, a hammer icon will appear and when you click it "codemcp" will be visible.

Pro tip: If the server fails to load, go to Settings > Developer > codemcp > Logs to look at the MCP logs, they're very helpful for debugging.

Pro tip: if on Windows, the logs say "Git executable not found. Ensure that Git is installed and available", and you just installed Git, reboot your machine (the PATH update hasn't propagated.) If this still doesn't work, open System Properties > Environment Variables > System variables > Path and ensure there is an entry for Git.

Pro tip: if you like to live dangerously, you can change prod to main. If you want to pin to a specific release, replace it with 0.3.0 or similar.

Pro tip: it is supported to specify only uvx as the command, but uvx must be in your global PATH (not just added via a shell profile); on OS X, this is typically not the case if you used the self installer (unless you installed into a system location like /usr/local/bin).

First, you must create a codemcp.toml file in the Git repository checkout you want to work on. If you want the agent to be able to do things like run your formatter or run tests, add the commands to execute them in the commands section (note: these commands need to appropriately setup any virtual environment they need):

format = ["./run_format.sh"]
test = ["./run_test.sh"]

Next, in Claude Desktop, we recommend creating a Project and putting this in the Project Instructions:

Initialize codemcp with $PROJECT_DIR

Where $PROJECT_DIR is the path to the project you want to work on.

Then chat with Claude about what changes you want to make to the project. Every time codemcp makes a change to your code, it will generate a commit.

To see some sample transcripts using this tool, check out:

codemcp will generate a commit per chat and amend it as it is working on your feature.

  • When you get rate limited, take the time to do something else (review Claude's code, review someone else's code, make plans, do some meetings)

  • This is not an autonomous agent. At minimum, you have to intervene after every chat to review the changes and request the next change. While you can ask for a long list of things to be done in a single chat, you will likely hit Claude Desktop's output limit and have to manually "continue" the agent anyway. Embrace it, and use the interruptions to make sure Claude is doing the right thing.

  • When Claude goes off the rails, it costs you time rather than dollars. Behave accordingly: if time is the bottleneck, watch Claude's incremental output carefully.

Here are all the config options supported by codemcp.toml:

project_prompt = """
Before beginning work on this feature, write a short haiku.  Do this only once.
"""

[commands]
format = ["./run_format.sh"]
test = ["./run_test.sh"]

The project_prompt will be loaded when you initialize the project in chats.

The commands section allows you to configure commands for specific tools. The names are told to the LLM, who will decide when it wants to run them. You can add instructions how to use tools in the project_prompt; we also support a more verbose syntax where you can give specific instructions on a tool-by-tool basis:

[commands.test]
command = ["./run_test.sh"]
doc = "Accepts a pytest-style test selector as an argument to run a specific test."

To run the server with inspector, use:

PYTHONPATH=. mcp dev codemcp/__main__.py

Logs are written to ~/.codemcp/codemcp.log. The log level can be set in a global configuration file at ~/.codemcprc:

[logger]
verbosity = "INFO"  # Can be DEBUG, INFO, WARNING, ERROR, or CRITICAL

Logging is not configurable on a per project basis, but this shouldn't matter much because it's difficult to use Claude Desktop in parallel on multiple projects anyway.

See CONTRIBUTING.md.

联系我们 contact @ memedata.com