mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
The contract check ran as an Ansible task in the middle of every provider deploy, and the two client checks ran the same way. A test that is part of the deploy cannot be run without deploying, cannot be re-run on its own, and reports its verdict as a deploy failure. Twenty-seven task files lose 491 lines to this.
It is now what it always was. Each provider ships files/test/test.sh, templates/test.env.j2 and meta/tests.yml, and test-e2e-cli stages one shared harness beside it: run.sh drives contract.sh in a throwaway container on the provider's own network, then isolation.sh for adapter-fronted providers. The read probe each provider offers moved from the calling task into meta/mcp.yml next to the allowlist it must satisfy, and the schema now rejects a read probe naming a tool outside that allowlist.
The bearer the test presents is the one a client resolves through mcp.credential, via the new mcp_client_bearer lookup over resolve_credential, which moved to utils.roles.applications.mcp so it is the same function mcp_servers renders every client connection with. The probe presented whatever the calling role passed, which for the fifteen adapter-fronted providers is a different secret than any client holds.
Sidecar isolation is read from the engine rather than measured inside the container, so it no longer needs a delegation to the node holding the task: attachment is compared by network name, which drops the gwbridge special case, and a swarm worker says it cannot measure instead of skipping silently.
Retrying is bounded by wall clock against MCP_DEADLINE_SECONDS, which scales through the same lookup('timeout') as the harness budget it has to stay under. A flag that is neither true nor false aborts rather than reading as off.
mcp-provider-probe becomes mcp-provider-cli-test: an enabled provider must ship the test rather than include the task. mcp-probe-bearer becomes mcp-adapter-bearer, tying ADAPTER_BEARER to the declared credential key now that no probe include carries it. A new integration test renders the shared env template for every provider through Ansible's own templar, so a later change to it breaks visibly instead of poisoning twenty deploys quietly.
Hermes and OpenClaw keep their client-side proof as CLI tests of their own.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
66 lines
2.7 KiB
YAML
66 lines
2.7 KiB
YAML
---
|
|
- name: "🧱 Rebuild the MCP adapter of {{ application_id }}"
|
|
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/svc-ai-mcp-adapter/tasks/rebuild.yml') }}"
|
|
|
|
- name: "🚿 Flush compose handlers for {{ application_id }}"
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
- name: "🔍 Read the upstream credential the {{ application_id }} adapter holds"
|
|
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/svc-ai-mcp-adapter/tasks/current_key.yml') }}"
|
|
vars:
|
|
mcp_upstream_key_path: "{{ [JELLYFIN_MCP_INSTANCE_DIR, 'upstream.env'] | path_join }}"
|
|
|
|
- name: "🔍 Resolve {{ application_id }} hosting node + container id"
|
|
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}"
|
|
vars:
|
|
resolve_service_key: "{{ JELLYFIN_MCP_SERVICE_KEY }}"
|
|
resolve_output_prefix: JELLYFIN_IDENTITY
|
|
resolve_compose_cid: "{{ JELLYFIN_MCP_CONTAINER }}"
|
|
|
|
- name: "🔑 Converge the read-only Jellyfin user the MCP adapter authenticates as"
|
|
ansible.builtin.command:
|
|
argv:
|
|
- container
|
|
- exec
|
|
- -i
|
|
- -e
|
|
- "JELLYFIN_BASE={{ JELLYFIN_MCP_UPSTREAM_URL }}"
|
|
- -e
|
|
- "JELLYFIN_ADMIN_USER={{ JELLYFIN_ADMIN_USERNAME }}"
|
|
- -e
|
|
- "JELLYFIN_ADMIN_PASSWORD={{ JELLYFIN_ADMIN_PASSWORD }}"
|
|
- -e
|
|
- "MCP_USER={{ JELLYFIN_MCP_UPSTREAM_USER }}"
|
|
- -e
|
|
- "MCP_PASSWORD={{ JELLYFIN_MCP_UPSTREAM_PASSWORD }}"
|
|
- -e
|
|
- "MCP_DEVICE_ID={{ JELLYFIN_MCP_UPSTREAM_DEVICE_ID }}"
|
|
- -e
|
|
- "MCP_CURRENT_TOKEN={{ MCP_UPSTREAM_CURRENT_KEY }}"
|
|
- "{{ JELLYFIN_IDENTITY_LOCAL_CID }}" # nocheck: container-exec-resolver
|
|
- python3
|
|
- "-"
|
|
stdin: "{{ lookup('file', 'python/provision_mcp_identity.py') }}"
|
|
register: jellyfin_mcp_identity
|
|
retries: 30
|
|
delay: 10
|
|
until: jellyfin_mcp_identity.rc == 0 or 'REJECTED' in jellyfin_mcp_identity.stderr
|
|
changed_when: jellyfin_mcp_identity.stdout_lines[0] | default('') == 'CHANGED'
|
|
delegate_to: "{{ JELLYFIN_IDENTITY_HOST_NODE }}"
|
|
run_once: true
|
|
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
|
|
|
|
- name: "🛑 Refuse an adapter whose upstream identity did not converge"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- jellyfin_mcp_identity.rc == 0
|
|
- jellyfin_mcp_identity.stdout_lines | length == 2
|
|
fail_msg: >-
|
|
{{ application_id }} could not give its MCP adapter a read-only identity.
|
|
|
|
- name: "🔑 Hand the captured token to the adapter"
|
|
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/svc-ai-mcp-adapter/tasks/upstream_key.yml') }}"
|
|
vars:
|
|
mcp_upstream_key_path: "{{ [JELLYFIN_MCP_INSTANCE_DIR, 'upstream.env'] | path_join }}"
|
|
mcp_upstream_key: "{{ jellyfin_mcp_identity.stdout_lines[1] }}"
|