Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MCP Tools Reference

The laurus MCP server exposes the following tools.

An argument a tool does not take, such as a misspelled "dryrun" for dry_run, is a tool error that names it, such as failed to deserialize parameters: unknown field `dryrun` ..., and the tool does nothing (Issue #1707). A tool that takes no arguments rejects any. The JSON inside fusion, field_boosts, highlight, rescore and group_by is read the way the HTTP gateway reads a request body, so a key that fusion (with its rrf and weighted_sum), highlight, rescore (with its late_interaction) or group_by does not take is a tool error that names it, such as Invalid highlight JSON: unknown key "tags" in highlight (expected "fields", ...), and the tool does nothing (Issue #1706). A key set to null is the same as one left out, so it is not reported. The keys of field_boosts are field names.

connect

Connect to a running laurus-server gRPC endpoint. Call this before using other tools if the server was started without the --endpoint flag, or to switch to a different laurus-server at runtime.

Parameters

NameTypeRequiredDescription
endpointstringYesgRPC endpoint URL (e.g. http://localhost:50051)

Example

Tool: connect
endpoint: "http://localhost:50051"

Result: Connected to laurus-server at http://localhost:50051.


create_index

Create a new search index with the provided schema.

Parameters

NameTypeRequiredDescription
schema_jsonstringYesSchema definition as a JSON string

Schema JSON format

FieldOption uses serde’s externally-tagged representation where the variant name is the key:

{
  "dynamic_field_policy": "Dynamic",
  "fields": {
    "title":     { "Text":    { "indexed": true, "stored": true } },
    "body":      { "Text":    {} },
    "score":     { "Float":   {} },
    "count":     { "Integer": {} },
    "active":    { "Boolean": {} },
    "created":   { "DateTime": {} },
    "embedding": { "Hnsw":    { "dimension": 384 } }
  }
}

The optional dynamic_field_policy key controls how fields that appear in ingested documents but are absent from the schema are handled. Accepted values: "Strict", "Dynamic" (default), "Ignore". Warning: under "Dynamic", integer fields silently truncate incoming float values (3.14 → 3); use "Strict" to reject such mismatches. See Schema & Fields for the full behaviour matrix.

The JSON is read by the types schema.toml is read by, so a key that a table does not declare, such as a misspelled "indexd", is an error that names the key, as in Failed to parse schema JSON: unknown field `indexd` ..., and no index is created (Issue #1700). The same holds for the field_option_json of add_field and update_field.

Example

Tool: create_index
schema_json: {"fields": {"title": {"Text": {}}, "body": {"Text": {}}}}

Result: Index created successfully at /path/to/index.

A schema with a Geo3d field for 3D ECEF positions:

{
  "fields": {
    "title":    { "Text":  { "indexed": true, "stored": true } },
    "position": { "Geo3d": { "indexed": true, "stored": true } }
  }
}

See 3D Geographic Search (ECEF) for the coordinate system; Geo3d is queryable via the geo3d_distance / geo3d_bbox / geo3d_nearest / geo3d_polyline DSL forms (see the search tool below).


add_field

Add a new field to the index.

Parameters

NameTypeRequiredDescription
namestringYesThe field name
field_option_jsonstringYesField configuration as JSON

Example

{
  "name": "category",
  "field_option_json": "{\"Text\": {\"indexed\": true, \"stored\": true}}"
}

Result: {"fields":["title","category","embedding"],"message":"Field 'category' added successfully."}

fields lists the field names of the schema after the change, in no particular order.


delete_field

Remove a field from the index schema. A lexical field’s data is discarded from every segment, which takes time in proportion to the index. A vector field’s files stay until a field with the same name is added again. Per-field analyzers and embedders are unregistered. A field added again with the same name starts empty (see Removing a Field).

Parameters

NameTypeRequiredDescription
namestringYesThe name of the field to remove

Example

{
  "name": "category"
}

Result: {"fields":["embedding","title"],"message":"Field 'category' deleted successfully."}


update_field

Change an existing field’s type or options. The change is classified as metadata_only (no existing data is affected; always applied), reindex (the field is rebuilt from the data already in the index) or destructive (the field’s existing data is discarded); see Changing a Field for the rules. A reindex or destructive change is rejected unless reindex is true.

Parameters

NameTypeRequiredDescription
namestringYesThe field to change; it must already exist
field_option_jsonstringYesThe field’s new configuration as JSON, in the same format as add_field
reindexbooleanNoApply a reindex or destructive change (default: false)
dry_runbooleanNoClassify the change without applying anything (default: false)

field_option_json replaces the field’s whole option: a key left out gets its default value, not the field’s current one. For an Hnsw, Flat or MultiVector field this includes dimension, which defaults to 128.

Example

For an embedding field created as {"Hnsw": {"dimension": 384}}:

{
  "name": "embedding",
  "field_option_json": "{\"Hnsw\": {\"dimension\": 384, \"m\": 32}}",
  "dry_run": true
}

Result: {"classification":"reindex","fields":["title","embedding"],"message":"Dry run: change to field 'embedding' classified."}

The same call without dry_run is a tool error, because the change needs reindex:

Failed to update field: code: 'Client specified an invalid argument', message: "Invalid argument: updating field 'embedding' requires rebuilding or discarding existing data (classified as Reindex); enable `reindex` to proceed"

With "reindex": true in place of "dry_run": true, the change is applied:

Result: {"classification":"reindex","fields":["title","embedding"],"message":"Field 'embedding' updated successfully."}

The result lists the field names, not the schema; call get_schema to see the field’s new option.


get_stats

Get statistics for the current search index, including document count and vector field information.

Parameters

None.

Result

{
  "document_count": 42,
  "vector_fields": {
    "embedding": {
      "vector_count": 42,
      "dimension": 384
    }
  }
}

vector_fields is a map keyed by field name; each entry reports the number of indexed vectors and the field’s configured dimension.


get_schema

Get the current index schema, including all field definitions and their configurations.

Parameters

None.

Result

{
  "fields": {
    "title": { "Text": { "indexed": true, "stored": true } },
    "body": { "Text": {} },
    "embedding": { "Hnsw": { "dimension": 384 } }
  },
  "default_fields": ["title", "body"]
}

put_document

Put (upsert) a document into the index. If a document with the same ID already exists, all its chunks are deleted before the new document is indexed. Call commit after adding documents.

Parameters

NameTypeRequiredDescription
idstringYesExternal document identifier
fieldsobjectYesDocument fields as a JSON object

Example

Tool: put_document
id: "doc-1"
fields: {"title": "Hello World", "body": "This is a test document."}

Result: Document 'doc-1' put (upserted). Call commit to persist changes.

Example with a Geo3d value:

Tool: put_document
id: "drone-1"
fields: {"title": "Drone over Tokyo", "position": {"x": -3955182.0, "y": 3350553.0, "z": 3700276.0}}

The MCP server accepts a 3D ECEF point as a JSON object with x, y, z keys (meters) — the same shape the HTTP gateway and laurus-cli accept (see JSON Field Value Inference).


add_document

Add a document as a new chunk to the index. Unlike put_document, this appends without deleting existing documents with the same ID. Useful for splitting large documents into chunks. Call commit after adding documents.

Parameters

NameTypeRequiredDescription
idstringYesExternal document identifier
fieldsobjectYesDocument fields as a JSON object

Example

Tool: add_document
id: "doc-1"
fields: {"title": "Hello World - Part 2", "body": "This is a continuation."}

Result: Document 'doc-1' added as chunk. Call commit to persist changes.


put_documents

Put (upsert) many documents in one call. Entries are applied sequentially, in input order, with one WAL fsync for the whole batch — much faster than calling put_document per document. Duplicate IDs within one batch dedup (the last occurrence wins). Call commit afterwards.

Parameters

NameTypeRequiredDescription
documentsarrayYesArray of {"id": "...", "fields": {...}} entries; each entry’s fields has the same shape as put_document’s

Example

Tool: put_documents
documents: [
  {"id": "doc-1", "fields": {"title": "Hello"}},
  {"id": "doc-2", "fields": {"title": "World"}}
]

Result: 2 documents put (upserted). Call commit to persist changes.

A failure aborts at the offending entry without rolling back the already-applied prefix, so retrying the batch (or its suffix) is idempotent.


add_documents

Add many documents as new chunks in one call. Unlike put_documents, existing documents are never deleted, so repeating an ID adds multiple chunks of the same logical document. One WAL fsync covers the whole batch. Call commit afterwards.

Parameters

Same as put_documents.

Example

Tool: add_documents
documents: [
  {"id": "doc-1", "fields": {"title": "Part 1"}},
  {"id": "doc-1", "fields": {"title": "Part 2"}}
]

Result: 2 documents added as chunks. Call commit to persist changes.


get_documents

Retrieve all stored documents (including chunks) by external ID.

Parameters

NameTypeRequiredDescription
idstringYesExternal document identifier

Result

{
  "id": "doc-1",
  "documents": [
    { "fields": { "title": "Hello World", "body": "This is a test document." } }
  ]
}

delete_documents

Delete all documents and chunks sharing the given external ID from the index. Call commit after deletion.

Parameters

NameTypeRequiredDescription
idstringYesExternal document identifier

Result: Documents 'doc-1' deleted. Call commit to persist changes.


commit

Commit pending changes to disk. Must be called after put_document, add_document, or delete_documents to make changes searchable and durable.

Parameters

None.

Result: Changes committed successfully.


Search documents using the laurus unified query DSL. Supports lexical search, vector search, and hybrid search in a single query string.

Parameters

NameTypeRequiredDescription
querystringYesSearch query in laurus unified query DSL
limitintegerNoMaximum results (default: 10). offset + limit must not exceed the server’s max_result_window (default 10,000)
offsetintegerNoResults to skip for pagination (default: 0)
fusionstringNoFusion algorithm as JSON (for hybrid search; see Value types)
field_boostsstringNoPer-field boost factors as JSON (see Value types)
highlightstringNoHighlighted fragments per field, as JSON (see Highlight example and Value types)
rescorestringNoLate-interaction rescore of the top results, as JSON (see Rescore example)
group_bystringNoGroup the results by a field’s value, as JSON; limit and offset then count groups (see Group by example)
track_total_hitsinteger or booleanNoCount the matching documents and return the count as total_hits: an integer n counts exactly up to n matches, true every match, and false (the default) none. A value, not a JSON string (see Total hits example)

Query DSL examples

QueryDescription
helloTerm search across default fields
title:helloField-scoped term search
title:hello AND body:worldBoolean AND
"exact phrase"Phrase search
roam~2Fuzzy search (edit distance 2)
count:[1 TO 10]Range search
title:helo~1Fuzzy field search
QueryDescription
position:geo3d_distance(x, y, z, distance_m)Sphere with center (x, y, z) and maximum distance in meters
position:geo3d_bbox(min_x, min_y, min_z, max_x, max_y, max_z)3D axis-aligned bounding box
position:geo3d_nearest(x, y, z, k)k nearest neighbors to (x, y, z)
position:geo3d_polyline((x, y, z, ...), distance_m)Within distance_m meters of the straight segments through the vertices (x, y, z), in order

position is the field name; substitute the actual Geo3d-typed field declared in your schema. See Query DSL → 3D Geographic Queries for the full DSL syntax.

QueryDescription
content:"cute kitten"Vector search on a field (field must be a vector field in schema)
content:pythonVector search with unquoted text
content:"cute kitten"^0.8Vector search with weight/boost
a:"cats" b:"dogs"^0.5Multiple vector queries

A weight (^) too large for a 32-bit float is an error, returned before any clause is embedded (Issue #1552).

QueryDescription
title:hello content:"cute kitten"Lexical + vector (OR/union — results from either)
title:hello +content:"cute kitten"Lexical + vector (AND/intersection — only results in both)
+title:hello +content:"cute kitten"Both required (AND); + on lexical field = required clause
title:hello AND body:world content:"cats"^0.8Boolean lexical + weighted vector

Fusion algorithm examples

{"rrf": {"k": 60.0}}
{"weighted_sum": {"lexical_weight": 0.7, "vector_weight": 0.3}}

k must be at least 0, and each weight between 0 and 1 with at least one greater than 0. The server rejects any other value, and the tool returns its error (Issue #1540).

Field boosts example

{"title": 2.0, "body": 1.0}

Each boost must be at least 0 (-0 is rejected). The server rejects any other boost, and the tool returns its error (Issue #1540).

Highlight example

highlight requests highlighted fragments per field (Issue #1134), following this tool’s lexical query — a vector-only query produces no highlights, and only stored: true text fields can be highlighted. The shorthand form is just a field list:

["body"]

The full object form adds HighlightConfig knobs — max_fragments, fragment_size, tag, css_class, require_field_match, max_analyzed_chars, return_entire_field_if_no_highlight:

{"fields": ["body"], "max_fragments": 2, "tag": "em"}

Value types

fusion, field_boosts and highlight take the same JSON as in the HTTP gateway’s search (Issue #1523):

  • fusion takes exactly one of rrf ({"k": 60}) and weighted_sum ({"lexical_weight": 0.5, "vector_weight": 0.5}), each an object whose numbers default to the values shown.
  • Each boost of field_boosts is a number.
  • In highlight, the field names are strings, max_fragments and fragment_size integers between 0 and 4294967295, max_analyzed_chars an integer between 0 and 18446744073709551615, require_field_match and return_entire_field_if_no_highlight true or false, and tag and css_class strings.

null is the same as omitting a key. To leave out a whole parameter, omit it: the string null is a tool error, while the HTTP gateway reads a null fusion, field_boosts or highlight as omitted. A value of another type, or an integer out of its range, is a tool error naming the key, and nothing is searched. For example, the highlight {"fields": ["body"], "max_fragments": "1"} returns:

Invalid highlight JSON: highlight: max_fragments must be an integer between 0 and 4294967295

A laurus-mcp older than this fix read such a value as omitted, so {"rrf": {"k": "1"}} used k 60 and {"title": "2"} boosted nothing. It also dropped a field name that was not a string, wrapped a max_fragments or fragment_size above 4294967295 (4294967297 became 1), and used rrf when both algorithms were set.

Unlike the HTTP gateway, a highlight must name at least one field: [], {} and {"fields": []} are a tool error, not a request for no highlighting.

Rescore example

rescore reorders the top window_size results (default 100) with late interaction over a MultiVector field (Issue #1351). A rescored result’s score is its late-interaction (MaxSim) score. The query is text, embedded by the field’s token-level embedder (a candle_colbert one):

{"late_interaction": {"field": "body_colbert", "text": "how do lifetimes work"}}

or the query’s token vectors:

{"window_size": 50, "late_interaction": {"field": "body_colbert", "vectors": [[0.1, 0.2], [0.3, 0.4]]}}

A malformed rescore is a tool error. search_batch has no rescore parameter. See Late-Interaction Rescore.

Group by example

group_by groups the results by a field’s value (Issue #1297): each result is a group’s best hit, its inner_hits hold the group’s next best hits, and its group_key the shared value. Chunks added under one id share _id, so grouping by it returns each document once, with up to group_size - 1 more of its chunks (group_size defaults to 1, at most 100):

{"field": "_id", "group_size": 2}

With three chunks added as manual and one as faq, the query body:rust returns:

{"results":[{"fields":{"body":"Rust ownership rules for Rust programs"},"group_key":"manual","id":"manual","inner_hits":[{"fields":{"body":"Borrowing in Rust"},"group_key":"manual","id":"manual","score":0.012359549291431904}],"score":0.012571428902447224},{"fields":{"body":"Why Rust has no garbage collector"},"group_key":"faq","id":"faq","score":0.010891089215874672}]}

The field may also be a single-valued, stored Text, Integer, Float, Boolean or DateTime field. A malformed group_by is a tool error. See Result Grouping.

Total hits example

track_total_hits counts the matching documents beyond the page (Issue #1472), with the values of the HTTP gateway’s track_total_hits: an integer n counts exactly up to n matches, true every match, and false, as without it, none. Unlike fusion or group_by, it is a JSON value, not a string. The result then gains "total_hits", whose "relation" is "eq" for an exact count and "gte" for a lower bound. With the four chunks of the group by example, three of which contain “rust”, {"query": "body:rust", "limit": 1, "track_total_hits": 2} returns:

{"results":[{"fields":{"body":"Rust ownership rules for Rust programs"},"id":"manual","score":0.012571428902447224}],"total_hits":{"relation":"gte","value":2}}

With true, the total is {"relation":"eq","value":3}. Counting has a cost, so ask for no more than you need; what the total counts for a vector, hybrid or grouped search is described in Total hits. A value other than an integer or a boolean, such as "1000", is a tool error:

track_total_hits must be true, false or an integer between 0 and 18446744073709551615

Result

Each result gains a "highlights" object when highlight was requested and at least one field actually highlighted, and the object gains "total_hits" when track_total_hits asked for it:

{
  "results": [
    {
      "id": "doc-1",
      "score": 3.14,
      "fields": { "title": "Hello World", "body": "..." },
      "highlights": { "body": ["<em>Hello</em> World"] }
    },
    {
      "id": "doc-2",
      "score": 1.57,
      "fields": { "title": "Hello Again", "body": "..." }
    }
  ]
}

search_batch

Execute multiple independent searches in a single round trip. All queries run in parallel on the server; the same limit, offset, highlight, group_by and track_total_hits apply to every query. Useful for agents issuing several sub-queries per turn.

Parameters

NameTypeRequiredDescription
queriesarray of stringYesQuery strings, each in the laurus unified query DSL (same syntax as search)
limitintegerNoMaximum results per query (default: 10). offset + limit must not exceed the server’s max_result_window (default 10,000)
offsetintegerNoResults to skip per query for pagination (default: 0)
highlightstringNoHighlighted fragments per field, as JSON — same format and value types as search’s highlight, applied identically to every query
group_bystringNoGroup each query’s results by a field’s value, as JSON — same format as search’s group_by, applied identically to every query
track_total_hitsinteger or booleanNoCount each query’s matching documents — same values as search’s track_total_hits, applied identically to every query

Result

The batch array preserves input order: batch[i] is the result set for queries[i]. With track_total_hits, each entry has its own "total_hits"; for ["body:rust", "body:garbage"] over the chunks of the group by example, with "limit": 1 and "track_total_hits": true:

{"batch":[{"results":[{"fields":{"body":"Rust ownership rules for Rust programs"},"id":"manual","score":0.012571428902447224}],"total_hits":{"relation":"eq","value":3}},{"results":[{"fields":{"body":"Why Rust has no garbage collector"},"id":"faq","score":0.9227996468544006}],"total_hits":{"relation":"eq","value":1}}]}

Without it:

{
  "batch": [
    {
      "results": [
        { "id": "doc-1", "score": 3.14, "fields": { "title": "Hello World" } }
      ]
    },
    {
      "results": [
        { "id": "doc-2", "score": 2.71, "fields": { "title": "Vector Search" } }
      ]
    }
  ]
}

A query the server rejects fails the whole batch, and the tool error names it by its position in queries, as the server’s SearchBatch does (Issue #1553). For ["body:rust", "nosuch:rust"]:

Batch search failed: code: 'Client specified an invalid argument', message: "queries[1]: Invalid argument: query references unknown field(s) [\"nosuch\"]; declare them in the schema or check for typos"

Typical Workflow

1. connect          → connect to a running laurus-server
2. create_index     → define the schema (if index does not exist)
3. add_field        → dynamically add fields (optional)
   delete_field     → remove fields (optional)
4. put_document     → upsert documents (repeat as needed)
   add_document     → append document chunks (optional)
5. commit           → persist changes to disk
6. search           → query the index
7. get_documents    → retrieve documents by ID
8. delete_documents → remove documents
9. commit           → persist changes