Skip to Content
19 November 2026: gateway operators, apply the nginx2root CVE mitigation.
Use with AIHow the MCP server finds an answer

How the MCP server finds an answer

The Nym docs MCP server answers a query from an index of chunks. The server ranks the chunks against the query, and an agent can then read a whole section. Each indexed repository keeps its part of the index current from its own CI. For the two models and the path of a call, see How search works.

What the index holds

The index holds chunks. A chunk is a short piece of text with a link to the place it came from. Each chunk has one vector, which the repository’s CI makes when it writes the chunk.

SourceOne chunkThe link points at
Nym docs pagesThe text under one heading. The indexer splits a section over about 2,400 characters into parts at paragraph breaksThe section’s anchor on the docs page
NymVPN client MarkdownThe text under one heading, split the same wayThe file on GitHub at the release tag
Source codeOne top-level item: a function, a type, an impl block, a class. The item’s doc comments and attributes stay with it. The indexer splits an item over about 2,400 characters at line breaksThe chunk’s first line on GitHub: the item’s first doc line, or the start of a part

Some text does not go into the code index:

  • The start of a file when it holds only package and import lines and a licence comment. A file that holds only imports or re-exports gives no chunk. A file comment that is documentation, such as a Rust //! comment, stays in the index.
  • Files in languages that the indexer cannot split into items, such as C and shell scripts.

Test code goes into the index with a flag. See How the server ranks results.

How the server ranks results

The server turns your query into a vector with the model of the index it searches. It then gives each chunk a score: the cosine similarity between the two vectors. A score near 1 means the texts are close in meaning.

  • The server returns the chunks with the highest scores, best first: 6 by default, 20 at most (topK).
  • search_docs searches the docs index and search_code the code index. Each index has its own model, so a score from one index does not compare with a score from the other.
  • A test chunk loses 0.05 from its score. Production code ranks above a test chunk unless the test chunk’s similarity is more than 0.05 higher.
  • The server drops a chunk with a score below zero, and applies no other floor. A query on a topic the docs do not cover still returns the nearest chunks. The agent must read them and decide if they answer the question.

The ranking uses only the vectors and the test flag. It does not use keywords, page popularity or the date of a change. The results do not show their scores.

Read a whole section

The indexer splits a docs section over about 2,400 characters into parts, and the index holds each part as a chunk. A search can return one part of a section.

get_section returns the whole section. Give it the URL of a search_docs result. The server finds every part with that URL and joins the parts in order. get_section reads the docs index only: a search_code result already holds its whole item, or one part of a long item, with a link to its line on GitHub.

If no section matches the reference, the tool says so in its result.

How current the index is

Each repository writes its own part of the index from its own CI.

Part of the indexWrittenLinks point at
Nym docsAfter each merge to the develop branch, which the docs site is built fromThe docs site
Nym source codeAfter each Nym binaries releaseGitHub at that release’s tag
NymVPN client docs and source codeAfter each NymVPN releaseGitHub at that release’s tag

The Nym docs can describe a change that is merged but not yet released. search_code returns the code of the last release that was written to the index. A release is in the index only after its write succeeds, so the indexed release can be older than the newest release.

A write embeds only the chunks that changed, and removes the chunks of deleted text.

The retrieval-indexer  repository runs checks against this server each day. A fixed set of queries must find their expected pages and files. Each part of the index must be built from the commit that its repository tracks, and each indexed source folder must hold chunks. A failure opens an issue in the retrieval-indexer repository. Its README  explains how the index is built and checked.

Last updated on