Files
computer-playbook/roles/web-app-gitea/tasks/utils/mcp/verify.yml
kevinveenbirkenbachandClaude Opus 5 48bc49b492 feat(gitea): authenticate MCP callers through the adapter
The gitea-mcp sidecar holds no credential of its own and expects each
client to supply a Gitea token per request, so it answers initialize and
tools/list to anyone: the deploy probe measured a 200 disclosing the full
tool inventory. No sidecar setting closes that, because serving the
unauthenticated is how the upstream is built.

Front it with the svc-ai-mcp-adapter instance instead. Clients now present
mcp_bearer to compose service giteamcp and get a 401 otherwise; the
adapter presents the minted Gitea token upstream to giteamcpupstream,
which keeps the sidecar image but drops it to the role's own network.

Pin the 24 read-only tools the sidecar serves, captured from the running
instance, so the served surface cannot widen unnoticed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 11:43:42 +02:00

20 lines
866 B
YAML

---
- name: "🩺 Complete an MCP initialize handshake against the sidecar"
ansible.builtin.shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i {{ GITEA_API_LOCAL_CID | quote }} \
{{ lookup('timeout', 30) | curl(5, 0) }} -f -o /dev/null \
-X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H {{ ('Authorization: Bearer ' ~ gitea_mcp_token) | quote }} \
--data-binary {{ GITEA_MCP_INITIALIZE_PAYLOAD | to_json | quote }} \
{{ GITEA_MCP_SIDECAR_URL | quote }}
register: gitea_mcp_endpoint_probe
changed_when: false
retries: 30
delay: 2
until: gitea_mcp_endpoint_probe.rc == 0
delegate_to: "{{ GITEA_API_HOST_NODE }}"
run_once: true
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"