Retrieve SQL metadata endpoint
- Last Updated: December 3, 2026
- 3 minute read
- Documentation
The GET /v1/retrieve/sql/metadata endpoint returns the SQL catalog metadata that the calling user can see. Use it to discover valid schema, table, column, and collection names before you submit a query to the Retrieve SQL endpoint.
Overview
The endpoint runs a fixed set of catalog queries in the security context of the calling user. So, two users can receive different catalog contents.
The response includes these catalogs:
- Schemas
- Tables and views
- Columns
- Functions
- Collations
- Collection URIs
The endpoint requires the mra-sql role.
Basic usage
This example requests the SQL metadata:
curl -X GET http://localhost:8003/v1/retrieve/sql/metadata \
--digest -u <username>:<password>
A HEAD request to the same path checks whether the endpoint is available.
Request parameters
This endpoint does not accept any parameters.
Response format
Success response
HTTP status: 200 OK
This table describes the fields in the response:
| Field | Type | Description |
|---|---|---|
schemas |
array | Rows from sys_schemas |
tables |
array | Rows from sys_tables |
columns |
array | Rows from sys_columns |
functions |
array | Rows from sys_functions |
collations |
array | Rows from sys_collations |
collections |
array | Distinct collection URIs from sys_collections |
truncated |
object | Present only when at least one array was capped. Maps the name of each capped array to true |
totalRows |
object | Present only with truncated. Maps the name of each capped array to its total row count before truncation |
This example shows the structure of a response:
{
"schemas": [ { "...": "..." } ],
"tables": [ { "...": "..." } ],
"columns": [ { "...": "..." } ],
"functions": [ { "...": "..." } ],
"collations": [ { "...": "..." } ],
"collections": [ { "uri": "..." } ]
}
The fields in the rows of schemas, tables, columns, functions, and collations depend on your MarkLogic Server catalog and on the permissions of the caller.
Row limit and truncation
Each array holds at most sqlMetadataMaxRows rows. The default is 500. You can change the limit in retrieveConfig.json.
When an array exceeds the limit, the endpoint returns only the number of rows specified in sqlMetadataMaxRows and adds an entry for that array to the truncated object with the value true. This example shows a response in which only the columns array was capped:
{
"truncated": { "columns": true },
"totalRows": { "columns": 1240 }
}
A truncated array still lists real names that you can query. It is not exhaustive. The endpoint does not support pagination or a filter parameter.
Error responses
Error responses that the endpoint formats use this format:
{
"errorResponse": {
"statusCode": 400,
"status": "Bad Request",
"message": "Invalid parameter format"
}
}
Authentication and MarkLogic Server-level failures can use the MarkLogic Server error format instead.
This table lists the status codes that this endpoint returns:
| Status | Meaning |
|---|---|
401 |
Authentication is required. |
403 |
The caller does not have the mra-sql role. |
404 |
The caller has no MarkLogic Retrieval API (MRA) role that permits running the endpoint module, or MRA is not deployed. |
405 |
The HTTP method is not allowed. |
500 |
A MarkLogic Server error occurred. |
See SQL tool issues in "Troubleshoot MarkLogic MCP Server" for remedies.
Caching in MarkLogic MCP Server
The RetrieveSQLMetadata tool in MarkLogic MCP Server caches this response for 300 seconds by default. The cache is in memory and organized by MarkLogic Server URL, with trailing slashes removed, and by a principal derived from the credentials. Metadata for one URL or credential set is never reused for another. When the cache is full, then MarkLogic MCP Server evicts the least recently used entry.
Changes to the catalog or to permissions, such as a new TDE view, might not appear in the tool response until the cache expires. After the cache expires, the next call fetches fresh data. Restarting MarkLogic MCP Server also clears the cache.