mcp.ymlΒΆ

---
- name: "πŸ” Read the MCP token this hub already issued"
  ansible.builtin.set_fact:
    homeassistant_mcp_token: "{{ lookup('mcp_credential', application_id) }}"

- name: "🩺 Check the stored token against the running hub"
  ansible.builtin.include_tasks: "{{ role_path }}/tasks/utils/mcp/probe.yml"
  when: homeassistant_mcp_token | length > 0

- name: "πŸš€ Onboard the hub and enable its MCP server"
  ansible.builtin.include_tasks: "{{ role_path }}/tasks/utils/mcp/provision.yml"
  when: homeassistant_mcp_token | length == 0 or homeassistant_token_probe.rc | default(1) != 0

- name: "🩺 Re-check the freshly minted token"
  ansible.builtin.include_tasks: "{{ role_path }}/tasks/utils/mcp/probe.yml"
  when: homeassistant_token_probe is not defined or homeassistant_token_probe.rc != 0

- name: "πŸ›‘ Refuse a hub whose MCP token every client would be rejected with"
  ansible.builtin.assert:
    that:
      - homeassistant_token_probe.rc == 0
    fail_msg: >-
      The hub rejected the token stored for {{ application_id }}, so every MCP
      client would be configured with a bearer the hub answers 401 to.