Matrix

v0.2.13
io.github.matthiasnordwig/matrix-mcp Checked 4 days ago Published 1 day ago

Answer questions over large PDF folders up to 3x faster, with file and page citations.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_contexts

List all Matrix contexts (local document collections, e.g. regulations, legal norms, contracts, manuals). For each: id, name, the user's description of what the collection contains, document and chunk counts, chunking strategy, the bound embedding model (needed for semantic search) and the languages of its documents (ISO codes, most documents first). Start here, then search a context and fetch the cited chunks.

list_documents

List the documents (files) of one Matrix context: id, name, the optional per-file description, size, page count, number of chunks and language (ISO code). Does not return the document text — use the search and chunk tools for content.

ParameterTypeDescription
context_id *integerContext id from list_contexts.

job_status

Poll a long-running Matrix job (ingest, chunking, embedding, graph extraction …) started by another tool that returned a job_id. Returns state (running | done | failed), progress, result and error. Finished jobs stay pollable for about 10 minutes.

ParameterTypeDescription
job_id *stringThe job_id returned when the job was started.

search_context

Semantic + keyword (hybrid) search over the original text of one or more Matrix contexts — the default tool for finding passages in the user's documents (regulations, legal norms, contracts, standards, manuals). Returns numbered chunks with stable chunk_id, header (document · outline path, e.g. chapter › article › paragraph, where headings are recognised), file and page where known, text and outgoing references to other norms (with the resolved target chunk_id when known) — cite sources by chunk_id (and file/page for the user). In this program each hit is an excerpt of about 300 chara…

