Skip to content

MCP tools reference

Noesis serves six tools over both MCP transports (streamable HTTP at /mcp/, stdio via python -m noesis.mcp). Every tool body is the same core call as its REST twin, and success payloads are identical dicts — tests assert byte-equality so the two surfaces cannot drift (src/noesis/mcp/server.py). Failures raise ToolError with the same detail REST puts in its HTTP error body, with one deliberate exception: the capacity refusals below carry agent-facing text rather than the REST detail string, because an agent needs to be told that nothing failed, that nothing was queued, and which knob changes the limit.

Capacity refusals (ADR-84/ADR-85). search_code raises ToolError when the search gate is saturated, and reindex when the machine-wide index-run cap is reached. Both are the MCP equivalent of REST's 429 — MCP has no status codes — and both mean retry shortly, not something is broken. The messages name the live counts and the config key to raise ([qdrant] query_connections, [indexing] max_concurrent_index_runs).

search_code

Semantic + lexical (hybrid) search over an indexed project.

Param Type Default Constraints
query str required min length 1; blank/whitespace-only rejected (ToolError: query must not be blank)
project_id str required must exist (ToolError: unknown project_id)
top_k int 10 1–100
language str | null null canonical language filter (payload-indexed)
channel "hybrid" \| "dense" \| "sparse" "hybrid" —
rerank bool | null null null → server default (reranker.enabled); ignored unless the reranker is enabled

Returns:

{
  "query": "validate jwt expiry",
  "channel": "hybrid",
  "reranked": false,
  "hits": [
    {
      "chunk_id": "6f0c…",
      "file_path": "src/auth/jwt.py",
      "start_line": 42,
      "end_line": 78,
      "language": "python",
      "symbol_name": "validate_token",
      "score": 0.5,
      "snippet": "def validate_token(…"
    }
  ]
}

When reranking was applied, reranked is true and each hit carries a rerank_score. Hits are candidates, not ground truth — read the live file before acting on a span. Telemetry records metadata only (interface, channel, latency, result count) — never the query text.

AST-pattern search (ast-grep) over the project's live files — never the index, so results are current even when the index is stale.

Param Type Default Constraints
pattern str required ast-grep pattern, e.g. def $NAME($$$ARGS): $$$BODY
language str required patterns are per-language; unsupported → error
project_id str required —
paths list[str] | null null relative path-prefix restriction
max_results int | null null ≥ 1; null → config structural.max_results (may lower the cap, never raise it)

Returns:

{
  "pattern": "models.FusionQuery($$$A)",
  "language": "python",
  "matches": [
    {
      "file_path": "src/noesis/core/vectorstore.py",
      "start_line": 449,
      "end_line": 452,
      "matched_text": "models.FusionQuery(fusion=models.Fusion.RRF)",
      "meta_vars": {"A": "fusion=models.Fusion.RRF"}
    }
  ],
  "scanned_files": 57,
  "truncated": false,
  "timed_out": false
}

