[Meta] Q&A insights (tagging, content gaps) and MCP tool access for AI Answers
### Problem/Motivation
AI Answers already gives visitors grounded, cited answers. What site owners still can't see is the other side: *what* people are asking, *which* questions we couldn't answer, and *what content they should write next*. That feedback loop is where the real value is, and it's exactly the kind of thing Drupal should make easy.
@wouters_frederik already built this in [ai_search_block](https://www.drupal.org/project/ai_search_block) and suggested we bring it over:
- **Q&A tagging** (`ai_search_block_log_tag`)
- **Content gaps analysis** (`ai_search_block_gaps`, which needs tagging)
In his words: "this is really really super powerful." Having seen it run on a real site, I agree. A report that says "4 visitors asked about BBQ cleaner and we had nothing for them" is something an editor can act on the same day.
@dries also asked for AI Answers / AI search to be callable as an **MCP tool** (submodule), so he can run his image search and content search demo straight from Claude using Drupal tools. This feels like a natural next step: the content, the permissions and the retrieval already live in Drupal, so an AI agent should be able to ask Drupal directly instead of scraping the site. It's totally something that should just work with Drupal, and AI Answers is well placed to make it happen.
### Proposed resolution
Deliver as optional submodules, with no change to existing AI Answers behaviour. #3615759 and #3615763 also add small, back-compatible APIs to AI Answers itself (events, a `noAnswer` flag, a `channel` argument, and a public `AnswerService::search()`). Each child issue has the detailed technical plan:
1. #3615759 Structured per-turn log (`ai_answers_log`) and turn/feedback events, the foundation
2. #3615760 Tagging (`ai_answers_tag`), depends on #3615759
3. #3615761 Content gaps (`ai_answers_gaps`), depends on #3615759. Tagging is optional: AI Answers already knows when an answer cited nothing, so gaps don't need tags.
4. #3615762 Plan: shared Q&A insights layer with ai_search_block
5. #3615763 Tool API + MCP tools (`ai_answers_tool`)
6. #3615764 Image data in search/MCP results, depends on #3615763
7. #3615765 Docs, recipe and demo script, depends on #3615760, #3615761 and #3615763
8. #3615803 Guardrail-blocked turns: show the guardrail's message on every path, log them as `blocked` and keep them out of gaps and tags, depends on #3615759
Suggested order: #3615759 first; then #3615760, #3615761 and #3615763 in parallel; then #3615764 and #3615765. #3615762 can run alongside any time.
#3615759 touches the same part of `AnswerService` as #3615755, so that one should land first or the two need to be coordinated.
### Remaining tasks
- [x] File child issues and link them here
- [ ] Agree shared-layer scope with @wouters_frederik (#3615762)
- [ ] Request AI Initiative triage in #ai-contrib
- [ ] Deliver children in dependency order
### User interface changes
New Insights pages under `/admin/config/ai/ai-answers/insights`. No front-end changes.
### API changes
- New events `AnswerTurnCompletedEvent` and `AnswerFeedbackEvent`, a `noAnswer` flag on `Answer`, and an optional `channel` argument on `AnswerService::answer()` (#3615759).
- New public `AnswerService::search()` (#3615763).
- New services and Tool API tools in the submodules.
All back-compatible.
### Data model changes
New `ai_answers_log` entity and `ai_answers_tag` table, in submodules only (#3615759, #3615760).
_[AI disclosure](https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquette/policy-on-the-use-of-ai-when-contributing-to-drupal#s-disclosure): Used AI to help with research and writing (reading the ai_answers and ai_search_block code, filing the child issues, updating this summary). The reasoning and positions are my own, and I reviewed everything before posting._
issue
GitLab AI Context
Project: project/ai_answers
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/ai_answers/-/raw/1.0.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/ai_answers
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD