opencode中使用gitcode mcp server

获取mcp server

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

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

opencode 配置

opencode.json 中配置mcp server

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

1
2
3
4
5
6
7
8
9
10
11
12
{
"$schema": "https://opencode.ai/config.json",
"mcp":{
"gitcode": {
"type": "local",
"command": ["python", "-m", "gitcode_mcp"],
"environment": {
"GITCODE_TOKEN": "your_personal_access_token_here"
}
}
}
}

之后即可在 opencode 中使用