Simple Chat uses LangGraph and MCP integration for enhanced tool handling with support for Slack, GitHub, Google Drive, Gmail, and Google Calendar.
Processing Flow
1. Query Processing
- User sends query from frontend
- Python API forwards to Service Controller
- Controller selects Model Service based on chosen model
- LLM is initialized
- MultiServerClient fetches available tools from MCP server
2. Tool Management
- Available Tools: Slack, GitHub, Google Drive, Google Calendar, Gmail
- Tools are matched against current query
- Unnecessary tools filtered out before LLM binding
3. StateGraph Construction
LangGraph StateGraph created with:- ToolNode - Tool execution
- ChatbotNode - Standard LLM responses
4. Context Initialization
- Chat Repository initialized with
chat_id
- Chat history retrieved and converted to memory
- Context prepared for conversation flow
5. Execution Logic
StateGraph determines response path:- Tool usage detected → ToolNode execution
- Standard query → ChatbotNode response
- Combined context (query + history) passed to selected node
Tool Activation Rules
Tool | Activation Condition |
---|---|
Web Search | GPT-4.1-search model only |
Image Generation | GPT-based models only |
MCP Tools | Dynamically filtered per query |
Response Processing
- Tool Invocation - Selected tool executed if needed
- LLM Integration - Tool may call LLM internally
- Streaming - Response streamed to frontend in real-time
Cost and Logging
MongoDB Handler logs:- Final response content
- Token usage metrics
- Tool activation records
- Cost breakdown
- Input/output token lengths measured
- Cost written via Cost Callback
- Total breakdown stored in database
Architecture

Simple Chat Architecture Flow
Web Search and Image Generation are model-gated. Verify model compatibility before tool invocation.
Troubleshooting
Tool Not Triggering
- Check tool compatibility with selected model
- Verify MultiServerClient pulled latest tools from MCP
- Review filtering logic for tool exclusion
- Validate LangGraph ChatbotNode → ToolNode transition
Streaming Issues
- Confirm frontend WebSocket/SSE connections
- Validate LangGraph state execution and transitions
- Check for tool execution bottlenecks
- Monitor MongoDB logs for latency indicators