Skip to content

Commit a6749c6

Browse files
committed
feat: add AGENTS.md, demo GIF, Smithery config, and README refresh
- Add AGENTS.md with AI agent instructions for using commit-check-mcp tools - Add smithery.yaml for Smithery AI MCP directory listing - Add demo/demo.py (full) and demo/demo-compact.py (GIF-optimized) - Add demo/demo.tape and demo/demo.gif (vhs-generated terminal demo) - Rewrite README with AI-agent-first positioning, comparison to commitlint, Smithery badge, demo GIF, AGENTS.md reference, and development section Positioning: commit-check-mcp is the first MCP-native commit validation tool designed for AI coding agents, not human CI pipelines.
1 parent 880eadf commit a6749c6

7 files changed

Lines changed: 487 additions & 2 deletions

File tree

AGENTS.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# AGENTS.md — AI Coding Agent Instructions
2+
3+
> This file tells AI coding agents (Claude Code, Cursor, Copilot, etc.) how to use
4+
> `commit-check-mcp` effectively when validating commits in this repository.
5+
6+
## What commit-check-mcp does for you
7+
8+
`commit-check-mcp` is an MCP server that exposes structured commit validation tools. As
9+
an AI agent, you can call these tools to validate:
10+
11+
- **Commit messages** — Conventional Commits format, subject length, imperative mood, etc.
12+
- **Branch names** — Naming conventions (feature/, bugfix/, hotfix/, etc.)
13+
- **Author info** — Name and email format validation
14+
- **Push safety** — Force-push detection for pre-push hooks
15+
- **Repository state** — Combined validation of all the above in one call
16+
- **Validation rules** — Inspect the effective config (defaults + repo config + overrides)
17+
18+
## Installing in your MCP client
19+
20+
```json
21+
{
22+
"mcpServers": {
23+
"commit-check": {
24+
"command": "commit-check-mcp"
25+
}
26+
}
27+
}
28+
```
29+
30+
Or with `uvx` (no install needed):
31+
32+
```json
33+
{
34+
"mcpServers": {
35+
"commit-check": {
36+
"command": "uvx",
37+
"args": ["commit-check-mcp"]
38+
}
39+
}
40+
}
41+
```
42+
43+
## When to call each tool
44+
45+
### Before creating a commit → `validate_commit_message`
46+
47+
Always call this **before** writing a commit message. Pass the message you intend to use:
48+
49+
```
50+
Tool: validate_commit_message
51+
Args: { "message": "feat(api): add user authentication endpoint" }
52+
```
53+
54+
If it returns `"status": "fail"`, read the `checks[].suggest` field and fix the message
55+
before committing. Never commit a message that fails validation.
56+
57+
### Before creating a branch → `validate_branch_name`
58+
59+
When you need to create a new branch, validate the name first:
60+
61+
```
62+
Tool: validate_branch_name
63+
Args: { "branch": "feature/user-auth" }
64+
```
65+
66+
### After switching to a repo → `describe_validation_rules`
67+
68+
On first entering a repository, inspect what rules are enforced:
69+
70+
```
71+
Tool: describe_validation_rules
72+
Args: { "repo_path": "/path/to/repo" }
73+
```
74+
75+
This tells you which checks are active so you can comply from the start.
76+
77+
### Before pushing → `validate_push_safety`
78+
79+
If the repo has pre-push hooks configured, validate push safety:
80+
81+
```
82+
Tool: validate_push_safety
83+
Args: { "repo_path": "/path/to/repo" }
84+
```
85+
86+
### Full state check → `validate_repository_state`
87+
88+
For a comprehensive check of the current repo state:
89+
90+
```
91+
Tool: validate_repository_state
92+
Args: { "repo_path": "/path/to/repo" }
93+
```
94+
95+
## Understanding responses
96+
97+
All validation tools return this shape:
98+
99+
```json
100+
{
101+
"status": "pass|fail",
102+
"checks": [
103+
{
104+
"check": "message",
105+
"status": "pass|fail",
106+
"value": "the input that was checked",
107+
"error": "reason for failure (only on fail)",
108+
"suggest": "how to fix it (only on fail)"
109+
}
110+
]
111+
}
112+
```
113+
114+
### When a check fails
115+
116+
1. Read `error` to understand what went wrong
117+
2. Read `suggest` for the recommended fix
118+
3. Apply the fix and re-validate
119+
4. Only proceed when `status` is `"pass"`
120+
121+
### Config precedence
122+
123+
When both `repo_path` and `config` are provided:
124+
125+
1. commit-check built-in defaults
126+
2. `cchk.toml` / `commit-check.toml` from the repo
127+
3. Explicit `config_path` if given
128+
4. Inline `config` overrides (highest priority)
129+
130+
## Best practices for AI agents
131+
132+
1. **Validate early, validate often** — check commit messages before writing them, not after
133+
2. **Don't bypass failures** — if a check fails, fix it; never force-push or skip hooks
134+
3. **Use the suggest field** — it contains the exact fix needed
135+
4. **Check rules first** — call `describe_validation_rules` when entering a new repo
136+
5. **Prefer `validate_repository_state`** for a comprehensive check in one call

