Content
# CData MCP Agent for ADK Web
A Google ADK agent that provides natural language access to CData Connect Cloud databases through the MCP (Model Context Protocol).
## Features
- 🔍 **Natural Language Queries**: Ask questions about your data in plain English
- 📊 **Database Exploration**: Browse catalogs, schemas, and tables
- 🔧 **SQL Execution**: Run queries on connected data sources
- 🌐 **Web Interface**: Visual interface through ADK Web
## Prerequisites
- Python 3.8+
- Google AI API key
- CData Connect Cloud MCP server credentials
## Setup
1. **Install ADK and dependencies**:
```bash
pip install google-adk python-dotenv
```
> **Note**: If you install with `pip install --user` (or pip defaults to user installation), the `adk` command may not be in your PATH. You'll need to either:
> - Use the full path: `~/Library/Python/3.x/bin/adk` (on macOS)
> - Add to PATH: `export PATH="$HOME/Library/Python/3.x/bin:$PATH"` in your shell config
> - Use a virtual environment where the PATH is automatically configured
2. **Configure environment variables**:
- Copy the `.env.example` file to `.env`:
```bash
cp .env.example .env
```
- Edit `.env` and add your credentials:
```env
# Google AI API Configuration
GOOGLE_API_KEY=your_google_api_key_here
# CData MCP Server Configuration
MCP_SERVER_URL=https://mcp.cloud.cdata.com/mcp
MCP_USERNAME=your_email@example.com
MCP_PASSWORD=your_mcp_password_here
# Optional: Gemini Model (defaults to gemini-2.0-flash-exp)
GEMINI_MODEL=gemini-2.0-flash-exp
```
## Running with ADK Web
1. **Start ADK Web** from this directory:
```bash
adk web --port 5000 .
```
2. **Open the web interface** (typically http://localhost:5000)
3. **Select the agent**: Choose `cdata_query_assistant` from the dropdown
4. **Start querying** your data with natural language:
- "What databases are available?"
- "Show me the tables in MongoDB1"
- "List the schemas in the SQL2 database"
- "What columns are in the customers table?"
## Example Queries
- **Explore databases**: "List all available catalogs"
- **View schemas**: "Show schemas in the MongoDB1 catalog"
- **Browse tables**: "What tables are in the dbo schema?"
- **Examine structure**: "Describe the columns in the orders table"
- **Query data**: "Show me recent orders from the sales database"
## How It Works
1. **ADK Agent**: The `LlmAgent` receives your natural language queries
2. **MCP Toolset**: Connects to CData Connect Cloud via MCP protocol
3. **Tool Discovery**: Automatically discovers available data operations
4. **Gemini AI**: Understands queries and determines which tools to use
5. **Data Access**: Executes operations and returns formatted results
## Available MCP Tools
- `getCatalogs` - List available databases
- `getSchemas` - View schemas in a database
- `getTables` - Browse tables in a schema
- `getColumns` - Examine table structure
- `getProcedures` - List stored procedures
- `getProcedureParameters` - View procedure parameters
- `executeProcedure` - Run stored procedures
- `queryData` - Execute SQL queries
## Architecture
```
User Query → ADK Web UI → CData MCP Agent → Gemini AI
↓ ↓
Visual Interface MCP Protocol
↓ ↓
Response Display CData Connect Cloud
```
## Troubleshooting
- **Connection errors**: Verify MCP_SERVER_URL and credentials
- **No tools available**: Check MCP server is accessible
- **Auth issues**: Ensure username/password are correct
- **Windows users**: Try `adk web --no-reload` if you encounter subprocess errors
## Notes
- The agent uses Gemini 2.0 Flash for fast, intelligent responses
- All data operations go through CData's secure MCP server
- The web interface provides a better user experience than CLI