# ElectricSQL (Sync Engine) MCP for AI Agents AI Agent Connect

> ElectricSQL (Sync Engine) connects your Postgres database to your AI agent for real-time data syncing. It lets your agent fetch specific data subsets (shapes) and stay updated on changes instantly via the Electric sync engine. Stop manually exporting tables and let your agent see live application data as it happens.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_oHJ3qu09kCH5uxqL3iEMeyWmY3KKUyxH9z2Dq8V7/ai-agent-connect
- **Tags:** postgres, real-time-sync, data-streaming, incremental-updates, http-api, database-sync

## Description

You need your AI agent to know what is happening in your Postgres database right now without writing a bunch of custom middle layer code. This Connector handles that by hooking into the ElectricSQL sync engine. Instead of your agent trying to query your entire database at once which is slow and often impossible it pulls specific subsets of data. You can tell the agent to look at just the pending orders or the last ten messages and it stays synced with those specific rows. If a row changes the agent sees it. It is a way to give your agent a live window into your app state without the overhead of building a custom API for every single query. You can find this among the other high quality connectors in the Vinkius catalog to get your data moving faster. It works by creating a subscription to your data so the agent does not have to keep asking for updates. It just listens. This means your agent can answer questions about current users, active sessions, or inventory levels with perfect accuracy. It removes the need for you to manually export CSVs or copy and paste rows into a chat window to get the AI to help you with a task.

## Tools

### post_shape
Retrieves specific data subsets using POST requests to handle complex filtering. Use this when your query includes many conditions that would break a standard URL.

### get_shape
Fetches an initial snapshot of a Postgres data subset via a GET request. It is perfect for loading a list of items into your agent's memory at the start of a chat.

## Prompt Examples

**Prompt:** 
```
Can you show me the last 5 pending orders from the database?
```

**Response:** 
```
I've pulled the latest pending orders for you:

| Order ID | Date | Status | Amount |
| :--- | :--- | :--- | :--- |
| #502 | Today | Pending | $120.00 |
| #498 | Yesterday | Pending | $45.50 |
| #495 | Yesterday | Pending | $310.00 |
| #490 | Yesterday | Pending | $12.00 |
| #488 | Yesterday | Pending | $88.00 |

Would you like me to check the status of any of these specifically?
```

**Prompt:** 
```
Start watching the 'notifications' table and tell me when something new happens.
```

**Response:** 
```
I've enabled live sync for the notifications table. I am now monitoring the database for any new entries. I will alert you as soon as a new notification is posted.
```

**Prompt:** 
```
Get me a list of all users who signed up today but haven't finished their profile.
```

**Response:** 
```
I'm pulling that subset now... I found 12 users who signed up today but are still missing profile details:

* **User_A** (signed up 10:45 AM)
* **User_B** (signed up 11:12 AM)
* **User_C** (signed up 11:30 AM)
* ... (8 more)

Would you like me to send them a follow-up message?
```

## Capabilities

### Pull initial database snapshots
Get a full list of specific rows into your agent's context instantly.

### Stream live database updates
Keep your agent updated on every change in your Postgres tables automatically.

### Filter data subsets using SQL logic
Restrict the data your agent sees to only the specific rows and columns you care about.

### Handle complex queries without limits
Use deep filtering and multiple conditions without hitting URL length restrictions.

### Manage paginated results
Browse through large datasets efficiently using limits and offsets.

## Use Cases

### Debugging a live order
A dev asks why an order is stuck. The agent uses post_shape to find the specific pending order and sees the exact status.

### Monitoring a live chat
A moderator wants to see new messages. The agent uses get_shape to sync the history and then watches for live entries.

### Inventory check
A warehouse manager asks for low stock. The agent pulls the current items shape and lists everything below a certain threshold.

### User activity tracking
A product lead asks about current signups. The agent streams the latest user registrations directly into the chat.

## Benefits

- Get live updates instantly because it uses SSE and long-polling to keep your agent in the loop on every database change.
- Save on overhead by using get_shape to pull only the specific rows you need instead of the whole table.
- Handle complex logic easily with post_shape to manage deep filtering and large WHERE clauses.
- Reduce manual work by letting your agent monitor system states in real-time without human intervention.
- Simplify your stack because you do not have to build custom endpoints to expose your Postgres data.
- Improve accuracy by ensuring your agent always works with the most recent data available in your database.

## How It Works

The bottom line is you get a live, filtered feed of your Postgres data directly into your agent's context.

1. Provide your Electric Service URL in the Connector configuration.
2. Define the specific data subsets your agent needs to monitor.
3. Ask your agent to sync the data or watch for live changes.

## Frequently Asked Questions

**How can I connect my Postgres database to Claude?**
You can connect your Postgres database by using this Connector to bridge the data. It allows your agent to see your database tables as a live feed of information.

**Can I see live updates from my database in my AI agent?**
Yes, this Connector supports live updates. It keeps your agent informed of changes in your Postgres database in real-time so you always have the latest data.

**Does ElectricSQL (Sync Engine) support complex SQL filters?**
Yes, it handles complex filtering. You can use the sync engine to pull specific subsets of data based on multiple conditions without hitting URL limits.

**How do I sync specific rows from Postgres to my AI client?**
You define specific data shapes, which are just subsets of your tables. The Connector then pulls only those rows into your agent's context for you.

**Can I use ElectricSQL (Sync Engine) for real-time monitoring?**
That is one of its primary uses. It allows your agent to watch for changes in your database and notify you immediately when something happens.

**What is a data shape in ElectricSQL?**
A data shape is a specific subset of your database table. It lets you choose exactly which rows and columns the agent should see, keeping the context clean and relevant.

**How do I perform an initial sync of a database table?**
Use the `get_shape` tool and set the `offset` parameter to `-1`. This triggers ElectricSQL to send the full initial snapshot of the specified table.

**What should I do if my SQL WHERE clause is too long for a standard URL?**
You should use the `post_shape` tool. It sends the filtering criteria in the request body, which prevents '414 Request-URI Too Long' errors when using complex logic.

**Can the AI agent receive updates automatically when data changes in Postgres?**
Yes! By setting the `live` parameter to `true` in `get_shape`, the agent can establish a long-polling connection to stream incremental changes as they happen.