README.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,34 @@
55
[![Build](https://github.com/commit-check/commit-check-mcp/actions/workflows/main.yml/badge.svg)](https://github.com/commit-check/commit-check-mcp/actions/workflows/main.yml)
66
[![Coverage](https://codecov.io/gh/commit-check/commit-check-mcp/graph/badge.svg)](https://codecov.io/gh/commit-check/commit-check-mcp)
77
[![MCP server](https://img.shields.io/badge/MCP-server-0A7B83)](https://modelcontextprotocol.io/)
8+
[![Smithery](https://img.shields.io/badge/Smithery-MCP%20Server-8B5CF6)](https://smithery.ai)
89

9-
Model Context Protocol (MCP) server for [commit-check](https://github.com/commit-check/commit-check).
10+
> **AI agent-friendly commit validation via MCP.** Built for AI coding agents (Claude Code, Cursor, Copilot, etc.) — not just human CI pipelines.
1011
11-
`commit-check-mcp` exposes `commit-check` as local MCP tools so an MCP client can validate commit messages, branch names, author info, push safety, and repository state.
12+
![Demo](demo/demo.gif)
13+
14+
**commit-check-mcp** is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that exposes [commit-check](https://github.com/commit-check/commit-check) validations as structured tools. AI agents call these tools to validate commit messages, branch names, author info, push safety, and repository state — every tool returns pass/fail results with actionable suggestions.
15+
16+
### Why this vs commitlint?
17+
18+
| | commitlint | commit-check-mcp |
19+
|---|---|---|
20+
| **Target user** | Humans in CI pipelines | AI coding agents via MCP |
21+
| **Interface** | CLI + git hooks + config files | MCP tools (JSON in/out) |
22+
| **Output** | Terminal text, exit codes | Structured JSON with `.error` + `.suggest` fields |
23+
| **Agent awareness** | None | AGENTS.md instructions, tool descriptions optimized for LLM function calling |
24+
| **Integration** | husky + CI config | Drop-in MCP server config for any MCP client |
25+
| **Repository context** | Reads config from cwd | Explicit `repo_path` + `config_path` params — works across repos |
26+
27+
## For AI Agents
28+
29+
If you're an AI coding agent working in this repository, read **[AGENTS.md](AGENTS.md)** for instructions on how to use commit-check-mcp tools effectively.
30+
31+
Key conventions for agents:
32+
- Always validate commit messages **before** writing them
33+
- Read `.suggest` on failures — it contains the exact fix
34+
- Call `describe_validation_rules` when entering a new repo
35+
- Use `validate_repository_state` for comprehensive checks in one call
1236

1337
## Features
1438

@@ -92,6 +116,16 @@ Example using an absolute path:
92116

93117
For local development from this repository, that absolute path may point to something like `.venv/bin/commit-check-mcp`.
94118

119+
## Smithery / mcp.so
120+
121+
commit-check-mcp is available on [Smithery](https://smithery.ai), the MCP server registry:
122+
123+
```bash
124+
npx @smithery-ai/cli install commit-check-mcp
125+
```
126+
127+
Or add it to your MCP client directly using the [Smithery config](smithery.yaml).
128+
95129
## Run Manually
96130

97131
```bash
@@ -205,3 +239,27 @@ Config precedence is:
205239
2. repository config loaded from `repo_path`
206240
3. `config_path` when explicitly provided
207241
4. inline `config` overrides passed to the tool
242+
243+
## Development
244+
245+
### Running tests
246+
247+
```bash
248+
pip install -e .[dev]
249+
pytest -q --cov=src/commit_check_mcp
250+
```
251+
252+
### Regenerating the demo GIF
253+
254+
Requires [vhs](https://github.com/charmbracelet/vhs):
255+
256+
```bash
257+
brew install vhs
258+
vhs demo/demo.tape --output demo/demo.gif
259+
```
260+
261+
Edit `demo/demo-compact.py` to change the demo content.
262+
263+
## License
264+
265+
MIT — see [LICENSE](LICENSE).

demo/demo-compact.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env python3
2+
"""Compact terminal demo optimized for GIF recording."""
3+
4+
from __future__ import annotations
5+
6+
import sys
7+
from pathlib import Path
8+
9+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "src"))
10+
11+
from commit_check_mcp.server import (
12+
_validate_message,
13+
_validate_branch,
14+
_validate_author,
15+
_validate_push,
16+
_validate_all,
17+
server_health,
18+
)
19+
20+
GREEN = "\033[32m"
21+
RED = "\033[31m"
22+
YELLOW = "\033[33m"
23+
CYAN = "\033[36m"
24+
BOLD = "\033[1m"
25+
RESET = "\033[0m"
26+
DIM = "\033[2m"
27+
28+
29+
def heading(text: str) -> None:
30+
print(f"\n{BOLD}{CYAN}{text}{RESET}")
31+
32+
33+
def show(result: dict) -> None:
34+
s = f"{GREEN}PASS{RESET}" if result["status"] == "pass" else f"{RED}FAIL{RESET}"
35+
print(f" [{s}]", end="")
36+
for c in result["checks"]:
37+
mark = f"{GREEN}{RESET}" if c["status"] == "pass" else f"{RED}{RESET}"
38+
print(f" {mark}{c['check']}", end="")
39+
if c["status"] == "fail" and c.get("suggest"):
40+
print(f"\n {YELLOW}{c['suggest'][:80]}{RESET}", end="")
41+
print()
42+
43+
44+
# Header
45+
print(f"{BOLD}commit-check-mcp — AI Agent-Friendly Commit Validation{RESET}")
46+
print(f"{DIM}https://github.com/commit-check/commit-check-mcp{RESET}")
47+
48+
heading("Server Health")
49+
health = server_health()
50+
print(f" {health['server']} v{health['server_version']} | commit-check v{health['commit_check_version']}")
51+
52+
heading("1. Commit Message")
53+
show(_validate_message("feat(api): add user auth endpoint"))
54+
show(_validate_message("add user auth"))
55+
56+
heading("2. Branch Name")
57+
show(_validate_branch("feature/user-auth"))
58+
show(_validate_branch("my_branch"))
59+
60+
heading("3. Author Info")
61+
show(_validate_author("Xianpeng Shen", "xianpeng.shen@gmail.com"))
62+
show(_validate_author("", "bad-email"))
63+
64+
heading("4. Push Safety")
65+
show(_validate_push("refs/heads/main abc123 refs/heads/main def456"))
66+
67+
heading("5. Combined Context")
68+
show(_validate_all(
69+
message="chore(deps): bump requests",
70+
branch="chore/update-deps",
71+
author_name="Xianpeng Shen",
72+
author_email="xianpeng.shen@gmail.com",
73+
))
74+
75+
print(f"\n{BOLD}{GREEN}8 MCP tools for AI agents — install: pip install commit-check-mcp{RESET}")

demo/demo.gif

194 KB
Loading

0 commit comments

Comments
 (0)