← 所有笔记

opencode中使用gitcode mcp server

从安装到接入,在 OpenCode 中使用 GitCode MCP Server,让 Agent 与代码仓库协作。

获取mcp server

官方项目地址为:https://gitcode.com/gitcode-ai/gitcode_mcp_server

git clone https://gitcode.com/gitcode-ai/gitcode_mcp_server.git
cd gitcode_mcp_server
touch .env
# .env 中输入 GitCode个人访问令牌
GITCODE_TOKEN=your_personal_access_token_here
# 可选:如果需要使用代理
HTTP_PROXY=http://localhost:8080
HTTPS_PROXY=https://localhost:8080
# 切换python 环境
conda activate xxx
# 从源码安装
pip install -e .

opencode 配置

在 opencode.json 中配置mcp server

GITCODE_TOKEN 替换为 gitcode 个人设置中的访问令牌

{
    "$schema": "https://opencode.ai/config.json",
    "mcp":{
        "gitcode": {
            "type": "local",
            "command": ["python", "-m", "gitcode_mcp"],
            "environment": {
                "GITCODE_TOKEN": "your_personal_access_token_here"
            }
        }
    }
}

之后即可在 opencode 中使用

✳

谢谢你读到这里。

更新于 2026-03-02

搜索笔记

搜索文章标题、标签和正文。

↑ ↓ 选择 · Enter 阅读Esc 关闭