Powered by Zoomin Software. For more details please contactZoomin

MarkLogic MCP Server

Tool contracts

  • Last Updated: December 3, 2026
  • 5 minute read
    • Documentation

Input and output contracts for the passthrough tools are exposed by MarkLogic MCP Server. These tools forward requests to MarkLogic Retrieval API (MRA) and return the endpoint response with minimal transformation.

Overview

MarkLogic MCP Server exposes these tools:

Tool Internal module id Required argument Purpose
RetrieveDefinition retrieve-definition none Return the current /v1/retrieve/definition payload.
Retrieve retrieve retrieveQuery Run /v1/retrieve with a JSON request body.
Augment augment augmentRequest Run /v1/retrieve/augment with a JSON request body.
RetrieveSQLMetadata retrieve-sql-metadata none Return the SQL catalog metadata from /v1/retrieve/sql/metadata.
RetrieveSQLResult retrieve-sql-result sqlQuery Run one read-only SQL query through /v1/retrieve/sql.
RetrieveSparqlMetadata retrieve-sparql-metadata none Return SPARQL prefixes and visible graph IRIs from /v1/retrieve/sparql/metadata.
RetrieveSparqlResult retrieve-sparql-result sparqlQuery Run one read-only SPARQL SELECT or ASK query through /v1/retrieve/sparql.

General contract

  • Missing required arguments return a tool error without calling MarkLogic Server.
  • MarkLogic Server errors are surfaced to the caller as tool errors.
  • Successful calls return a single text chunk with pretty-printed JSON from the underlying endpoint.

RetrieveDefinition

Purpose: Fetch the current search configuration for the deployment.

Arguments: none

Returns: the JSON payload returned by GET /v1/retrieve/definition.

Typical fields in the response include:

  • description
  • labels
  • filters
  • documentSchemas
  • vectorMetadata
  • metadataFields
  • recommendedWorkflow
  • queryFormat

Example

RetrieveDefinition()

Retrieve

Purpose: Run hybrid search against /v1/retrieve.

Required argument: retrieveQuery

retrieveQuery must be a JSON string representing the request body sent to /v1/retrieve.

Canonical request fields include:

  • text
  • labels
  • filters
  • vectors
  • metadata
  • entities
  • relations
  • topk

Example

{
  "retrieveQuery": "{\"text\":\"diabetes OR insulin\",\"topk\":10}"
}

Returns: the JSON payload returned by POST /v1/retrieve, typically including:

  • matches
  • totalMatches when text search is used
  • warnings when the request triggers non-fatal issues
  • mcpWarnings when MCP-side processing adds structured warnings

Augment

Purpose: Retrieve full document content by URI from /v1/retrieve/augment.

Required argument: augmentRequest

augmentRequest must be a JSON string representing the request body sent to /v1/retrieve/augment. The canonical field name is URIs (uppercase), though the agent normalizes lowercase uris to URIs before calling MarkLogic Server.

Canonical request fields include:

  • URIs โ€” array of URI strings or {uri, xpath} objects
  • metadata โ€” optional array containing metadata, processingMetadata, and/or provenance

Example

{
  "augmentRequest": "{\"URIs\":[\"/medical/doc001.json\"]}"
}

Returns: the JSON payload returned by POST /v1/retrieve/augment, typically including:

  • documents
  • uri
  • document
  • metadata when requested
  • processingMetadata when requested
  • provenance when requested

RetrieveSQLMetadata

Purpose: Discover the SQL schemas, tables and views, columns, functions, collations, and collection URIs that the connected user can query. Call this tool before RetrieveSQLResult so that queries use names that exist.

Arguments: none

Returns: the JSON payload returned by GET /v1/retrieve/sql/metadata, including:

  • schemas
  • tables
  • columns
  • functions
  • collations
  • collections
  • truncated when at least one array was capped
  • totalRows when at least one array was capped

Each array holds at most sqlMetadataMaxRows entries (default 500). This default can be changed in retrieveConfig.json.

MarkLogic MCP Server caches the response for 300 seconds by default, organized by MarkLogic Server URL and principal. This default can be changed through environment variables.

Example

RetrieveSQLMetadata()

RetrieveSQLResult

Purpose: Run one read-only SQL query through /v1/retrieve/sql.

Required argument: sqlQuery