truncated: true means the scan stopped at max_results; timed_out: true means the wall-clock budget expired and matches are partial. Errors are typed — unknown_project, unsupported_language, pattern_error (with ast-grep's diagnostic, so agents can iterate on patterns cheaply), invalid_path — surfaced as ToolError("type: message").

list_projects

No parameters. Returns the registered projects (root path, embedding model, timestamps, per-project flags). Project ids from here feed every other tool.

get_index_status

Param Type
project_id str (required)

Status of the most recent index run, shaped identically for REST and MCP:

{
  "project_id": "…",
  "run_id": "…",
  "status": "done",
  "files_total": 115,
  "files_changed": 14,
  "chunks_written": 81,
  "started_at": "…",
  "finished_at": "…",
  "error": null,
  "expected_chunks": 333,
  "vector_count": 333,
  "drift": false,
  "unwalkable_dirs": 0,
  "quarantined_dirs": 0,
  "embedder_assets": "ready",
  "embedder_ready": true,
  "reranker_assets": "disabled",
  "reranker_ready": "disabled"
}

status is one of never_indexed | queued | running | done | failed (a registered project with no runs reports never_indexed with run fields nulled — a stable shape for agent consumers). The drift fields compare what the state DB expects against what Qdrant actually holds; a mismatch (drift: true) means the vector store lost data externally, and the next index run self-heals it (ADR-49).

drift requires evidence that survives an index run committing mid-call: the expected chunk total is read on both sides of the Qdrant count, and drift is reported only when those two readings agree with each other and still disagree with the count. A total that moved across that window means neither reading is a stable expectation, so there is nothing to compare against — that is an in-flight run, not drift. The figure reported is the fresher of the two.

The cost of that rule is worth knowing: while a run is actively committing, drift reads false even if the store genuinely lost data. The first call after the run settles reports it. A false negative for a few seconds beats a false positive on every status poll during every index run.

unwalkable_dirs and quarantined_dirs are the coverage half of the same health picture, where drift is the storage half. drift says the store lost content it should be holding; these say part of the tree was never read, so what is indexed for it may be stale and cannot be proven otherwise. quarantined_dirs is a subset: those have failed long enough that the paths they hide are no longer being re-queued for retry (ADR-56).

Both zero is the healthy state. Non-zero does not mean anything was deleted — nothing under an unwalked directory is ever purged, because "I could not look" is not evidence of absence. It means results from that part of the tree may reflect older content than what is on disk. Worth checking before treating a search result as authoritative, and worth reporting to the human if a search over that project is coming back thin. Recovery is automatic: the first run that walks the directory again re-hashes its contents. There is no tool to clear this — it is a filesystem problem (a permissions change, an unmounted disk) or a deliberate scope decision, and both are resolved outside Noesis.

embedder_assets/embedder_ready mirror /healthz's cold-start warm-up signal (issue #47) for callers with no HTTP surface to poll — an MCP stdio server has no /healthz at all. embedder_assets is "ready" or "missing" (are the model's weights cached locally, checked without touching the network); embedder_ready is true/false once the embedder reports which device it loaded on, or the string "n/a" for an embedder implementation that doesn't expose one (e.g. a test double). A search_code call arriving while embedder_ready is still false will block until the background warm-up finishes loading the model — this pair of fields is why, not a hang.

reranker_assets/reranker_ready are the same pair for the optional cross-encoder (ADR-87), with the same values plus "disabled" on both when the reranker.enabled kill switch is off (and "unknown" if the serving context does not model a reranker at all) — the shipped default, and the value shown above. A value rather than absent keys, so a caller can tell "reranking is off" from "this server doesn't report it", and nobody is sent after 2.3 GB of weights for a feature they never turned on. When reranking is on, reranker_ready: false alongside reranker_assets: "ready" means the next reranked search pays the cross-encoder's ~2.3 GB load, which is roughly 4x the embedder's — and reranker_assets: "missing" means it pays the download too.

get_chunk

Param Type
chunk_id str (required, from search_code hits)

Returns the exact stored span with the full chunk content — the indexed snapshot, which may lag the live file. Unknown id → ToolError: unknown chunk_id. Exposing chunk_id in every search hit is what makes this tool discoverable (ADR-36).

reindex

Param Type
project_id str (required)

Starts an incremental re-index (only changed files are re-embedded) and returns immediately with a run_id — poll get_index_status until done. If a run is already in flight the existing run's id is returned (status: "already_running"). The mixed-model guard (index built with a different embedding model) raises a ToolError explaining that a full re-index is required.

No force on this tool

A project whose scan finds zero files while the index still tracks some fails its run rather than emptying the project (ADR-55). The force that accepts that result is on the REST surface only (POST /projects/{id}/reindex?force=true): the assertion "these files really are gone" needs a human who can check whether the disk is mounted, and the caller of an MCP tool is an agent. An agent that meets the refusal should surface it, not work around it.

Registration is not an MCP tool

Registering a project is an operator step over REST or the dashboard — agents get reindex, not register. See Connecting agents.