-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add AGENTS.md, demo GIF, Smithery config, and README refresh #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shenxianpeng
wants to merge
1
commit into
main
Choose a base branch
from
feature/mcp-ecosystem-readiness
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| # AGENTS.md — AI Coding Agent Instructions | ||
|
|
||
| > This file tells AI coding agents (Claude Code, Cursor, Copilot, etc.) how to use | ||
| > `commit-check-mcp` effectively when validating commits in this repository. | ||
|
|
||
| ## What commit-check-mcp does for you | ||
|
|
||
| `commit-check-mcp` is an MCP server that exposes structured commit validation tools. As | ||
| an AI agent, you can call these tools to validate: | ||
|
|
||
| - **Commit messages** — Conventional Commits format, subject length, imperative mood, etc. | ||
| - **Branch names** — Naming conventions (feature/, bugfix/, hotfix/, etc.) | ||
| - **Author info** — Name and email format validation | ||
| - **Push safety** — Force-push detection for pre-push hooks | ||
| - **Repository state** — Combined validation of all the above in one call | ||
| - **Validation rules** — Inspect the effective config (defaults + repo config + overrides) | ||
|
|
||
| ## Installing in your MCP client | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "commit-check": { | ||
| "command": "commit-check-mcp" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Or with `uvx` (no install needed): | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "commit-check": { | ||
| "command": "uvx", | ||
| "args": ["commit-check-mcp"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## When to call each tool | ||
|
|
||
| ### Before creating a commit → `validate_commit_message` | ||
|
|
||
| Always call this **before** writing a commit message. Pass the message you intend to use: | ||
|
|
||
| ``` | ||
| Tool: validate_commit_message | ||
| Args: { "message": "feat(api): add user authentication endpoint" } | ||
| ``` | ||
|
|
||
| If it returns `"status": "fail"`, read the `checks[].suggest` field and fix the message | ||
| before committing. Never commit a message that fails validation. | ||
|
|
||
| ### Before creating a branch → `validate_branch_name` | ||
|
|
||
| When you need to create a new branch, validate the name first: | ||
|
|
||
| ``` | ||
| Tool: validate_branch_name | ||
| Args: { "branch": "feature/user-auth" } | ||
| ``` | ||
|
|
||
| ### After switching to a repo → `describe_validation_rules` | ||
|
|
||
| On first entering a repository, inspect what rules are enforced: | ||
|
|
||
| ``` | ||
| Tool: describe_validation_rules | ||
| Args: { "repo_path": "/path/to/repo" } | ||
| ``` | ||
|
|
||
| This tells you which checks are active so you can comply from the start. | ||
|
|
||
| ### Before pushing → `validate_push_safety` | ||
|
|
||
| If the repo has pre-push hooks configured, validate push safety: | ||
|
|
||
| ``` | ||
| Tool: validate_push_safety | ||
| Args: { "repo_path": "/path/to/repo" } | ||
| ``` | ||
|
|
||
| ### Full state check → `validate_repository_state` | ||
|
|
||
| For a comprehensive check of the current repo state: | ||
|
|
||
| ``` | ||
| Tool: validate_repository_state | ||
| Args: { "repo_path": "/path/to/repo" } | ||
| ``` | ||
|
|
||
| ## Understanding responses | ||
|
|
||
| All validation tools return this shape: | ||
|
|
||
| ```json | ||
| { | ||
| "status": "pass|fail", | ||
| "checks": [ | ||
| { | ||
| "check": "message", | ||
| "status": "pass|fail", | ||
| "value": "the input that was checked", | ||
| "error": "reason for failure (only on fail)", | ||
| "suggest": "how to fix it (only on fail)" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### When a check fails | ||
|
|
||
| 1. Read `error` to understand what went wrong | ||
| 2. Read `suggest` for the recommended fix | ||
| 3. Apply the fix and re-validate | ||
| 4. Only proceed when `status` is `"pass"` | ||
|
|
||
| ### Config precedence | ||
|
|
||
| When both `repo_path` and `config` are provided: | ||
|
|
||
| 1. commit-check built-in defaults | ||
| 2. `cchk.toml` / `commit-check.toml` from the repo | ||
| 3. Explicit `config_path` if given | ||
| 4. Inline `config` overrides (highest priority) | ||
|
|
||
| ## Best practices for AI agents | ||
|
|
||
| 1. **Validate early, validate often** — check commit messages before writing them, not after | ||
| 2. **Don't bypass failures** — if a check fails, fix it; never force-push or skip hooks | ||
| 3. **Use the suggest field** — it contains the exact fix needed | ||
| 4. **Check rules first** — call `describe_validation_rules` when entering a new repo | ||
| 5. **Prefer `validate_repository_state`** for a comprehensive check in one call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| #!/usr/bin/env python3 | ||
| """Compact terminal demo optimized for GIF recording.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "src")) | ||
|
|
||
| from commit_check_mcp.server import ( | ||
| _validate_message, | ||
| _validate_branch, | ||
| _validate_author, | ||
| _validate_push, | ||
| _validate_all, | ||
| server_health, | ||
| ) | ||
|
|
||
| GREEN = "\033[32m" | ||
| RED = "\033[31m" | ||
| YELLOW = "\033[33m" | ||
| CYAN = "\033[36m" | ||
| BOLD = "\033[1m" | ||
| RESET = "\033[0m" | ||
| DIM = "\033[2m" | ||
|
|
||
|
|
||
| def heading(text: str) -> None: | ||
| print(f"\n{BOLD}{CYAN}{text}{RESET}") | ||
|
|
||
|
|
||
| def show(result: dict) -> None: | ||
| s = f"{GREEN}PASS{RESET}" if result["status"] == "pass" else f"{RED}FAIL{RESET}" | ||
| print(f" [{s}]", end="") | ||
| for c in result["checks"]: | ||
| mark = f"{GREEN}✓{RESET}" if c["status"] == "pass" else f"{RED}✗{RESET}" | ||
| print(f" {mark}{c['check']}", end="") | ||
| if c["status"] == "fail" and c.get("suggest"): | ||
| print(f"\n {YELLOW}→ {c['suggest'][:80]}{RESET}", end="") | ||
| print() | ||
|
|
||
|
|
||
| # Header | ||
| print(f"{BOLD}commit-check-mcp — AI Agent-Friendly Commit Validation{RESET}") | ||
| print(f"{DIM}https://github.com/commit-check/commit-check-mcp{RESET}") | ||
|
|
||
| heading("Server Health") | ||
| health = server_health() | ||
| print(f" {health['server']} v{health['server_version']} | commit-check v{health['commit_check_version']}") | ||
|
|
||
| heading("1. Commit Message") | ||
| show(_validate_message("feat(api): add user auth endpoint")) | ||
| show(_validate_message("add user auth")) | ||
|
|
||
| heading("2. Branch Name") | ||
| show(_validate_branch("feature/user-auth")) | ||
| show(_validate_branch("my_branch")) | ||
|
|
||
| heading("3. Author Info") | ||
| show(_validate_author("Xianpeng Shen", "xianpeng.shen@gmail.com")) | ||
| show(_validate_author("", "bad-email")) | ||
|
|
||
| heading("4. Push Safety") | ||
| show(_validate_push("refs/heads/main abc123 refs/heads/main def456")) | ||
|
|
||
| heading("5. Combined Context") | ||
| show(_validate_all( | ||
| message="chore(deps): bump requests", | ||
| branch="chore/update-deps", | ||
| author_name="Xianpeng Shen", | ||
| author_email="xianpeng.shen@gmail.com", | ||
| )) | ||
|
|
||
| print(f"\n{BOLD}{GREEN}8 MCP tools for AI agents — install: pip install commit-check-mcp{RESET}") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix heading level to maintain proper document structure.
The heading jumps from h1 to h3, skipping h2. For correct Markdown hierarchy and accessibility, this should be an h2 heading.
📝 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 16-16: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
🤖 Prompt for AI Agents