You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by "MisterRaindrop (via GitHub)" <gi...@apache.org> on 2026/10/16 07:40:28 UTC
[PR] mcp-server: read Lance foreign tables and bound query results [cloudberry]
MisterRaindrop opened a new pull request, #2144:
URL: https://github.com/apache/cloudberry/pull/2144
Part of #2139 (1 of 2 for mcp-server).
### What does this PR do?
Lets an agent read `lance_fdw` foreign tables through cbmcp, and bounds what
any query returns.
- **Finding Lance tables.** `list_tables` lists foreign tables (`table_type`
narrows to `base` or `foreign`); `list_columns` gives the declared type, such
as `real[]`; `get_table_ddl` builds the columns from `pg_attribute` and shows
a foreign table's server and options. Option values are shown only where they
are known to hold no secret (lance_fdw's own table options); every other
wrapper's option value is `<redacted>`, and user mappings are never read.
- **Values.** bytea, composites (a Lance struct), ranges, bit strings, paths and
float NaN/Infinity now come back in a JSON form instead of failing the call
or turning into null.
- **Bounds.** `execute_query` reads through a cursor and stops at
`MCP_MAX_ROWS` (default 1000), cuts values past `MCP_MAX_VALUE_LENGTH`
(default 10000) and stops adding rows at `MCP_MAX_RESULT_BYTES` (default
1000000) of JSON; `truncated_by` says which limit applied.
- **Vector search.** `vector_search` accepts a `real[]` column of a `lance_fdw`
table using the `<->`, `<=>` and `<#>` operators lance_fdw defines, and
lance_fdw pushes the filter and the search into Lance.
`list_searchable_columns` reports such columns.
- **Timeouts.** `MCP_QUERY_TIMEOUT` (default 60 s) is configurable, and a query
that hits it says so instead of returning an empty error.
### Type of Change
- [x] New feature (non-breaking change)
### Test Plan
- [x] Unit tests added/updated
- [x] Integration tests added/updated (`test_result_values.py`, `test_lance_tools.py`)
- Full mcp-server suite on a three-segment demo cluster: 216 passed, 45 skipped
(the skips need pgvector or lance_fdw, which that cluster lacks).
- `test_lance_tools.py` against the `contrib/lance_fdw` of #2143, with
`optimizer = off`: 29 passed.
### Impact
**User-facing changes:** `execute_query` results are now capped by the three
limits above: a query returning more than 1000 rows, or values longer than
10000 characters, now comes back truncated, and the result says so and which
limit applied. The limits are settings. The README documents the limits, the
redaction, and that a read-only transaction does not stop every side effect.
**Dependencies:** none. Reading Lance tables needs `lance_fdw` (#2140);
vector search on them needs its distance operators (#2142).
### Checklist
- [ ] Followed [contribution guide](https://cloudberry.apache.org/contribute/code)
- [x] Added/updated documentation (mcp-server/README.md, mcp-server/tests/README.md)
- [x] Reviewed code for security implications (credential redaction in `get_table_ddl`, result bounds)
- [x] This PR contains AI-assisted code generation
- [ ] Requested review from [cloudberry committers](https://github.com/orgs/apache/teams/cloudberry-committers)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org