refactor: make gitea a self-contained Cline skill

Relocate the script into the skill (skills/gitea/scripts/gitea_mcp.py) and add a
PEP 723 dependency block, so `uv run scripts/gitea_mcp.py` provisions deps with no
install step and the skill folder is portable (drop into ~/.cline/skills/). Drop
the non-standard `metadata` frontmatter — Cline only recognizes name + description.

- .mcp.json points at the relocated script and runs with --no-project (PEP 723)
- SKILL.md uses relative scripts/ paths; metadata block removed
- find_config walks up the tree to locate config.json (skill root or plugin root)
- tests import gitea_mcp via pytest pythonpath; README/CLAUDE paths updated

Tests: 119 passed, 92% coverage. Standalone list-tools verified via uv --no-project.
This commit is contained in:
2026-06-24 14:35:28 +03:00
parent 9a5750ddca
commit db5a43b19a
21 changed files with 77 additions and 58 deletions
+19 -21
View File
@@ -8,8 +8,6 @@ description: >
"переключись на work gitea", "gitea", "list repos", "create issue",
"open PR", "merge pull request", "create release", "add webhook",
"list branches", "gitea notifications", "check gitea connection".
metadata:
version: "0.3.0"
---
# Gitea Platform Assistant
@@ -18,9 +16,9 @@ Full Gitea REST API — 66 tools for repos, issues, PRs, branches, files, releas
webhooks, organizations. One source file, two ways to call it (pick whichever your
runtime gives you):
- **CLI (this skill):** `uv run … server/gitea_mcp.py <tool> --param value`
- **CLI (this skill):** `uv run scripts/gitea_mcp.py <tool> --param value`
prints **one JSON object** on stdout. This is the default for Cline.
- **MCP server:** the same tools exposed as `mcp__gitea__<tool>` when the file is
- **MCP server:** the same tools exposed as `mcp__gitea__<tool>` when the script is
registered via `.mcp.json`. Use these instead of `execute_command` if the tools
are already available to you.
@@ -29,21 +27,21 @@ differs (CLI uses `--dashed-flags`, MCP uses named arguments).
## Calling via CLI
```
ROOT = <plugin folder> # the gitea-platform-mcp directory
SCRIPT = $ROOT/server/gitea_mcp.py
```
Run through `uv` (deps come from the project; no separate install):
The script is bundled inside this skill at `scripts/gitea_mcp.py` and carries its
own PEP 723 dependency block, so `uv` provisions everything on first run — no
install step. Run it from the skill directory:
```
uv run --project "$ROOT" "$SCRIPT" --config "$ROOT/config.json" <tool> [--flags]
uv run scripts/gitea_mcp.py <tool> [--flags]
```
Convert snake_case params to `--dashed` flags. Booleans use `--flag` / `--no-flag`
(e.g. `--private` / `--no-private`). List params take space-separated values
(e.g. `--topics ci backend`).
Config is auto-discovered (`config.json` in the skill folder or a parent). Pass
`--config <path>` to point elsewhere.
**Output contract:** exactly one JSON object on stdout. Always check `success`:
```json
@@ -56,7 +54,7 @@ The process exits 0 even on tool-level errors — read `success`, not the exit c
## Discovery
```
uv run --project "$ROOT" "$SCRIPT" list-tools
uv run scripts/gitea_mcp.py list-tools
```
Returns every tool with its description and parameter spec (name / type /
@@ -67,12 +65,12 @@ required). Use it when unsure of a flag instead of guessing.
Always start by checking the connection:
```
uv run … "$SCRIPT" list_instances → configured instances + default
uv run … "$SCRIPT" get_current_user → verifies auth works
uv run scripts/gitea_mcp.py list_instances → configured instances + default
uv run scripts/gitea_mcp.py get_current_user → verifies auth works
```
If these fail with a config error, tell the user to fill in `config.json` in the
plugin folder (copy `config.example.json`).
If these fail with a config error, tell the user to create `config.json` in the
skill folder (copy `config.example.json` from the plugin root).
## Instance Selection
@@ -158,18 +156,18 @@ Every tool takes an optional `--instance` (default `""` = use config default).
```
# Open an issue
uv run --project "$ROOT" "$SCRIPT" create_issue \
uv run scripts/gitea_mcp.py create_issue \
--owner andrey --repo infra --title "CI flaky on main" --body "Fails ~1/5 runs"
# Edit then commit a file (two steps — get sha first)
uv run … "$SCRIPT" get_file --owner andrey --repo infra --filepath README.md
uv run … "$SCRIPT" update_file --owner andrey --repo infra --filepath README.md \
uv run scripts/gitea_mcp.py get_file --owner andrey --repo infra --filepath README.md
uv run scripts/gitea_mcp.py update_file --owner andrey --repo infra --filepath README.md \
--content "new text" --message "docs: tweak" --sha <sha-from-get_file>
# Create and merge a PR on the work instance
uv run … "$SCRIPT" create_pull_request --owner team --repo svc \
uv run scripts/gitea_mcp.py create_pull_request --owner team --repo svc \
--title "Feature X" --head feature/x --base main --instance work
uv run … "$SCRIPT" merge_pull_request --owner team --repo svc --index 42 \
uv run scripts/gitea_mcp.py merge_pull_request --owner team --repo svc --index 42 \
--merge-style squash --delete-branch-after-merge --instance work
```