Overview
This demo shows you how to build an AI agent that connects RisingWave with Anthropic’s LLM. The agent processes natural language queries and returns clean, readable results to users. The agent includes several key components:- Table extraction from SQL-like queries
- Dynamic table schema fetching
- MCP tool invocation
- Result parsing and formatting
- Chat loop management between RisingWave and Anthropic
- Implement a custom Anthropic agent
- Integrate it with RisingWave MCP
- Perform simple stream processing with RisingWave
Prerequisites
Before you begin, you need:- RisingWave: Install and run RisingWave. See the Quick start guide.
- Anthropic API key: Get your key from the Anthropic console.
- PostgreSQL client: Install
psql
. See Download PostgreSQL. - RisingWave MCP: Clone the RisingWave MCP repository.
Step 1: Set up your environment
Create a.env
file with your RisingWave connection configuration:
Step 2: Create the agent
Import the required dependencies
Import these modules for your agent:Build the main agent class
TheRisingWaveMCPAgent
class manages connections and caches. Adjust the environment variables if you’re connecting to a remote RisingWave instance.
Add core functionality
Add these functions to handle tool usage and provide table context:Add the main function
Add the entry point to start the program:Step 3: Create test data
Create test data using the load generator tutorial or run this script:Step 4: Run and test the agent
Start the agent
Run this command to start the agent:Test the agent
Try these example commands: Get database information:- Give me the database version
- Show me the users table structure
- Track the highest risk scores
- Sort that mv by highest spending and display
Clean up
When you finish testing:- Stop the agent: Type
quit
in the agent interface. - Clean up test data (optional): Ask the agent to “Drop the users table”.
- Stop RisingWave: Stop the RisingWave service if you started it for this demo.