- New: mcp_server.py — FastMCP stdio server exposing 7 tools: gitea_create_issue, gitea_create_pr, gitea_close_issue, gitea_list_issues, gitea_view_issue, gitea_mark_issue, gitea_mirror_refs - New: auth.py — shared authentication and API helpers (get_credentials, get_auth_header, api_request, repo_api_url) - Refactored: create_pr.py, create_issue.py, manage_labels.py to use shared auth module (eliminates credential duplication) - New: tests/test_mcp_server.py — 17 tests for all MCP tools - Updated: tests/test_credentials.py — now tests auth.py directly - Updated: tests/test_create_issue.py — adapted for refactored imports - New: requirements.txt — frozen venv deps (mcp[cli], pytest) - Updated: README.md — MCP server as primary interface - Config: added gitea-tools to mcp_config.json Closes #1. Resolves #2, #5. Relates to #7.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Gitea Tools
|
||||
|
||||
A collection of Python and Bash scripts to automate interactions with Gitea instances.
|
||||
A collection of Python scripts and an MCP server to automate interactions with Gitea instances.
|
||||
|
||||
## Supported Instances
|
||||
|
||||
@@ -18,7 +18,38 @@ Scripts extract credentials from the macOS keychain automatically — no tokens
|
||||
|
||||
Ensure you've logged in via Git over HTTPS at least once so the keychain caches your credentials.
|
||||
|
||||
## Available Scripts
|
||||
## MCP Server (Recommended)
|
||||
|
||||
The Gitea-Tools MCP server exposes all functionality as structured tool calls.
|
||||
Any MCP-compatible agent (Antigravity, Claude Code, etc.) can call these tools natively.
|
||||
|
||||
### Available Tools
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `gitea_create_issue` | Create an issue with title, body, remote |
|
||||
| `gitea_create_pr` | Open a pull request with title, head, base |
|
||||
| `gitea_close_issue` | Close an issue by number |
|
||||
| `gitea_list_issues` | List issues with state/label filters |
|
||||
| `gitea_view_issue` | Get full details of a single issue |
|
||||
| `gitea_mark_issue` | Claim/release an issue (start/done) |
|
||||
| `gitea_mirror_refs` | Mirror branches + tags between instances |
|
||||
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
cd /Users/jasonwalker/Development/Gitea-Tools
|
||||
source venv/bin/activate
|
||||
pip install "mcp[cli]"
|
||||
```
|
||||
|
||||
The server is configured in `mcp_config.json` and runs automatically when Antigravity starts.
|
||||
Restart Antigravity to load the server after first setup.
|
||||
|
||||
## CLI Scripts
|
||||
|
||||
The MCP tools can also be used as standalone CLI scripts:
|
||||
|
||||
| Script | Description |
|
||||
|---------------------|--------------------------------------------------------------------|
|
||||
@@ -59,31 +90,35 @@ Ensure you've logged in via Git over HTTPS at least once so the keychain caches
|
||||
|
||||
Use `--help` on any Python script or shell script for full usage details.
|
||||
|
||||
## Mirror Refs
|
||||
## Architecture
|
||||
|
||||
`mirror_refs.sh` keeps branches and tags in sync between dadeschools and prgs:
|
||||
|
||||
- **Additive only** — never deletes branches or tags
|
||||
- **Dry-run by default** — pass `--apply` to actually push
|
||||
- **Divergence protection** — shared branches that have diverged are skipped with a warning; pass `--force` to override
|
||||
- Uses a bare repo cache in `/tmp/gitea-mirror-Timesheet` for isolation
|
||||
- Won't auto-close or merge anything — just ref mirroring
|
||||
```
|
||||
auth.py ← shared auth & API helpers (get_credentials, api_request)
|
||||
mcp_server.py ← MCP server (FastMCP, stdio transport)
|
||||
create_issue.py ← CLI: create issues
|
||||
create_pr.py ← CLI: create PRs
|
||||
manage_labels.py ← CLI: label management
|
||||
close_issue.sh ← CLI: close issues
|
||||
mark_issue.sh ← CLI: claim/release issues
|
||||
mirror_refs.sh ← CLI: ref mirroring
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
Run the full test suite:
|
||||
|
||||
```bash
|
||||
# Run with the venv (includes MCP SDK)
|
||||
source venv/bin/activate
|
||||
python3 -m pytest tests/ -v
|
||||
```
|
||||
|
||||
| Test file | Covers |
|
||||
|--------------------------|---------------------------------------------------------|
|
||||
| `test_create_issue.py` | Arg parsing, remote resolution, payload, auth, errors |
|
||||
| `test_create_pr.py` | Arg parsing, remote resolution, payload, auth, errors |
|
||||
| `test_credentials.py` | `get_credentials()` parsing edge cases |
|
||||
| `test_manage_labels.py` | Label create/skip, dry run, mapping, constant validation|
|
||||
| `test_shell_scripts.py` | `close_issue.sh` + `mark_issue.sh` arg validation |
|
||||
| `test_mirror_refs.py` | Flags, safety defaults, local integration tests |
|
||||
| `test_mcp_server.py` | All 7 MCP tools: create, list, view, close, mark, PR, mirror |
|
||||
| `test_create_issue.py` | CLI arg parsing, remote resolution, payload, auth, errors |
|
||||
| `test_create_pr.py` | CLI arg parsing, remote resolution, payload, auth, errors |
|
||||
| `test_credentials.py` | `get_credentials()`, `get_auth_header()`, `repo_api_url()` |
|
||||
| `test_manage_labels.py` | Label create/skip, dry run, mapping, constant validation |
|
||||
| `test_shell_scripts.py` | `close_issue.sh` + `mark_issue.sh` arg validation |
|
||||
| `test_mirror_refs.py` | Flags, safety defaults, local integration tests |
|
||||
|
||||
All tests mock network and keychain access — no real API calls are made.
|
||||
|
||||
Reference in New Issue
Block a user