sqlQuery must be a single read-only SQL statement as plain text. Do not wrap it in JSON, quotation marks, or code fences. The agent sends it to MarkLogic Server as {"query": "<sqlQuery>"}.

The query must meet these requirements:

  • Start with SELECT or WITH
  • Contain one statement, with no semicolon outside quoted text, including a trailing semicolon
  • Contain no SQL comments (-- or /* */)
  • Contain no write or administrative keywords, even inside a string literal: INSERT, UPDATE, DELETE, MERGE, UPSERT, CREATE, DROP, ALTER, TRUNCATE, GRANT, or REVOKE
  • Contain no script-injection content, such as javascript, xquery, xdmp:, fn:, eval(, or invoke(
  • Select columns with unique names; use AS aliases when joined tables share column names
  • Contain 10,000 characters or fewer

Examples

A correct query:

{
  "sqlQuery": "SELECT name FROM sys_tables ORDER BY name"
}

An incorrect query, which MarkLogic Server rejects because it has two statements and a write keyword:

{
  "sqlQuery": "SELECT name FROM sys_tables; DELETE FROM sys_tables"
}

Returns: the JSON payload returned by POST /v1/retrieve/sql, including:

  • columns
  • rows
  • rowCount
  • maxRows
  • truncated when the result was capped at maxRows

The query runs in the security context of the calling user, so the result contains only the data that that user is authorized to see.

How the SQL tools work together is explained in SQL workflow.

RetrieveSparqlMetadata

Purpose: Discover namespace prefixes, the default graph IRI, and named graph IRIs visible to the connected identity.

Arguments: none

Returns: the JSON payload returned by GET /v1/retrieve/sparql/metadata, including:

  • prefixes
  • graphs.defaultGraph
  • graphs.namedGraphs
  • truncated and totalRows when a metadata list is capped

Each of prefixes and graphs.namedGraphs is capped independently by sparqlMetadataMaxRows (default 500). Configure the limit in retrieveConfig.json.

MarkLogic MCP Server caches the metadata response for 300 seconds by default, organized by MarkLogic Server URL and principal. Configure the cache through environment variables.

Example

RetrieveSparqlMetadata()

RetrieveSparqlResult

Purpose: Run one read-only SPARQL SELECT or ASK query through /v1/retrieve/sparql.

Required argument: sparqlQuery

sparqlQuery must contain one complete SPARQL query as plain text. The tool does not take a JSON string or code block. It accepts SELECT and ASK, optionally preceded by PREFIX or BASE. Use FROM or GRAPH to scope graphs within the query.

The endpoint rejects empty or malformed queries, multiple queries, extra REST body fields, CONSTRUCT, DESCRIBE, and SPARQL Update forms. A valid semicolon within SPARQL syntax is accepted; do not add a trailing statement terminator.

Example

{
  "sparqlQuery": "SELECT (1 AS ?one) WHERE {}"
}

Returns: the JSON payload returned by POST /v1/retrieve/sparql, including head and results.bindings for SELECT. The response includes maxRows; it includes truncated: true only when an additional solution exists beyond the row cap. An ASK response contains head and a boolean boolean field, without maxRows or truncated.

Queries run in the security context of the calling user, so results contain only data that identity can read.

How the SPARQL tools work together is explained in SPARQL workflow.

Error behavior

The tools follow a fail-fast contract:

  • Missing retrieveQuery or augmentRequest returns a descriptive tool error.
  • A missing or blank sqlQuery returns the tool error Error: sqlQuery parameter is required. without calling MarkLogic Server.
  • A missing or blank sparqlQuery returns a tool error without calling MarkLogic Server.
  • Invalid JSON in either argument returns a descriptive tool error.
  • A malformed or unsupported SPARQL query returns a tool error. A 403 response means the caller lacks the SPARQL privilege required by the endpoint.
  • HTTP failures from MarkLogic Server are returned as tool errors with the underlying message. For SQL, a 400 response means the query is invalid or unsupported, and a 403 response means the caller lacks the mra-sql role. The SQL tools can return only the HTTP status without the errorResponse.message text. To see the detailed message, send the same request directly to the SQL endpoint.
  • The agent layer does not silently rewrite request bodies, except for the uris โ†’ URIs normalization in Augment.
Alert