Add fetch MCP server with proxy routing, challenge solving and failure reports
Live reads go through an operator proxy pool (round-robin over the newest 100 entries, cooling on connect failures, no direct fallback); stored clearances are replayed only on the exit that earned them. Identity, clearance, solver and Turnstile rungs escalate automatically. fetch_pages reads up to 12 URLs four at a time with per-item isolation. report/reports/reports_update keep a durable queue of unreadable pages for the operator. Ships a pinned multi-stage image (non-root 10001, data in /data), an ordered CI with static gates, tests on 3.12 and 3.13 at 85% coverage, an offline image smoke, and sha/latest publishing gated on main.
This commit is contained in:
commit
5d36fddd30
35 files changed
+7616
No files matched your search
@@ -0,0 +1,160 @@
|
||||
# Public repository, self-hosted runner: trusted pushes only, so a fork cannot
|
||||
# execute on the runner. Stages are sequential; nothing publishes unless every
|
||||
# earlier stage is green.
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
env:
|
||||
PYTHONUNBUFFERED: "1"
|
||||
UV_LINK_MODE: copy
|
||||
UV_PYTHON_DOWNLOADS: never
|
||||
IMAGE: git.eeee.host/omar/fetch-mcp
|
||||
|
||||
jobs:
|
||||
static:
|
||||
name: static
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install tooling from the lock file
|
||||
run: uv sync --locked --all-groups
|
||||
- name: ASCII only
|
||||
run: uv run --locked python scripts/check_ascii.py
|
||||
- name: Lint and format
|
||||
run: |
|
||||
uv run --locked ruff check .
|
||||
uv run --locked ruff format --check .
|
||||
- name: Byte-compile everything
|
||||
run: uv run --locked python -m compileall -q $(git ls-files '*.py')
|
||||
|
||||
test:
|
||||
name: test-${{ matrix.python }}
|
||||
needs: static
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python: ["3.12", "3.13"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Select interpreter
|
||||
run: |
|
||||
uv python install ${{ matrix.python }}
|
||||
uv venv --python ${{ matrix.python }}
|
||||
- name: Install from the lock file
|
||||
run: uv sync --locked --all-groups
|
||||
- name: Tests with coverage gate
|
||||
run: uv run --locked pytest -q --junitxml=junit.xml
|
||||
- name: Keep the report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3.2.2
|
||||
with:
|
||||
name: coverage-${{ matrix.python }}
|
||||
path: |
|
||||
coverage.xml
|
||||
junit.xml
|
||||
.coverage
|
||||
if-no-files-found: warn
|
||||
|
||||
image:
|
||||
name: image
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
digest: ${{ steps.build.outputs.digest }}
|
||||
tag: ${{ steps.meta.outputs.tag }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Derive the content tag
|
||||
id: meta
|
||||
run: echo "tag=sha-$(git rev-parse --short=12 HEAD)" >> "$GITHUB_OUTPUT"
|
||||
- name: Build
|
||||
id: build
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker build --pull --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
|
||||
-t "$IMAGE:${{ steps.meta.outputs.tag }}" .
|
||||
docker image inspect "$IMAGE:${{ steps.meta.outputs.tag }}" --format '{{.Id}}'
|
||||
docker save "$IMAGE:${{ steps.meta.outputs.tag }}" > /dev/null
|
||||
- name: Record digest
|
||||
run: echo "digest=$(docker image inspect "$IMAGE:${{ steps.meta.outputs.tag }}" --format '{{.Id}}')" >> "$GITHUB_OUTPUT"
|
||||
id: digest
|
||||
|
||||
smoke:
|
||||
name: smoke
|
||||
needs: image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run the built image offline over stdio
|
||||
run: |
|
||||
set -euo pipefail
|
||||
image="$IMAGE:${{ needs.image.outputs.tag }}"
|
||||
name="smoke-$$"
|
||||
docker create --name "$name" --network none -e MCP_LIVE_ROUTE=direct -i "$image" > /dev/null
|
||||
trap 'docker rm -f "$name" > /dev/null 2>&1 || true' EXIT
|
||||
python3 scripts/mcp_smoke.py | docker start -a -i "$name" > smoke.out
|
||||
code=$(docker inspect --format '{{.State.ExitCode}}' "$name")
|
||||
cat smoke.out
|
||||
test "$code" = "0"
|
||||
python3 - "$name" <<'PY'
|
||||
import json, sys
|
||||
|
||||
lines = [line for line in open("smoke.out", encoding="utf-8") if line.strip()]
|
||||
assert lines, "no stdout"
|
||||
ids = []
|
||||
for line in lines:
|
||||
frame = json.loads(line)
|
||||
assert frame.get("jsonrpc") == "2.0", frame
|
||||
assert "error" not in frame, frame
|
||||
if "id" in frame:
|
||||
ids.append(frame["id"])
|
||||
assert ids == [1, 2, 3], ids
|
||||
init = next(json.loads(line) for line in lines if '"id": 1' in line or '"id":1' in line)
|
||||
tools = init["result"]["capabilities"]["tools"]
|
||||
assert tools is not None
|
||||
print("smoke ok:", ids)
|
||||
PY
|
||||
- name: Keep the transcript
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3.2.2
|
||||
with:
|
||||
name: smoke
|
||||
path: smoke.out
|
||||
|
||||
publish:
|
||||
name: publish
|
||||
needs: [image, smoke]
|
||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Log in with the package token
|
||||
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.eeee.moe -u omar --password-stdin
|
||||
- name: Push the immutable tag
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker build -t "$IMAGE:${{ needs.image.outputs.tag }}" .
|
||||
docker push "$IMAGE:${{ needs.image.outputs.tag }}"
|
||||
- name: Move latest only if HEAD has not moved
|
||||
run: |
|
||||
set -euo pipefail
|
||||
built=$(docker image inspect "$IMAGE:${{ needs.image.outputs.tag }}" --format '{{index .Config.Labels "org.opencontainers.image.revision"}}')
|
||||
head=$(git rev-parse HEAD)
|
||||
docker tag "$IMAGE:${{ needs.image.outputs.tag }}" "$IMAGE:latest"
|
||||
if [ "$built" = "$head" ]; then
|
||||
docker push "$IMAGE:latest"
|
||||
else
|
||||
echo "HEAD moved to $head, leaving latest alone"
|
||||
fi
|
||||
Reference in new issue
Block a user