Skip to content

Model Context Protocol Support for Agentic Chat

We want to be able to support MCP for Agentic Chat. MCP allows enterprises to bring third party enterprise tools to Agentic chat. Allowing the LLM access to enterprise data.

sequenceDiagram
    participant User
    participant IDE
    participant DWS as Duo Workflow Service
    participant MCP as MCP Server
    participant LLM

    Note over User: Setup Phase
    User->>User: Create ~/.gitlab/duo/mcp.json<br/>describing MCP servers

    Note over User, LLM: Chat Initiation
    User->>IDE: Send chat message
    IDE->>IDE: Read MCP servers from mcp.json
    IDE->>MCP: Start MCP servers
    MCP->>IDE: Return available tools list
    
    Note over IDE, DWS: Workflow Start
    IDE->>DWS: startWorkflow(tools_list) via gRPC bidi stream
    DWS->>LLM: Send message for processing
    
    alt MCP Tool is Called
        LLM->>DWS: Response with MCP tool call
        
        Note over DWS: Workflow Paused
        DWS->>IDE: Request user approval via bidi stream
        IDE->>User: Show tool approval request
        User->>IDE: Approve/Reject (+ optional reason)
        IDE->>DWS: startWorkflow with approval result
        
        alt Tool Approved
            DWS->>IDE: Execute tool via bidi stream
            IDE->>MCP: Run tool
            MCP->>IDE: Tool result
            IDE->>DWS: Tool execution result
            DWS->>LLM: Continue with tool result
        else Tool Rejected
            DWS->>LLM: Cancel tool calls with rejection reason
        end
        
    else No MCP Tool Called
        LLM->>DWS: Regular response
    end
    
    Note over DWS, IDE: Response Delivery
    DWS->>IDE: Send final response via bidi stream
    IDE->>IDE: Update UI
    IDE->>User: Display response
Edited by Shekhar Patnaik