[Semantic Code Search] Agentic Chat Integration
## Context
This epic captures the tasks we need to do in order to implement Codebase Semantic Search as a tool in Agentic Chat.
We have already introduced a [Codebase Semantic Search tool for Classic Duo Chat](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/gitlab/llm/chain/tools/codebase_search/executor.rb#L8). This cannot be used by Agentic Chat since Agentic Chat defines and uses tools differently. We can, however, re-use the same [ActiveContext Query class](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/ai/active_context/queries/code.rb#L6) used by Classic Chat's Codebase Semantic Search tool.
## References
- [Initial investigation effort](https://gitlab.com/gitlab-org/gitlab/-/issues/549013)
- [Details about adding a Codebase Semantic Search tool in Agentic Chat](https://gitlab.com/gitlab-org/gitlab/-/issues/549013#note_2564049258)
**Duo Workflow**
- [Duo Workflow Architecture Document](https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/duo_workflow/)
- Follow-up ADRs: go to bottom of page
- Repositories
- [Duo Workflow Executor](https://gitlab.com/gitlab-org/duo-workflow/duo-workflow-executor)
- Duo Workflow Service - [in AIGW](https://gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/-/tree/main/duo_workflow_service?ref_type=heads) | [in own repo (archived)](https://gitlab.com/gitlab-org/duo-workflow/duo-workflow-service/)
- Further Duo Workflow docs
- [in AIGW](https://gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/-/blob/main/docs/duo_workflow_service.md?ref_type=heads)
**Agentic Chat on Duo Workflow**
- https://gitlab.com/gitlab-org/gitlab/-/issues/524895+
- Diagram: [Proposed Flow IDE](https://gitlab.com/gitlab-org/gitlab/-/issues/524895#proposed-flow-ide)
- Diagram: [Proposed Flow Gitlab UI](https://gitlab.com/gitlab-org/gitlab/-/issues/524895#proposed-flow-gitlab-ui)
**Model Context Protocol**
- Epic for introducing the GitLab MCP Server: https://gitlab.com/groups/gitlab-org/-/epics/18413
- Epic for migrating Duo Workflow tools to MCP: https://gitlab.com/groups/gitlab-org/-/epics/18759
- Generic MCP guide: https://modelcontextprotocol.io/docs/getting-started/intro
- GitLab's MCP user doc: https://docs.gitlab.com/user/gitlab_duo/model_context_protocol/
- GitLab's MCP development doc: https://docs.gitlab.com/development/mcp_server/
- API design discussion for MCP tool: https://gitlab.com/gitlab-org/gitlab/-/issues/569206+
## Proposal
These are the tasks we need to implement in order of dependency.
### Agentic Chat Support
| Task | Issue |
| ---- | ----- |
| [Rails] Expose a Codebase Semantic Search API that can be called by the above tool. This should make use of the same [ActiveContext query class](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/ai/active_context/queries/code.rb#L6) currently used by [Classic Chat's Codebase Search Tool executor](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/gitlab/llm/chain/tools/codebase_search/executor.rb#L8). | https://gitlab.com/gitlab-org/gitlab/-/issues/555843 |
| [Rails] Add `CodebaseSemanticSearch` as a [new MCP tool](https://docs.gitlab.com/development/mcp_server/#adding-a-new-tool) | https://gitlab.com/gitlab-org/gitlab/-/issues/569624 |
| Support `CodebaseSemanticSearch` invocation for multiple projects | https://gitlab.com/gitlab-org/gitlab/-/issues/569625 |
| Source tracking | https://gitlab.com/gitlab-org/gitlab/-/issues/548421 |
### Improve projects query
| Task | Issue |
| ---- | ----- |
| Finalize/settle on the approach for searching projects and implement | https://gitlab.com/gitlab-org/gitlab/-/issues/555843 |
epic