---
title: Migration guide
slug: migration-guide
docTags: 
createdAt: 2026-08-26T21:54:24.640Z
---

This guide walks you through migrating an agent from Elasticsearch (ES) queries to the Bridge MCP Server (Trino/SQL via MCP tools).

# Prerequisites

- Bridge Agent SDK with MCPClient (already in bridge\_agent\_sdk.mcp)
- KAIF\_HOST configured for your runtime (SDK can auto-resolve MCP endpoint)
- Bridge MCP server URL via BRIDGE\_MCP\_SERVER\_URL only when you want to override endpoint resolution
- Runtime agent\_payload containing account\_id and instance\_name

#  Step by step migration

1. **Step 1: Identify your domain and table:&#x20;**&#x43;heck which domain and table in Bridge corresponds to your ES index. See [step 1](https://github.com/kyndryl-agentic-ai/bdg-sw-agents-development-guide/blob/main/docs/05-mcp-tools/06-es-to-bridge-mcp-migration.md#step-1-identify-your-domain-and-table)
2. **Step 2: [Get column schema](https://github.com/kyndryl-agentic-ai/bdg-sw-agents-development-guide/blob/main/docs/05-mcp-tools/06-es-to-bridge-mcp-migration.md#step-2-get-column-schem)**
3. **Step 3: [Convert ES queries to Trino DSQL](https://github.com/kyndryl-agentic-ai/bdg-sw-agents-development-guide/blob/main/docs/05-mcp-tools/06-es-to-bridge-mcp-migration.md#step-3-convert-es-queries-to-trino-sql)**
4. **Step 4: [Use MCPClient in code](https://github.com/kyndryl-agentic-ai/bdg-sw-agents-development-guide/blob/main/docs/05-mcp-tools/06-es-to-bridge-mcp-migration.md#step-4-use-mcpclient-in-cod)**
5. **Step 5: [Parse response](https://github.com/kyndryl-agentic-ai/bdg-sw-agents-development-guide/blob/main/docs/05-mcp-tools/06-es-to-bridge-mcp-migration.md#step-5-parse-response)**

**ES → Trino SQL conversion cheatsheet**

| <font color="#f3f4f6">**ES concept**</font> | <font color="#f3f4f6">**Trino SQL equivalent**</font> |
| ------------------------------------------- | ----------------------------------------------------- |
| term                                        | WHERE field = 'value'                                 |
| terms                                       | WHERE field IN ('a','b')                              |
| range.gte                                   | WHERE field >= value                                  |
| @timestamp now-1d                           | CURRENT\_TIMESTAMP - INTERVAL '1' DAY                 |
| @timestamp now-2h                           | CURRENT\_TIMESTAMP - INTERVAL '2' HOUR                |
| @timestamp now-30m                          | CURRENT\_TIMESTAMP - INTERVAL '30' MINUTE             |
| match                                       | WHERE field LIKE '%text%'                             |
| exists                                      | WHERE field IS NOT NULL                               |
| bool.must                                   | AND                                                   |
| bool.should                                 | OR                                                    |
| bool.must\_not                              | NOT (...)                                             |
| sort desc                                   | ORDER BY field DESC                                   |
| size                                        | LIMIT                                                 |
| from                                        | OFFSET                                                |
| .keyword                                    | Drop suffix (tenant\_id.keyword → tenant\_id)         |

For an autonomous documentation creation agent, see this [link](https://github.com/kyndryl-agentic-ai/bdg-sw-agents-development-guide/blob/main/docs/05-mcp-tools/06-es-to-bridge-mcp-migration.md#complete-example-autonomous-doc-creation-agent).   

# What changed (before vs after)

| <font color="#f3f4f6">**Aspect**</font> | <font color="#f3f4f6">**Before (ES)**</font>                           | <font color="#f3f4f6">**After (Bridge MCP)**</font>       |
| --------------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------- |
| Auth                                    | ES username/password from account settings                             | agent\_payload auto token via MCPClient                   |
| Connection                              | requests.post(es\_url/index/\_search)                                  | MCPClient.call\_tool\_parsed("bridge\_execute\_query")    |
| Query format                            | ES JSON DSL (bool, must, range, term)                                  | Trino SQL (SELECT ... WHERE ... ORDER BY)                 |
| Response parsing                        | result\["hits"]\["hits"]\[\*]\["\_source"]                             | parsed\["data"] or parsed\["rows"]                        |
| Config needed                           | ELASTICSEARCH\_URL, ELASTICSEARCH\_USER, <br />ELASTICSEARCH\_PASSWORD | KAIF\_HOST (+ optional BRIDGE\_MCP\_SERVER\_URL override) |
| Time ranges                             | now-1d in ES DSL                                                       | CURRENT\_TIMESTAMP - INTERVAL '1' DAY                     |

**Before (Elasticsearch):**

Agent → ES HTTP API → Elasticsearch Index → JSON hits

**After (Bridge MCP):**

Agent → MCPClient → Bridge MCP Server → Trino SQL → JSON rows

**Key differences:**

- No more ES credentials — authentication is handled via agent\_payload and the SDK TokenService
- SQL instead of JSON DSL — write Trino SQL instead of ES bool/match/range
- MCP tools instead of HTTP — call bridge\_execute\_query through MCPClient
