Overview
Drasi is a change detection platform that makes it easy and efficient to detect and react to changes in databases. The LangChain-Drasi integration creates reactive, change-driven AI agents by connecting external data changes with workflow execution. This allows agents to discover, subscribe to, and react to real-time query updates by bridging external data changes with agentic workflows. Drasi continuous queries stream real-time updates that trigger agent state transitions, modify memory, or dynamically control workflow execution—transforming static agents into ambient long-lived, responsive systems.Details
| Class | Package | Serializable | JS support | Downloads | Version |
|---|---|---|---|---|---|
DrasiTool | langchain-drasi | ❌ | ❌ |
Features
- Query Discovery - Automatically identify available Drasi queries
- Real-time Subscriptions - Monitor continuous query updates
- Notification Handlers - Six built-in handlers for different use cases
- Console
- Logging
- Memory
- Buffer
- LangChain Memory
- LangGraph Memory
- Custom Handlers - Extend base handler for domain-specific logic
Setup
To access the Drasi tool, you’ll need to have Drasi and the Drasi MCP server running.Prerequisites
- Drasi platform - Installed and running
- Drasi MCP server - Configured and accessible
- Python 3.11+ - Required for the
langchain-drasipackage
Credentials (Optional)
If your Drasi MCP server requires authentication, you can configure headers with Bearer tokens or other authentication methods:Configure authentication
Installation
The Drasi tool lives in thelangchain-drasi package:
Instantiation
Now we can instantiate an instance of the Drasi tool. You’ll need to configure the MCP connection and optionally add notification handlers to process real-time updates:Initialize tool instance
Invocation
Directly
Below is a simple example of calling the tool directly.Call tool
As a ToolCall
We can also invoke the tool with a model-generated ToolCall, in which case a ToolMessage will be returned.
Within an agent
We can use the Drasi tool in a LangGraph agent to create reactive, event-driven workflows. For this we will need a model with tool-calling capabilities.Agent with tool
Notification handlers
One of Drasi’s key features is its built-in notification handlers that process real-time query result changes. You can use these handlers to take specific actions based on the data changes.Built-in handlers
ConsoleHandler - Outputs formatted notifications to stdout:
Custom handlers
You can create custom handlers by extendingBaseDrasiNotificationHandler:
Examples
- Interactive Chat: A chat application that uses Drasi for real-time memory updates.
- Terminator Game: A game that leverages Drasi for dynamic NPC behavior.
Use cases
Drasi is particularly useful for building ambient agents that need to react to real-time data changes. Some example use cases include:- AI Co-pilots - Assistants that monitor and respond to system events
- AI game players - NPCs that adapt to in-game events
- IoT Monitoring - Agents that process sensor data streams
- Customer Support - Bots that react to ticket updates or customer actions
- DevOps Assistants - Tools that monitor infrastructure changes
- Collaborative Editing - Systems that respond to document or code changes