Migration guide
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
- Step 1: Identify your domain and table: Check which domain and table in Bridge corresponds to your ES index. See step 1
- Step 2: Get column schema
- Step 3: Convert ES queries to Trino DSQL
- Step 4: Use MCPClient in code
- Step 5: Parse response
ES → Trino SQL conversion cheatsheet
ES concept | Trino SQL equivalent |
|---|---|
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.
What changed (before vs after)
Aspect | Before (ES) | After (Bridge MCP) |
|---|---|---|
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, 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