Log MCP origin of Duo sessions to mcp.log
What does this MR do and why?
This MR writes a log line to mcp.log when a Duo session is created over MCP.
Before this change, the MCP origin of a Duo session was only in the database and in Snowflake. It was not in Kibana. Now it is also in the logs.
The work item scope was reduced in a comment. The database marker and the internal event were already done in !253728 (merged) and !254746 (merged). The Orbit MCP endpoint cannot start sessions, so it is not a gap. This MR does the remaining work.
Ai::DuoWorkflows::CreateWorkflowServicelogs one line throughGitlab::Mcp::Loggerwhen the new session hassource_typemcp.- The log is in the shared create service. It covers all creation paths: AI Catalog flows, GitLab flows, and foundational agents.
- The line has these fields:
message,event_name,ai_component,source_type,duo_workflow_id, andgl_user_id. - The line has the same
correlation_idas the MCPtool_callline from the same request. - The fields are always logged. Expanded AI logging does not control them.
doc/administration/logs/_index.mddescribes the new line in themcp.logsection.doc/development/duo_agent_platform/mcp/_index.mdhas a new section, "Filter Duo sessions by MCP origin". It shows how to filter in the database, Snowflake, and Kibana.
The log volume is very small. There is one line for each session created over MCP.
There is no feature flag and no database change.
References
- Work item: #630113 (closed)
- Epic (MCP Server instrumentation): gitlab-org#23391
- Earlier MR, internal event with
source: mcp: !253728 (merged) - Earlier MR,
source_typemcpon the non-catalog branch: !254746 (merged)
Screenshots or screen recordings
There is no UI change. This is an example of the new log line in mcp.log:
{
"severity": "INFO",
"time": "2026-10-06T10:00:00.000Z",
"correlation_id": "29d8d33c-b727-4910-98c9-5b029299f323",
"meta.caller_id": "POST /api/:version/mcp",
"meta.feature_category": "mcp_server",
"message": "Duo session created over MCP",
"event_name": "duo_session_created",
"ai_component": "mcp_server",
"gl_user_id": 1,
"source_type": "mcp",
"duo_workflow_id": 123
}How to set up and validate locally
-
Use a GDK with GitLab Duo Agent Platform and the MCP server working. You also need a project where you can start a Duo session. You need the Developer role or higher, and a runner for Duo sessions.
-
In a terminal, follow the log. Run this from the
gitlabdirectory of the GDK:tail -f log/mcp.log | grep duo_session_created -
Start a session over MCP. For example, connect an MCP client such as Claude Code or Cursor to
http://gdk.test:3000/api/v4/mcp. Ask it to call thestart_duo_sessiontool with a project and a goal.You can also send a JSON-RPC request with curl. The token needs the
mcpscope.curl --request POST "http://gdk.test:3000/api/v4/mcp" \ --header "Authorization: Bearer <your_access_token>" \ --header "Content-Type: application/json" \ --header "Accept: application/json, text/event-stream" \ --data '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"start_duo_session","arguments":{"project_id":"<group/project>","goal":"Add a README section"}}}' -
Check that
mcp.loghas aduo_session_createdline. It should havesource_typeset tomcp. The session ID should be induo_workflow_id. -
Optional: check that the
tool_callline forstart_duo_sessionhas the samecorrelation_id. -
Open the Rails console with
bin/rails console. Run this command:Ai::DuoWorkflows::Workflow.source_mcp.lastIt should return the same session as
duo_workflow_idin the log line. -
Do a negative check. Start a session another way, for example from the GitLab UI or the Duo CLI. No
duo_session_createdline should be added tomcp.log.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.