ai-git
A deterministic MCP server that reimplements ai-git-fish workflows (aicommit, aibranch, aipr) with Leantime integration, enabling Claude Code and Codex to perform git operations and manage tickets without an internal LLM.
README
ai-git-mcp
An MCP server that reimplements the ai-git-fish
workflows — aicommit, aibranch, aipr — with Leantime integration, without fish shell and
without DeepSeek. Wire it up once and the same workflows work in Claude Code and Codex.
- Why no AI inside the server?
- Requirements
- Installation
- Configuration (env)
- Usage — slash commands
- Tools reference
- Troubleshooting
- Local development
Why no AI inside the server?
ai-git-fish calls DeepSeek to generate commit messages and PR text. But Claude Code and Codex
are already the AI. So this server contains no LLM: every tool is deterministic. The agent
reads the diff/ticket through a tool, writes the prose itself, and passes it into the next tool.
No paying for AI twice, no losing context, and the agent understands your code better than DeepSeek.
Agent (Claude/Codex) ──calls tools──> ai-git-mcp ──> git / gh CLI
│ │
└── writes commit/PR/slug └──> Leantime JSON-RPC (/api/jsonrpc)
Requirements
On the machine that runs the agent:
- Node.js ≥ 18 (
node -v) - git in
PATH(git --version) - GitHub CLI
gh, authenticated (gh auth login) — needed only foraipr - A Leantime instance + API key — needed only for the ticket tools
You do not need to clone this repo. npx fetches and builds it for you (see below).
Installation
1. Get your Leantime credentials
| Value | Where to find it |
|---|---|
LEANTIME_BASE_URL |
Your Leantime URL, e.g. https://leantime.example.com |
LEANTIME_API_KEY |
Leantime → your profile → API Keys → generate one |
LEANTIME_USER_ID |
Your numeric user id — see the tip below |
Finding your
LEANTIME_USER_IDthe easy way (replaces ai-git-fish's installer fzf picker): set justLEANTIME_BASE_URL+LEANTIME_API_KEYfirst, restart, then ask the agent to runleantime_list_users. It prints every user with theirid— copy yours into the env and restart. (Or: open your profile and read the id from the URL, e.g..../users/editUser/5→5.)
2. Add the server to your client
Pick your client. The npx -y github:BenBen2109/ai-git-mcp command downloads this repo, builds
it once, caches it, and runs it — no manual clone or build.
<details open> <summary><b>Claude Code</b></summary>
Option A — one command:
claude mcp add ai-git \
-e LEANTIME_BASE_URL=https://leantime.example.com \
-e LEANTIME_API_KEY=your-key \
-e LEANTIME_USER_ID=123 \
-- npx -y github:BenBen2109/ai-git-mcp
Option B — edit .mcp.json (project root) or ~/.claude.json (global):
{
"mcpServers": {
"ai-git": {
"command": "npx",
"args": ["-y", "github:BenBen2109/ai-git-mcp"],
"env": {
"LEANTIME_BASE_URL": "https://leantime.example.com",
"LEANTIME_API_KEY": "your-key",
"LEANTIME_USER_ID": "123"
}
}
}
}
</details>
<details open> <summary><b>Codex</b></summary>
Edit ~/.codex/config.toml:
[mcp_servers.ai-git]
command = "npx"
args = ["-y", "github:BenBen2109/ai-git-mcp"]
env = { LEANTIME_BASE_URL = "https://leantime.example.com", LEANTIME_API_KEY = "your-key", LEANTIME_USER_ID = "123" }
</details>
Pin a version by appending a tag/branch/commit:
github:BenBen2109/ai-git-mcp#v1.0.0. The first launch is slower (it builds once); later launches use the npx cache.
3. Restart and verify
Restart the client (or reload the MCP config). Then check the server is connected:
- Claude Code: run
/mcp—ai-gitshould show 14 tools and 4 prompts. - Codex: the
ai-gittools appear in the tool list at startup.
Configuration (env)
| Variable | Required | Meaning |
|---|---|---|
LEANTIME_BASE_URL |
ticket tools | e.g. https://leantime.example.com |
LEANTIME_API_KEY |
ticket tools | sent as the x-api-key header |
LEANTIME_USER_ID |
recommended | numeric id used to filter your tickets |
LEANTIME_PICK_LIMIT |
optional | max tickets listed (default 30) |
SLACK_WEBHOOK_URL |
Slack tools | Incoming Webhook URL; the channel is fixed on the Slack side |
PR_PREVIEW_URL_TEMPLATE |
optional | Deploy-preview URL with a {pr} placeholder, e.g. https://frontend-preview-{pr}--anymatemeproject.netlify.app. Adds a Preview line to the Slack PR message |
SLACK_USER_MAP |
optional | JSON map of name/login → Slack member ID, e.g. {"khanhld":"U012ABC"}, for @-mentions |
SLACK_PR_REVIEWERS |
optional | Who to @-mention on every PR — comma list of names (from the map), raw Slack ids, or here/channel |
The git-only tools (git_status, git_staged_diff, git_commit, git_log_for_pr,
git_create_branch, git_create_or_update_pr, git_undo_last_commit) work without any Leantime
config. See .env.example.
Usage — slash commands
Three workflows, exposed as MCP prompts. In Claude Code type the slash command; in Codex just say it in plain language (e.g. "run aicommit") — the agent calls the same tools either way.
/ai-git:aicommit [hint] — stage-aware commit
Reads your staged diff, writes a Conventional Commit message, shows it to you, then commits.
# stage what you want first
git add -p
# then, in the agent:
/ai-git:aicommit
/ai-git:aicommit drop the debug logging # optional hint to steer the message
→ git_staged_diff → (agent writes message) → git_commit
/ai-git:aibranch [type] — branch from a Leantime ticket
Lists your tickets, you pick one, it creates/switches to type/<id>-<slug> (slug auto-derived
from the ticket headline, Vietnamese diacritics handled).
/ai-git:aibranch # type defaults to "feat" → feat/1234-add-login
/ai-git:aibranch fix # → fix/1234-add-login
→ leantime_list_my_tickets → (you pick) → git_create_branch
If LEANTIME_USER_ID isn't set (or you want someone else's tickets), the agent calls
leantime_list_users first, you pick a person, and it lists that user's tickets via assignee_id
— the equivalent of ai-git-fish's fzf user picker.
/ai-git:aipr [hint] — open or update a GitHub PR
Pushes the branch and creates (or updates) its PR with an AI-written title and body. If the branch
is named type/<id>-<slug>, the Leantime ticket is auto-linked and embedded.
/ai-git:aipr
/ai-git:aipr focus on the migration # optional hint to steer the PR
→ git_status + git_log_for_pr → (agent writes title/body) → git_create_or_update_pr → slack_post_pr
After the PR is created/updated, it sends a formatted notification to the team Slack channel
(via SLACK_WEBHOOK_URL). If Slack isn't configured, that step is skipped with a note.
/ai-git:aireview <pr> [spec] — review a PR and post the review
Fetches the PR + diff, reviews it against the team checklist (Functionality, Security, Error Handling, Code Quality, Performance, Style), writes the review in English following a fixed format, and posts it as a PR comment. Optionally validates against a Redmine spec URL.
/ai-git:aireview https://github.com/org/repo/pull/42
/ai-git:aireview https://github.com/org/repo/pull/42 https://redmine.example.com/issues/1234
Prefer the full PR URL — it tells gh which repo the PR is in. A bare number (42) only
resolves when repo_path is the PR's repository.
→ git_pr_view → (agent reviews, + Redmine spec via the agent's redmine tools if given) → git_pr_comment
Boundaries: never approves or merges, never changes code without approval.
Tools reference
All tools return JSON. Each accepts an optional repo_path (defaults to the server's working
directory) unless noted.
Leantime
| Tool | Params | Returns |
|---|---|---|
leantime_list_users |
— | { count, users: [{ id, name, username, isConfigured }] } (setup helper to find your LEANTIME_USER_ID) |
leantime_list_my_tickets |
limit? (1–100), assignee_id? |
{ count, assigneeId, filtered, tickets: [{ id, headline, statusLabel, projectName, assignee, dueDate, url, description }] } (description is a ~200-char snippet, like the fzf preview; filtered:false means no LEANTIME_USER_ID and no assignee_id → all tickets) |
leantime_get_ticket |
id |
{ found, id, headline, description, statusLabel, dueDate, url, markdown } |
Git — read-only
| Tool | Params | Returns |
|---|---|---|
git_status |
repo_path? |
{ branch, ahead, behind, staged[], unstaged[], untracked[] } |
git_staged_diff |
repo_path?, max_bytes? |
{ diff, files: [{ path, status }], isEmpty, truncated } |
git_log_for_pr |
base?, repo_path? |
{ base, count, commits: [{ sha, subject, body }] } |
git_pr_view |
pr, max_bytes?, repo_path? |
{ number, title, body, state, author, baseRefName, headRefName, url, additions, deletions, changedFiles, files[], diff, diffTruncated } |
Git — write
| Tool | Params | Returns |
|---|---|---|
git_commit |
message, repo_path? |
{ sha, shortStat } |
git_create_branch |
ticket_id, type?, slug?, repo_path? |
{ branch, created } |
git_create_or_update_pr |
title, body, ticket_id?, base?, draft?, repo_path? |
{ url, number, action } |
git_pr_comment |
pr, body, repo_path? |
{ url } — posts a comment (e.g. a review); never approves/merges |
git_undo_last_commit |
repo_path? |
{ undoneSha, message } |
Slack
| Tool | Params | Returns |
|---|---|---|
slack_post_pr |
title, url, number?, author?, ticket_id?, mention? |
{ ok } — posts Author / PR / Preview / Ticket / Feat / Reviewers (@-mentions) to the webhook channel |
slack_send_message |
text, mention? |
{ ok } — plain Slack mrkdwn message, optional @-mentions |
@-mentions: Slack only pings by member id (<@U…>), not by display name. Set SLACK_USER_MAP
to map names → ids, then list reviewers in SLACK_PR_REVIEWERS (or pass mention per call).
here/channel work without any map.
Notes:
git_commitfails with an actionable message if nothing is staged.git_create_branchauto-derives the slug from the ticket headline whenslugis omitted.git_create_or_update_prpushesHEAD, detects an existing PR for the branch (edits it) or creates a new one, and appends the ticket markdown block whenticket_idis given.git_undo_last_commitis a soft reset — your changes stay staged, nothing is lost.
Troubleshooting
| Symptom | Fix |
|---|---|
Leantime is not configured |
Set LEANTIME_BASE_URL + LEANTIME_API_KEY in the server env. |
Not a git repository |
Run the agent from inside a git repo, or pass repo_path. |
Nothing staged to commit |
git add your changes first. |
gh ... failed on aipr |
Run gh auth login; ensure the repo has a GitHub remote. |
npx is slow on first run |
Expected — it builds once, then caches. Pin a tag to stabilise. |
| Slash commands missing in Codex | Codex prompt support varies; just say "run aicommit" instead. |
Local development
git clone https://github.com/BenBen2109/ai-git-mcp
cd ai-git-mcp
npm install
npm run build # → dist/index.js
npm test # vitest
npm run dev # tsx watch (live reload)
Local-path config (instead of npx):
{ "mcpServers": { "ai-git": {
"command": "node",
"args": ["/absolute/path/to/ai-git-mcp/dist/index.js"],
"env": { "LEANTIME_BASE_URL": "...", "LEANTIME_API_KEY": "...", "LEANTIME_USER_ID": "..." }
}}}
Credits
Leantime client and ticket formatting (HTML/entity decoding, status labels, PR markdown block)
are ported from ai-git-fish by DucTam2411.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。