MCP
The Knowledge Graph exposes agent retrieval as a first-party Model Context Protocol (MCP) server on your tenant origin at /_kg-engine/mcp (Streamable HTTP). Agents explore through an evidence loop: search or open a chunk, read its position, section, entities and neighbours in the same payload, then hop to more chunks. Every answer contains only what the caller may read (Permissions). This page is the reference for the tools, the chunk package they return, the search parameters, the OpenCypher tool, and how you connect an external client.
One call: the permission check decides which namespaces the caller may read, or refuses the call, before the graph is searched.
Tool catalog
Section titled “Tool catalog”| Tool | What it does |
|---|---|
kg_search |
Hybrid search (full text, vector, graph expansion) fused by reciprocal rank fusion; several namespaces fuse by rank. Returns capped chunk packages. Disabled and unreadable content is excluded |
kg_open |
Open packages by exactly one of chunkKey, outlineKey (that section’s chunks), entityKey (chunks mentioning it) or fileId (the file’s chunks in order) |
kg_hop |
Typed hop onto related packages: next_chunk, prev_chunk, similar (from a chunkKey); mentions, rel, same_type (from an entityKey); outline_child, outline_parent, outline_siblings (from an outlineKey) |
kg_outline |
A file’s page index: sections in document order with outlineKey, title, depth, parent and pages. Paged with cursor / nextCursor; maxDepth limits large files |
kg_ontology |
The published schema of a namespace: entity types, relation types and the patterns that connect them |
kg_entity_search |
Entity entry by text and/or vector similarity; returns type labels and mention evidence packages |
kg_file_entities |
All entities mentioned by one file’s chunks, plus the published entity types used in that file. Paged with afterEntityKey when truncated |
kg_file_triples |
Typed relationship triples where both subject and object are mentioned in one file |
kg_namespaces |
The Knowledge Graph namespaces the caller may read |
kg_collections |
A namespace’s collections (for example a regulation and its successor) with their folder paths; collectionId values go to kg_search as filters.collectionIds |
kg_status |
Processing status of one namespace, or of the files under folderPrefix: disabled, not_started, in_progress, blocked or settled. An agent reads it before importing into a namespace |
kg_files |
Files in one namespace by path. folderPrefix and name (a path glob) combine. Lists a page (cursor / nextCursor). Each file includes namespace, path and fileId (file: plus the path) |
kg_file |
One file’s path, size and content hash from namespace plus path or fileId; a csv or tsv also returns columns. Contents and queries are Fontana Files. See Read or query a file |
kg_cypher |
One read-only OpenCypher statement for an exact word, a figure or a known path (at most 50 rows, 2 second limit). Returns the file path and the chunk text |
You enable these tools on an agent with the Knowledge capability tile on the agent card. Five more tools write the graph during an agent turn; see Write tools.
Chunk packages
Section titled “Chunk packages”Every search, open, hop and entity-search hit is a chunk package. Lists carry truncated and total when clipped at the requested cap.
| Field | Contents |
|---|---|
text |
The chunk text, plus contextHeader (the “Document › Heading › Subheading” trail) and citation (namespace/path › sections (pp.)) |
position |
chunkIndex, charStart / charEnd in the parsed text, page and line span, tokenCount, prevChunkKey, nextChunkKey |
outline |
The chunk’s page-index section: outlineKey, title, depth, order, and its ancestors, siblings and children |
mentions |
Entities the chunk mentions: key, name, type id and label, how it was found (method), and the quoted text |
relNeighbors |
Typed relations of those entities, when a file you may read states them |
dates |
The file’s documentDate, effective window and collections |
similarFiles |
Readable files similar to the chunk’s file, best first |
| Cap | Default | Hard max |
|---|---|---|
topK |
8 | 32 |
mentions |
8 | 24 |
rel |
8 | 24 |
ancestors |
6 | 12 |
siblings |
8 | 24 |
children |
8 | 24 |
similar |
4 | 16 |
Caps passed on the tool call override the defaults. A value over the hard max fails closed with an error. An optional tokenBudget omits or truncates chunk text. Files processed before character offsets existed report trace.missingOffsets until they are reprocessed.
Hybrid search (kg_search)
Section titled “Hybrid search (kg_search)”kg_search runs one or more retrieval lanes and fuses the results with reciprocal rank fusion (RRF):
| Parameter | Default | Purpose |
|---|---|---|
query |
(required) | Search text |
namespaces |
All allowed | Subset of the caller’s namespace allow-list |
lanes |
fulltext, vector, graph_expand |
Which lanes to run. co_annotation is opt-in. A failed lane returns empty without aborting the search |
tokenBudget |
none | Estimated token cap on returned chunk text |
filters |
none | Collection, folder, temporal and relation filters |
ranking.rrfK |
60 | RRF constant k |
ranking.laneWeights |
1 each | Per-lane multipliers on RRF contributions |
ranking.minScore |
none | Drop hits below this display score (0 to 1) |
Across several namespaces, results interleave by rank within each namespace, not by raw score, because scores from different corpora are not comparable. A failed lane or namespace returns empty while the others continue; the agent turn is never aborted.
When filters or disabled files hide most of a namespace, the vector lane widens its candidate pool in rounds instead of returning fewer hits; trace.vectorWidening reports the final pool and whether its cap was reached.
Co-annotation lane
Section titled “Co-annotation lane”The co_annotation lane finds chunks that mention two entities named in the question. It runs only when the search call includes it in lanes; the assistant adds it to its own calls, and KG Studio search has no switch for it. With the lane on, the span linker attaches a phrase in the question to a nearby entity when the published ontology did not already name it, and grounding roles label those entities from how often they are mentioned.
Every search runs full text, embeddings and a graph hop and fuses them by rank; co-annotation joins when the question names two entities.
When the lane runs, the response includes grounding, one entry per namespace. Each entry lists the grounded entities with their roles, the chosen pair, directCount (chunks that mention both entities) and bridgeCount (chunks one relation away). When the lane cannot form that evidence, the entry carries a reason such as too_few_bridges.
Navigating from a hit
Section titled “Navigating from a hit”The remaining read tools move from one hit to the evidence around it.
kg_openresolves one key to packages, from a chunk, outline, entity or file id the agent already holds.kg_hopexpands fromfromKeywith a typedkind.similarmoves to the first chunks of files similar to the chunk’s file.kg_outlinereturns a file’s table of contents;kg_open {outlineKey}then opens one section.kg_ontologyreturns the published schema on its own, so the types do not have to travel on every search hit.kg_entity_searchstarts from a name and lands on mention packages, so an answer built from it stays citation-backed. Each hit carriesdegree(how many chunks mention the entity) androle:bridge(specific enough to connect the question to evidence),filter(common enough to narrow the question, not to connect chunks) orignore(too common to connect the question to evidence).kg_file_entitieslists the entities and entity types already extracted for one file; the Ontology Agent reads it before it retypes entities or reviews the file again.afterEntityKeypages the list when the response istruncated.kg_file_tripleslists typed relationship triples for one file when both endpoints are mentioned in that file. Whentruncatedis true, the response’scontinueAftergoes back asafterSourceEntityKey,afterRelationTypeIdandafterTargetEntityKey.
Write tools
Section titled “Write tools”Five tools write the Knowledge Graph on an agent’s behalf. The Ontology Agent uses them when it reviews what processing found in your documents.
| Tool | What it does |
|---|---|
kg_upsert_triples |
Write typed relationships between entities. Each one cites the file and the quoted text that states it |
kg_set_entity_types |
Set the entity type of one or more entities |
kg_propose_ontology_terms |
Propose entity types and relation patterns. The namespace’s evolution policy decides whether a proposal is applied or waits for review |
kg_merge_entities |
Merge duplicate entities into one. A later merge does not undo it |
kg_save_recognition |
Replace the namespace’s recognition tree (.fontana/kg/recognition.yaml), creating or moving each entity type under the parent the file names |
- Agent turns only. The write tools run only inside a Fontana agent turn. An external client connected with a personal access token does not see them in its tool list, and a call to one is refused.
- Scope. The person the agent runs for must be allowed to write the Knowledge Graph and must have edit access (editor or admin) to the namespace, and the namespace must be one the agent is set to use. An extraction turn for one file may cite and retype only that file.
- Files first. Each write lands in the namespace’s files in Fontana Files before it reaches the graph, so a rebuilt graph keeps it. See Where the ontology is kept.
- Activity. Each write is recorded in the agent turn’s activity.
In Flow, an agent sees these tools under the mcp_knowledge-graph_ prefix, for example mcp_knowledge-graph_kg_upsert_triples.
Read or query a file
Section titled “Read or query a file”Every hit names a file: a search package, kg_open, kg_files and kg_file all carry namespace, path and fileId. fileId is file: plus path. Chat @kg:<namespace>/<path> maps to that namespace and path.
kg_file describes the file: path, size and content hash, and for a csv or tsv the columns (header names). Reading and querying the file is the Fontana Files MCP, on the same tenant with the same credentials: pass namespace and the same path or fileId, unchanged, to get_file or query. file:notes/a.txt and notes/a.txt are the same file.
| Need | Fontana Files call |
|---|---|
| The text | get_file with namespace and path |
| A line window | query with type: "text", startLine, endLine |
| An in-file or folder regex | query with type: "grep"; a path ending in / searches that folder; a hit returns path and fileId |
| SQL over a csv, tsv, json or jsonl | query with type: "sql"; the table is the quoted path: SELECT * FROM "sales.csv". Quote a header that is not a bare name: "Market Value (AUD)" |
| JSON | query with type: "jsonpath", "jsonata" or "jinja" (Jinja receives the parsed document as data) |
In Flow, the Files ability gives an agent these tools as mcp_ffs_get_file and mcp_ffs_query, next to the Knowledge ability’s mcp_knowledge-graph_* tools.
OpenCypher (kg_cypher)
Section titled “OpenCypher (kg_cypher)”kg_cypher runs one read-only OpenCypher statement against a single namespace, selected by the namespace argument. It answers an exact word, a figure or a known path; kg_search answers by meaning when the words or the path are unknown.
A statement labels every node, follows one relationship at a time, projects a property such as f.vfsPath, and ends with a literal LIMIT from 1 to 50. The platform stops each query after 2 seconds and runs statements one at a time. The next page is read with WHERE ID(n) > $afterId; SKIP is rejected. Before writing a statement, an agent lists the namespaces it may read with kg_namespaces and reads the namespace’s published schema with kg_ontology.
The graph stores:
- FileRef, a file (
vfsPath,name,fileId). A Folder (folderPath) connects withFolder -[:HAS_CHILD]-> FileRef. - Chunk, one text window (
text,path,chunkIndex).Chunk -[:PART_OF]-> FileRefandChunk -[:NEXT_CHUNK]-> Chunk. - OutlineNode, a heading (
title).OutlineNode -[:COVERS]-> Chunk. - Entity, a mention (
name,typeId). OnlyChunk -[:MENTIONS]-> Entity. - EntityType, the published schema (
typeId,label,side = "published"). - REL, a typed link between entities (
relationTypeId), when the namespace has any. A query reaches it from a chunk mention and aliases the edge.
An entity, heading or folder shares the pattern with an aliased Chunk or FileRef, so every row leads back to a file. An exact word in a known path:
MATCH (c:Chunk)-[:PART_OF]->(f:FileRef)WHERE toLower(c.text) CONTAINS "dkim" AND f.vfsPath CONTAINS "reports"RETURN f.vfsPath AS path, c.text AS textLIMIT 10An answer cites the file path and the chunk text it came from; an entity name on its own carries no citation. Cypher matches the text it is given, so a misspelling such as “remed” for “Resmed” is found with kg_entity_search first, and a Cypher walk from that entity leads back to the mentioning chunk. Two files connect through Chunk -[:MENTIONS]-> Entity <-[:MENTIONS]- Chunk, returning each file path.
The namespace argument has to be one your namespace grants let you read, and the platform adds the enabled-file check and any pinned filters to each aliased Chunk and FileRef before the query runs.
Permissions, fail closed
Section titled “Permissions, fail closed”Every Knowledge Graph tool call is permission-enforced. Fontana resolves the caller’s readable namespaces from the namespace grants on each call. Nothing from a namespace the caller may not read, or from a disabled file, reaches the answer: not its chunks, not the entities only it mentions, not relations only it states, not its similar-file links. If the caller context is missing or cannot be resolved, the call fails closed with an explicit auth error, never a silent empty result or a cross-namespace answer.
In-app agents and external clients both run tools under your identity. An in-app agent reads only the namespaces on its allow-list that you may read.
Using Knowledge Graph MCP in Flow
Section titled “Using Knowledge Graph MCP in Flow”- Agents: enable the seeded Knowledge Graph MCP connection from AI → Tools and MCP and assign namespaces on the agent’s Knowledge capability tile. Flow runs tool calls as the signed-in person.
- Chat: when the Knowledge Graph toggle is on, matching search evidence can be placed in the turn automatically. An answer that uses a file shows a bookmark for that file. Hover the bookmark to see the namespace and path; click it to open the file in the Knowledge Graph.
- KG Studio: graph layout, ontology editing and search run in the product UI against the same tenant graph.
Memory and conversations
Section titled “Memory and conversations”Two private namespaces of yours are searchable through the same tools.
Memory writes use knowledge_addMemory and knowledge_forgetMemory, which every agent has without setup; they are not MCP tools. Each user has one private memory store in Fontana Files, shared by the agents that user runs. Its files are searchable like any other namespace you can read, so Knowledge Graph search returns your memories next to other evidence. See agent memory for paths, overwrite and the Forget memory button in chat.
Your conversations are a private namespace too: every completed turn is saved to your threads namespace in Fontana Files and indexed like any other document. Your own searches reach it. An agent turn reaches it only in a chat of your own, never in a shared conversation, a Slack or Teams thread, a schedule, an evaluation run or Knowledge Graph extraction, and naming the namespace in a tool call does not change that. See where conversations are saved.
Tenant endpoints
Section titled “Tenant endpoints”On your tenant Flow origin:
- Health:
https://<tenant>.<baseDomain>/_kg-engine/health(no auth) - MCP (Streamable HTTP):
https://<tenant>.<baseDomain>/_kg-engine/mcp
External MCP clients (Cursor, ChatGPT)
Section titled “External MCP clients (Cursor, ChatGPT)”Use a personal access token to connect an external MCP client to your tenant’s /_kg-engine/mcp endpoint. You create each token under Admin → Fontana MCP and access tokens (/admin/access-tokens) and bind it to one agent. On this URL the token authenticates as you and serves only the Knowledge Graph read tools that agent grants, together with your namespace grants. The write tools are not served to external clients. The same token connects to External agents and to Fontana Files MCP.
Issue a token
Section titled “Issue a token”- Sign in to your tenant Flow origin (the same HTTPS hostname you use for workflows, for example
https://acme.example.com). - Open Admin → Fontana MCP and access tokens (
/admin/access-tokens). - Create a token, choose the agent it is bound to, and copy the full
fnt_pat_…value from the setup step of the create dialog. It is shown only there: once you close the dialog, nobody can see it again. - Rotate a token on that page to replace its bearer: the old one stops working at once and the new one is shown once, the same way. Revoke a token when it should stop connecting for good.
The token must be created on the same tenant origin you configure in your MCP client. A token from one hostname does not work on another.
Cursor
Section titled “Cursor”Add a Streamable HTTP server in your Cursor MCP configuration (~/.cursor/mcp.json or a project-level .cursor/mcp.json):
{ "mcpServers": { "knowledge-graph": { "url": "https://<tenant>.<baseDomain>/_kg-engine/mcp", "headers": { "Authorization": "Bearer fnt_pat_…" } } }}After editing MCP config, run Developer: Reload Window in Cursor (or fully quit and reopen).
ChatGPT (Developer mode)
Section titled “ChatGPT (Developer mode)”ChatGPT connects to remote HTTPS MCP servers only (Streamable HTTP). You need a paid plan with Developer mode enabled (Settings → Security and login).
- Open Settings → Apps & Connectors.
- Create a custom connector (Developer mode):
- Connector URL:
https://<tenant>.<baseDomain>/_kg-engine/mcp - Authentication: Token (not OAuth), or a single
Authorizationheader (see below).
- Connector URL:
- Paste your full
fnt_pat_…value. ChatGPT sendsAuthorization: Bearer fnt_pat_…to your tenant MCP endpoint.
Header-only setup (works in Cursor and ChatGPT):
| Field | Value |
|---|---|
| URL | https://<tenant>.<baseDomain>/_kg-engine/mcp |
| Bearer token env var | Empty. This field is for the env-var setup below |
| Header name | Authorization |
| Header value | Bearer fnt_pat_… (full token, including the Bearer prefix) |
Env-var setup (ChatGPT desktop / Codex): set bearer_token_env_var to a name such as MCP_PAT, export that variable to the raw token (no Bearer prefix), and do not also send an Authorization header.
Verify PAT auth
Section titled “Verify PAT auth”Health checks do not use auth. Confirm the PAT on the MCP path:
export MCP_PAT='fnt_pat_…' # full token from /admin/access-tokens
curl -fsS "https://<tenant>.<baseDomain>/_kg-engine/health"# {"ok":true}
curl -sS -w "\nHTTP %{http_code}\n" -X POST \ -H "Authorization: Bearer $MCP_PAT" \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' \ "https://<tenant>.<baseDomain>/_kg-engine/mcp"Replace <tenant>.<baseDomain> with your tenant origin. 401 means the token is missing, truncated, unknown, revoked, or created on a different origin. 200 with a JSON-RPC body means auth succeeded.
Troubleshooting 401
Section titled “Troubleshooting 401”| Symptom | Likely cause | Fix |
|---|---|---|
| Health OK, MCP 401 | Bad or missing Authorization |
Use Authorization: Bearer fnt_pat_… only; pick one auth method (header or env var, not both) |
| Intermittent 401 | Bearer env var and header both set | Pick one auth method; clear the other |
| Always 401 | Truncated token in the UI | Re-copy the full PAT |
| Always 401 | PAT from another tenant origin | Create the PAT on the same hostname as your MCP client URL |
| Always 401 | Unknown or revoked token | Create a token on this origin at /admin/access-tokens and bind it to an agent |