Add list_duo_sessions mcp tool

What does this MR do and why?

This MR adds the EE-only list_duo_sessions MCP tool.

References

Closes #607635 (closed)

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Create an OAuth token that can access the MCP server.

  2. Check that the tool is registered:

curl --silent --request POST "$MCP_URL" \
  --header "Authorization: Bearer $MCP_OAUTH_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' |
  jq -er '.result.tools[] | select(.name == "list_duo_sessions") | .name'
  1. List running Duo sessions for a project:
curl --silent --request POST "$MCP_URL" \
  --header "Authorization: Bearer $MCP_OAUTH_TOKEN" \
  --header 'Content-Type: application/json' \
  --data "$(jq -cn --argjson project_id "$PROJECT_ID" \
    '{jsonrpc:"2.0",id:2,method:"tools/call",
      params:{name:"list_duo_sessions",
      arguments:{project_id:$project_id,status:"running",page:1,per_page:20}}}')" |
  jq
  1. Validate the response shape:
curl --silent --request POST "$MCP_URL" \
  --header "Authorization: Bearer $MCP_OAUTH_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{"jsonrpc":"2.0","id":3,"method":"tools/call",
    "params":{"name":"list_duo_sessions",
    "arguments":{"page":1,"per_page":20}}}' |
  jq -e '
    .result.isError == false and
    (.result.structuredContent.sessions | type == "array") and
    (.result.structuredContent.metadata.page | type == "number") and
    (.result.structuredContent.metadata.per_page | type == "number") and
    (.result.structuredContent.metadata.has_more | type == "boolean") and
    (.result.structuredContent.sessions | all(
      has("id") and has("status") and has("goal") and
      has("flow") and has("web_url") and has("created_at")
    ))
  '
  1. Run specs:
bundle exec rspec \
  ee/spec/services/mcp/tools/duo_workflows/list_duo_sessions_service_spec.rb \
  ee/spec/requests/api/mcp/handlers/list_tools_spec.rb \
  ee/spec/services/ee/mcp/tools/manager_spec.rb

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.

Related to #607635 (closed)

Merge request reports

Loading
Loading