|
| 1 | +name: MCP Check |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main] |
| 5 | + paths: |
| 6 | + - 'plugins/**' |
| 7 | + - '.github/workflows/mcp-check.yml' |
| 8 | + pull_request: |
| 9 | + paths: |
| 10 | + - 'plugins/**' |
| 11 | + - '.github/workflows/mcp-check.yml' |
| 12 | + schedule: |
| 13 | + - cron: '17 8 * * *' |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + check: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + timeout-minutes: 10 |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 25 | + |
| 26 | + - name: Resolve the declared server config |
| 27 | + run: | |
| 28 | + set -euo pipefail |
| 29 | + config=plugins/greptile/.mcp.json |
| 30 | + jq -e 'if has("mcpServers") then .mcpServers else . end' "$config" > "$RUNNER_TEMP/servers.json" |
| 31 | + if ! jq -e '.greptile | type == "object"' "$RUNNER_TEMP/servers.json" >/dev/null; then |
| 32 | + echo "::error::$config does not declare a \"greptile\" server object in either the bare or mcpServers shape." |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | + if ! jq -e '.greptile.url | type == "string" and startswith("https://")' "$RUNNER_TEMP/servers.json" >/dev/null; then |
| 36 | + echo "::error::$config does not declare an https url for the greptile server." |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + jq -r '.greptile.url' "$RUNNER_TEMP/servers.json" > "$RUNNER_TEMP/url.txt" |
| 40 | + echo "Resolved $(cat "$RUNNER_TEMP/url.txt")" |
| 41 | +
|
| 42 | + - name: Config uses OAuth discovery |
| 43 | + run: | |
| 44 | + set -euo pipefail |
| 45 | + if jq -e '.greptile | has("headers") or has("bearer_token_env_var")' "$RUNNER_TEMP/servers.json" >/dev/null; then |
| 46 | + echo "::error::MCP config must use OAuth discovery, without headers or bearer_token_env_var." |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | + echo "No headers declared." |
| 50 | +
|
| 51 | + - name: Server still advertises OAuth |
| 52 | + run: | |
| 53 | + set -euo pipefail |
| 54 | + url=$(cat "$RUNNER_TEMP/url.txt") |
| 55 | + response=$(curl -sS -o /dev/null -D - -X POST "$url" \ |
| 56 | + -H 'Content-Type: application/json' \ |
| 57 | + -H 'Accept: application/json, text/event-stream' \ |
| 58 | + -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_code_reviews","arguments":{}}}' \ |
| 59 | + -w 'http_code=%{http_code}\n') |
| 60 | + echo "$response" |
| 61 | + if ! grep -q 'http_code=401' <<<"$response"; then |
| 62 | + echo "::error::An unauthenticated tools/call on $url did not return 401. Codex starts the OAuth flow from that challenge." |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | + if ! grep -qi '^www-authenticate:.*resource_metadata=' <<<"$response"; then |
| 66 | + echo "::error::$url returned 401 without an RFC 9728 www-authenticate challenge. Codex needs resource_metadata to discover the authorization server." |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | + echo "OAuth challenge present." |
| 70 | +
|
| 71 | + - name: README documents exactly the tools the server serves |
| 72 | + run: | |
| 73 | + set -euo pipefail |
| 74 | + url=$(cat "$RUNNER_TEMP/url.txt") |
| 75 | + curl -sS -X POST "$url" \ |
| 76 | + -H 'Content-Type: application/json' \ |
| 77 | + -H 'Accept: application/json, text/event-stream' \ |
| 78 | + -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' > "$RUNNER_TEMP/tools.json" |
| 79 | + python3 - <<'PY' |
| 80 | + import json, os, re, sys |
| 81 | +
|
| 82 | + with open(os.path.join(os.environ['RUNNER_TEMP'], 'tools.json')) as fh: |
| 83 | + payload = json.load(fh) |
| 84 | + if 'result' not in payload: |
| 85 | + sys.exit(f"::error::tools/list returned no result: {json.dumps(payload)[:400]}") |
| 86 | + served = {t['name'] for t in payload['result']['tools']} |
| 87 | + if not served: |
| 88 | + sys.exit('::error::tools/list returned no tools.') |
| 89 | +
|
| 90 | + readme = open('plugins/greptile/README.md').read() |
| 91 | + documented = set(re.findall(r'^- `([a-z_]+)`', readme, re.M)) |
| 92 | + documented |= set(re.findall(r'/ `([a-z_]+)`', readme)) |
| 93 | +
|
| 94 | + missing = sorted(served - documented) |
| 95 | + extra = sorted(documented - served) |
| 96 | + if missing: |
| 97 | + print(f"::error::README does not document: {', '.join(missing)}") |
| 98 | + if extra: |
| 99 | + print(f"::error::README documents tools the server does not serve: {', '.join(extra)}") |
| 100 | + if missing or extra: |
| 101 | + sys.exit(1) |
| 102 | + print(f"README documents all {len(served)} served tools.") |
| 103 | + PY |
0 commit comments