ParameterTypeDescription
context_ids *arrayContexts to search (ids from list_contexts).
query *stringNatural-language search query.
date_fromstringOptional: only documents dated on or after this day (mails: their own date), YYYY-MM-DD, YYYY-MM or YYYY; inclusive. Documents without a date are left out.
date_tostringOptional: only documents dated on or before this day (mails: their own date), YYYY-MM-DD, YYYY-MM or YYYY; inclusive. Documents without a date are left out.
detailstringsnippets: per hit only the excerpt that fits the query (about 300 characters) with file, page and outline path, hits of one article merged - far fewer tokens; read the full text with get_chunks / get_…
document_idsarrayOptional: restrict to these documents (ids from list_documents); they must belong to the given contexts.
folderstringOptional: only documents whose folder path in the collection contains this text, case-insensitive (e.g. "lay-k/sent"); "/inbox/" matches a whole folder name.
rerank_candidatesintegerHow many top hits the local reranker re-reads and puts first; further hits up to top_k follow in search order (default 20, max 200; only where a local reranker is active, i.e. the stand-alone plugin p…
senderstringOptional: only mails (and their attachments) whose sender (From: name or address) contains this text, case-insensitive. Other documents are left out.
top_kintegerHow many chunks to return (default: as many as fill one result, 15 whole passages with detail full or 85 snippets; at most 15 / 87).

lookup_exact

Exact-phrase keyword search over the original text. Use it instead of search_context for exact identifiers and citations that vector search blurs: legal norms and article numbers ('Art. 33', '§ 25a KWG', '2016/679'), defined terms, quotes. Terms must appear adjacent and in order. Same result format as search_context; works without an embedding model.

ParameterTypeDescription
context_ids *arrayContexts to search (ids from list_contexts).
term *stringExact phrase / identifier to look up.
date_fromstringOptional: only documents dated on or after this day (mails: their own date), YYYY-MM-DD, YYYY-MM or YYYY; inclusive. Documents without a date are left out.
date_tostringOptional: only documents dated on or before this day (mails: their own date), YYYY-MM-DD, YYYY-MM or YYYY; inclusive. Documents without a date are left out.
document_idsarrayOptional: restrict to these documents (ids from list_documents); they must belong to the given contexts.
folderstringOptional: only documents whose folder path in the collection contains this text, case-insensitive (e.g. "lay-k/sent"); "/inbox/" matches a whole folder name.
senderstringOptional: only mails (and their attachments) whose sender (From: name or address) contains this text, case-insensitive. Other documents are left out.

get_chunks

Fetch specific chunks by chunk_id to read the exact source text for a citation, or to follow an outgoing reference (resolved_chunk_id) from another chunk. A fragmented section/article is completed with up to two continuation chunks automatically. Ids outside the given contexts/documents are not returned (reported in missing_ids). A chunk that runs onto another PDF page has `page_end`, and its text marks each page change with a line [p. N]: cite the page of the sentence you quote (text before the first mark is on `page`).

ParameterTypeDescription
context_ids *arrayContexts to search (ids from list_contexts).
ids *arrayChunk ids to fetch.
document_idsarrayOptional: restrict to these documents (ids from list_documents); they must belong to the given contexts.

get_section

Fetch the whole article or section a chunk belongs to (the chunk's neighbours up to the next heading of the same or a higher rank, e.g. all of Art. 18 for a hit in Art. 18(1)), with full text, pages (page changes inside a chunk marked [p. N]) and the outline path. Use it before answering from a rule that may have exceptions, conditions or special cases in other paragraphs, instead of relying on the single hit. A long section is cut to about 12,000 characters around the chunk and the chunk_ids left out are listed (fetch them with get_chunks); without recognised headings only the chunk itself co…

ParameterTypeDescription
chunk_id *integerA chunk_id from a search result.
context_ids *arrayContexts to search (ids from list_contexts).
document_idsarrayOptional: restrict to these documents (ids from list_documents); they must belong to the given contexts.

find_citing_chunks

Reverse reference lookup: find chunks whose text CITES a given legal norm ('Art. 395 CRR', '§ 25a KWG', 'Art. 28 DORA') — useful when a provision applies to an entity via a reference or range list that neither search_context nor lookup_exact surfaces. Optional query soft-ranks many citing chunks by semantic similarity. Same result format as search_context.

ParameterTypeDescription
context_ids *arrayContexts to search (ids from list_contexts).
norm *stringA single citation, e.g. 'Art. 395 CRR' or '§ 25a KWG'.
document_idsarrayOptional: restrict to these documents (ids from list_documents); they must belong to the given contexts.
querystringOptional natural-language focus to soft-rank many citing chunks by.

list_norm_references

List the legal-norm references Matrix recognized in a context's text ('§ 25a KWG', 'Art. 28 DORA', 'AT 4.3 MaRisk' - normalized keys): without chunk_ids every referenced norm with how many chunks cite it and the first chunk ids, most cited first (an overview of what a collection depends on); with chunk_ids the references of exactly those chunks (follow a passage's cross-references, then lookup_exact or find_citing_chunks for the targets). contains filters the keys.

ParameterTypeDescription
context_id *integerContext id.
chunk_idsarrayOnly these chunks.
containsstringOnly keys containing this text (case-insensitive), e.g. 'KWG'.
limitintegerNorms listed without chunk_ids (1-500, default 100).

get_page_image

Return the stored image (JPEG) of one graphics page - an organigram, chart or diagram that Matrix keeps as a picture next to the document text - together with document name, page number and size. Use the `page_image_id` of a search hit (a chunk marked found_via_page_image) to look at the page that made it relevant, e.g. to read a figure the extracted text does not contain. Unknown id = error.

ParameterTypeDescription
page_image_id *integerThe page_image_id from a search_context / get_chunks hit.

get_status

Live status of Matrix' background work — chunking, embedding and knowledge-graph extraction progress (active, done/total, errors, current phase) — plus the most recent application log lines (errors, warnings, MCP calls). Use it to follow long-running ingestion or graph jobs and to diagnose failures; for one specific job use job_status. This program adds shared_folders (what Matrix may read, with problems such as a folder that does not exist), search_model (state of the search model and the date of its recommendation), model_task_queue (tasks waiting for you) and running_jobs.

ParameterTypeDescription
log_linesintegerHow many recent log lines to include (0-200, default 20).
min_levelstringLowest log level to include (default info).

verify_citations

Check the citations of YOUR OWN answer against the cited source chunks — Matrix' citation attribution check for answers about documents, regulations and legal norms. Pass the answer text and `chunk_ids`; mark every claim with [n] = n-th entry (1-based) of chunk_ids, or with [chunk:<id>] (the id is added to the list). Answers without markers are rejected. Also list the retrieved chunks you did NOT cite: they are the candidates a better source is searched among. Per citing statement and marker the verdict is `supported` (verbatim quote found, or the cited/co-cited chunk carries at least 30% of…

ParameterTypeDescription
answer *stringYour answer text with citation markers [n] or [chunk:<id>].
chunk_idsarrayChunk ids in marker order ([1] = first entry), plus uncited retrieved chunks as candidates. No duplicates. May be omitted when the answer only uses [chunk:<id>] markers.

list_sheet_tables

List the spreadsheet tables of the given contexts: every table region of an uploaded Excel/ODS/CSV file is also stored as an SQL table. Returns per table its SQL name, document, sheet, row count and columns (SQL name, original header, type, notes such as 'percent, stored as a fraction', an example value). Use the names with query_table to compute exact sums, counts, averages or rankings.

ParameterTypeDescription
context_ids *arrayContexts (ids from list_contexts).
document_idsarrayOptional: only the tables of these documents (ids from list_documents).

query_table

Run ONE read-only SQLite SELECT (WITH … SELECT allowed) over the spreadsheet tables of the given contexts (see list_sheet_tables) and get the result as CSV with a header line: exact aggregates (SUM, COUNT, AVG, MIN/MAX), filters, GROUP BY, window functions, date()/strftime(). Only those tables are readable; writes, PRAGMA, ATTACH and other tables are refused. At most 200 rows / 20,000 characters (truncation is reported), 2 s time limit.

ParameterTypeDescription
context_ids *arrayContexts (ids from list_contexts).
sql *stringOne SELECT statement.
document_idsarrayOptional: only the tables of these documents (ids from list_documents).

create_context

Create a new, empty Matrix context (a document collection) and pass chunking_strategy "structural": PDFs are split along their layout (articles, headings, tables), other formats (Word, Excel, text, HTML) by their headings, with no language model. The configured search model is bound automatically; if it still has to be downloaded the answer says so: call setup_embedding_model, the user approves that call. Next: add_files.

ParameterTypeDescription
name *stringUnique context name.
chunking_strategystringAlways "structural".
descriptionstringWhat the collection contains (shown to agents in list_contexts).

embed_context

Compute embedding vectors for a context's chunks with its bound embedding model, as a background job. By default only chunks without a vector are embedded (resume); reembed=true recomputes all vectors in place. Returns {job_id}; poll job_status. The context needs an embedding model (create_context / update_context).

ParameterTypeDescription
context_id *integerContext id from list_contexts.
reembedbooleanRecompute every vector (default false: only missing ones).

embed_page_images

Embed the stored graphics pages (charts, org charts, diagrams found while ingesting PDFs) of a context as image vectors, so text questions also find them (image search). Background job; by default only pages without a vector of the context's model, reembed=true recomputes all. Needs a local ONNX embedding model with a vision encoder; otherwise it fails with the reason. Returns {job_id}; poll job_status (result: total, embedded, failed). Status first: page_image_status.

ParameterTypeDescription
context_id *integerContext id from list_contexts.
reembedbooleanRecompute every page-image vector (default false: only missing ones).

cancel_page_image_embedding

Stop the running embed_page_images job (there is one at a time) after the page it is on; page vectors written so far are kept, embed_page_images continues with the missing ones later. Returns {cancel_requested}.

page_image_status

Graphics pages of a context for the image search: how many page images are stored (total), how many have a vector of the context's embedding model (embedded), and whether that model can embed images (vision_available).

ParameterTypeDescription
context_id *integerContext id from list_contexts.

set_document_description

Set (or clear with null/empty) the short description of one document. Agents see it in list_documents and use it to decide which files to search.

ParameterTypeDescription
document_id *integerDocument id from list_documents.
descriptionstring | nullWhat the document contains; null or empty clears it.

list_profiles

List Matrix profiles of one kind: chunking (LLM chunking prompt, window overlap), structural (regex patterns that split PDFs along headings/articles) or grid (grid question prompt and output format). Use an id with update_context to assign it to a context.

ParameterTypeDescription
kind *stringProfile kind.

create_profile

Create a new chunking, structural or grid profile. `profile` holds that kind's fields. chunking: name, prompt (must contain {{pre_chunk}}), overlap_ratio, max_signature_len, metadata_fields (JSON text), match_strategy (exact_forward|fuzzy), fuzzy_threshold. structural: name, min_chunk_chars, max_chunk_chars, patterns[{group_name, role, regex, flags, priority, label, sort_order}]. grid (a template = prompt + answer columns): name, system_prompt (the template's prompt, asked of every row), data_format (plain|json), json_schema ({mode: object|array, fields: [{key, type: string|number|integer|bool…

ParameterTypeDescription
kind *stringProfile kind.
profile *objectThe new profile's fields (see tool description).

update_profile

Change an existing chunking, structural or grid profile. Only the fields given in `profile` change (same field names as create_profile; for a structural profile `patterns`, if given, replaces the whole list). Contexts using the profile pick the change up on their next run. Returns the stored profile.

ParameterTypeDescription
kind *stringProfile kind.
profile *objectFields to change.
profile_id *integerId from list_profiles.

update_context

Change a Matrix context's name, description, structural profile (list_profiles, kind structural) or embed_images (embed graphics pages automatically after the text; needs a search model with an image encoder). Only the fields you pass change; null clears an assignment. To move a context to another search model use setup_embedding_model with reindex_contexts.

ParameterTypeDescription
context_id *integerContext id from list_contexts.
descriptionstring | null
embed_imagesbooleanEmbed graphics pages automatically after the text chunks (embedding job). Catch up any time with embed_page_images.
namestring
structural_profile_idinteger | nullStructural profile (structural strategy).

list_grid_profiles

List the grid profiles (the templates of the app's Tables page). A template is a prompt plus answer columns: id, name, the template's prompt (field system_prompt; it is the instruction asked of every row), output format (plain text, or JSON whose fields become the answer columns: mode object = one answer per row, array = several entries per row). Pick one as grid_profile_id for run_grid.

list_grid_runs

List earlier grid runs (newest first, at most 50): run_id, the question (prompt), when it last changed, and how it ran (model, tool_call_budget: 0 = classic, -1 = agentic until the row's context is full, > 0 = agentic with at most that many searches per row; template, context_mode; null for old runs). Read a run's table with grid_results.

run_grid

Ask the same question about many rows and collect the answers as a table (the app's Tables page) - e.g. 'which obligations does this paragraph impose?' for every chunk of a regulation. Rows are the passages of a collection (source_context_id: all its documents, or only document_ids; max_rows caps them) or texts you give (row_texts: one row per text, e.g. search hits you picked). A row sees its own text, and further evidence only from retrieval_context_ids (matching passages of those contexts, retrieved per row). Each row is answered by the LLM (by you, the calling agent: llm_tasks / llm_answer…

ParameterTypeDescription
document_idsarrayWith source_context_id: only chunks of these documents (list_documents). Omit it to use every document of the context.
follow_refsbooleanAlso follow outgoing norm references (default true).
grid_profile_idintegerTemplate (list_grid_profiles): prompt + answer columns. Default: the first template, as on the Tables page.
hybridbooleanVector + keyword retrieval (default true).
max_rowsintegerWith source_context_id: at most this many chunks (1-200, default 50).
promptstringThe question/instruction applied to every row. Omit it to use the template's prompt.
reasoningstringReasoning depth for models that support it (default off).
rerankbooleanRerank retrieved passages (default false).
retrieval_context_idsarrayContexts to retrieve supporting passages from for each row, as evidence for the answer (default: none, the row is answered from its own text).
retrieval_promptstringText put before the row text to form the retrieval query (default: the row text).
row_textsarrayRows = these texts (1-200), one row each, e.g. passages you picked from a search; every row sees its own text only (plus retrieval_context_ids, if given). To fill the rows from a whole collection use…
source_context_idintegerRows = the passages of this context, one row per passage. Exclusive with row_texts.
tool_call_budgetintegerLet the LLM search for itself with tools in every row: 0 = until the row's context window is nearly full (as the app does by default), any larger whole number = at most that many searches per row. Omi…
top_kintegerPassages retrieved per row (1-20, default 5).

grid_results

Read a grid run as a table: columns = row (chunk id) + status + the answer fields (JSON profiles; an answer with several items becomes several table rows) or a 'response' column (plain profiles), rows = the answers, cells shortened. Also reports the status counts and whether the run is finished. Status 'cut_off' = the answer hit the model's answer limit (Output Reserve), later cells can be incomplete. Rows of a run that has just started are still queued or running; the user watches them fill in on the Tables page (show_in_app, where offered; review_run). If you need the finished table in this…

ParameterTypeDescription
run_id *stringRun id from run_grid or list_grid_runs.
max_cell_charsintegerCut each cell at this many characters (20-2000, default 300).
max_rowsintegerTable rows to return (1-200, default 50).
wait_secondsintegerWait up to this long (0-30, default 0) for the run to finish before reading it.

cancel_grid_run

Ask a running grid run to stop: rows not yet started end as 'Cancelled', answers in flight still arrive. Rows already answered are kept.

ParameterTypeDescription
run_id *stringRun id from run_grid.

suggest_grid_columns

Let the model propose the answer columns for a table prompt, as the Tables page's "Suggest from prompt" does: every question the prompt asks becomes a column (key, label in the prompt's language, type string|number|integer|boolean|date|enum, description); mode object = one answer per row, array = a list per row. Background job: returns {job_id}; the job_status result is a json_schema ({mode, fields}) to put into a grid profile (create_profile kind grid, data_format json) before run_grid. Uses the model selected for tables unless llm_id/pool_id is given - in the stand-alone program the 'client'…

ParameterTypeDescription
prompt *stringThe question/instruction the table will ask about every row.

search_embedding_models

Find embedding models (search models) on Hugging Face that Matrix can run locally: feature-extraction repos with an ONNX export. Per repo: downloads, likes, license, languages (as the model card states them), created/last-modified dates, vector size (dimension; null = not stated, cannot be registered automatically), query/document prefixes, its graph variants with download size (e.g. model = full precision, model_q4 = int4) and image encoders (graphics search). Use it when the user asks for a better or smaller search model, or when the configured recommendation is older than six months (get_st…

ParameterTypeDescription
limitintegerRepos (1-10, default 6).
querystringPart of the repo name, e.g. 'gemma', 'e5', 'bge-m3' (default: all).
sortstringOrder (default downloads; updated/created = newest first).

add_files

Add a local file, or every supported file of a local folder (recursively by default), from the user's computer to a Matrix context as ONE background job: extract text, chunk, embed if the context has an embedding model. Only paths inside the folders Matrix may read are allowed: the folder Claude Code was started in, folders from the plugin settings and folders the user allowed (list_allowed_folders). For any other path the user is asked and decides - tell them in words first which folder and why; never try to get around a refusal. A symlink or `..` counts by where it leads; symlinked folders i…

ParameterTypeDescription
context_id *integerContext id from list_contexts.
path *stringAbsolute path of a file or folder inside a shared folder.
recursivebooleanFor a folder: include subfolders (default true).

setup_embedding_model

Download and register the search model (embedding model; search by meaning needs it) as a background job: returns {job_id}; poll job_status until it is done, then repeat the call that asked for the model. Without arguments: the model this server is configured with - by default EmbeddingGemma 2 (multilingual, text and images, recommended October 2026), a one-time download of about 1.2 GB from Hugging Face. Call it when a tool says the model is missing: the user approves this tool call, which is their consent - tell them the size. Nothing is downloaded otherwise. If the recommendation is older t…

ParameterTypeDescription
cancelbooleanStop the running download instead of starting one (the partial file stays and the next call resumes it). Other arguments are ignored.
reindex_contextsbooleanWith repo_id, only after the user agreed: move every context embedded with another model to the new one (replaces its vectors).
repo_idstringInstead of the configured model: a Hugging Face ONNX repo 'owner/name' (from search_embedding_models).
rerankerbooleanInstead of the search model: download the reranker (re-orders the first search hits by relevance; get_status shows it under reranker with size and license). Other arguments are ignored.
variantstringWith repo_id: graph variant, e.g. 'model' (default, full precision) or 'model_q4'.
vision_variantstringWith repo_id: also fetch this image encoder (e.g. 'vision_encoder_q4') for graphics search.

llm_tasks

Fetch the open language-model tasks Matrix has for you. In this program YOU are Matrix' language model: flows that need one (run_grid, suggest_grid_columns) run on the endpoint 'client' (the default model for tables) and wait until you answer. Returns {tasks: [{id, messages, answer_format, json_schema?, max_answer_tokens?, offered}], open: {waiting, fetched}, how_to_answer, rejected?}. Answer every task with llm_answer, then call llm_tasks again until it is empty and the run is finished. Many tasks: let fresh subagents call llm_tasks and llm_answer themselves (each fetches a few rounds, answer…

ParameterTypeDescription
maxintegerMost tasks to return (1-20, default 5; fewer when their text is long).
wait_secondsintegerWait up to this long for a first task (0-60, default 20).

llm_answer

Hand back your answers to tasks from llm_tasks, one entry per task id: {id, answer} with exactly the text the task asks for (answer_format json: one JSON value), or {id, error} when you cannot answer it (the flow then records the error for that item, as with a failing model). Up to 20 per call. The flow parses and checks the answer itself (e.g. evidence must be quoted verbatim from the passage). Returns per id whether it was delivered; a task of a cancelled run is reported as no longer open.

ParameterTypeDescription
answers *array

list_allowed_folders

List the folders Matrix may read: the folder Claude Code was started in (source project), folders from the plugin settings (setting) and folders the user allowed when asked (granted), plus configured folders that could not be used and why (problems: does not exist, not readable - macOS privacy). Nothing outside them is read: add_files asks the user for another folder.

revoke_folder

Take back the permission to read a folder the user allowed earlier (source granted in list_allowed_folders). Removes only the permission: no document, index or file is deleted, and indexed collections stay searchable. Folders from the plugin settings or the project folder cannot be revoked here.

ParameterTypeDescription
path *stringAbsolute path as listed by list_allowed_folders.