Connecting and enriching
Link repos to their issues, docs, and designs, manage sources, and pull grounded external facts into the knowledge layer with query-driven enrichment.
On this page
Who this is for: operators who link repos to issues, docs and designs, and want grounded facts from those sources in the knowledge layer.
Beyond code, contextlake links each repo to its external context (issues, docs, and designs) and can pull
grounded facts from those sources into the knowledge layer. connect links repos to items; enrich
queries connected sources with codebase-derived terms and stores what comes back.
flowchart LR C(["tracker, designs, merge
requests, chat"]) --> CON["kb connect"] I(["files, web, api, graphql,
another MCP server"]) --> ING["kb ingest"] Q(["the searchable ones: Atlassian,
an MCP search tool, or an api
source with search_url"]) --> ENR["kb enrich"] G[("the code graph")] -.->|"repo name and top symbols
become the search terms"| ENR CON --> P[("isolated partitions")] ING --> P ENR --> P P -.->|"linked to the repos and
symbols they name"| G
Each stage writes its own partition, so re-indexing a repo's code never disturbs its external links.
Connectors#
connect enriches the graph with external context. Five connectors ship, sharing one seam:
-
Atlassian: links each repo to the Jira issues and Confluence pages it references. Issue keys harvested from branch/commit names are confirmed against the live tracker (one batched JQL call per site prunes false positives and fetches each issue's summary/status), and Atlassian URLs in docs are classified into issue/page links. It talks to one or more Atlassian sites over MCP, each independently authenticated.
Per-symbol attribution: an issue key found in a specific symbol's own docstring, or in the git-blame commit message on its defining line, becomes a
tracked_byedge sourced from that symbol (not just the repo). The same batched JQL call confirms it. The dashboard blast radius page shows it as the Ticket breadcrumb, distinct from the repo-level Links crumb. -
Figma: links repos to the design files they reference, classifying
figma.comURLs to a stable file key. If a Figma MCP is configured, each reachable design's real metadata (a name and/or top structural frame/page names) is merged in on top of the URL-slug title, which is always the fallback. -
GitLab: links each repo to its open merge requests and issues (read through your authenticated
glab). A repo is read only when the host at the start of its id is in the source'sgitlab_hostslist. Every call then runsglab api --hostname HOSTwith that listed host.Unset, the list holds
GITLAB_HOSTwhen that variable is set, elsegitlab.com. A self-hosted GitLab needsgitlab_hosts = ["git.example.com"]on the source, orGITLAB_HOST. The source key wins over the variable.A repo on any other host is skipped and makes no request. The run logs one line for each skipped host and ends with a warning that counts the repos no GitLab source read. A skip is not a failure, so the exit code does not change. On a run where every source answers, the skipped repo's earlier GitLab links are cleared.
The log advises
gitlab_hostsas "if HOST runs GitLab". It gives no advice forgithub.comor another host known to run a different product.The host in a repo id comes from the clone's origin URL, port included: an ssh URL with the port 2222 gives
git.example.com:2222, and an https URL with the port 8443 givesgit.example.com:8443.glabtakes each entry as an HTTP host, so list the host as GitLab serves its API. Do not list an ssh port. The entrygit.example.comdoes not match the idgit.example.com:2222, and the repo is skipped.To read a repo whose origin is an ssh URL with a port, set the origin to an https URL on the host GitLab serves its API on, or to
[email protected]:ns/pwith the port set in~/.ssh/config. Runcontextlake kb index --source PATHor--workspace DIRon the clone so the repo id changes, then list that host. Indexing by the old repo id keeps the old id. The log advises the https route for a skipped host that carries a port. - Zendesk: links repos to the support tickets and Help Center articles about them, classifying*.zendesk.comURLs to a ticket id (repo --discussed_in--> issue) or an article id (repo --documented_by--> document).It makes no network call, which makes it the one connector that runs inside the offline boundary rather than as an opt-in exception to it. Zendesk's API needs a per-instance token, and the association is already stated by the link itself. The cost is that a ticket node carries no subject line. An article gets its title from the URL slug; a ticket has none to get, and inventing one would state something the graph cannot support.
Node ids carry the instance subdomain, because ticket numbers restart at 1 per instance.
hostsis configurable for an instance served from a vanity domain. The default claims only*.zendesk.com, since claiming an arbitrary host would take links belonging to another connector. -
Slack: links repos to the channels and messages that discuss them, classifying
slack.compermalinks (/archives/<channel>and/archives/<channel>/p<ts>) into channel/message links. Reachability is checked best-effort over a configured Slack MCP; there's no single spec-mandated tool name across Slack MCP servers, so the verification tool name is configurable (verify_tool, defaultconversations_info), as is the tool used to read a channel's recent messages (history_tool, defaultconversations_history). Any code symbol those messages mention by name is linked straight to the channel.
Adding another connector is a small, self-contained module, and its output lands in an isolated graph
partition, so re-indexing a repo's code never disturbs its external links. Configure connectors by copying
examples/kb.toml.example to ~/.contextlake/kb.toml.
Managing sources: the source command family#
Editing kb.toml by hand works, but for everyday use contextlake kb source commands let you add, test, and
manage connectors without touching the config file. They rewrite kb.toml while preserving your comments,
and work alongside hand-editing if you mix approaches.
The commands:
-
contextlake kb source add [NAME] [--type TYPE]: add a connector. The name is a positional argument, not a flag (contextlake kb source add jira --type atlassian). Run it in a terminal without a name or a--typeand it asks for them. It offers every type this build ships: the five connectors (atlassian,figma,gitlab,zendesk,slack) plus the built-in ingest sources (files,web,api,graphql,mcp) and any installed plugin. It proposes defaults and writes the entry tokb.toml. Without a terminal, a missing name or type exits 2 and prints the form to use.--mcp URLsets the MCP server URL and--localtargets a project-level file (--helpshows all).--set KEY=VALUE(repeatable) writes any other connector optionkb.tomlaccepts. It writes the value as a string. A number such astimeoutis read from that string (--set timeout=2.5works). A list option (include,hosts,urls,args) set this way holds one item, so--set include='*.md'means the one glob*.md. To give two or more, editkb.tomland write a list.A credential never goes on the command line. Store the name of the environment variable that holds it, and contextlake reads the value from your environment at run time:
--set token_env=MY_TOKEN.addrefuses a literal secret (a key such astoken,api_key,passwordorsecret) from--setand from--from-stdin, and exits 2 without writing anything.--from-stdin KEYreads the value of one non-secret option from stdin instead of the command line, so it stays out of shell history:printf '%s' "$MCP_URL" | contextlake kb source add jira --type atlassian --from-stdin mcp. -
contextlake kb source list: show all configured connectors (the effective merged config from~/.contextlake/kb.toml, the nearest ancestor directory's.contextlake.kb.tomlif one exists, and the built-in defaults), with reachability status. contextlake kb source test SOURCE: verify that a specific connector works. Reaches its API, reads credentials from the configured env var, lists available items. Shows what each source will ingest without running a fullconnect.contextlake kb source enable|disable SOURCE: toggle a connector on/off in the config by name, so you can pause one without deleting it.contextlake kb source remove SOURCE: delete a connector entry by name.
add, remove, enable and disable lock the file while they change it. When two run at the same
time, both changes are kept. The lock is an empty file beside the config (kb.toml.lock, or
.contextlake.kb.toml.lock for a project file). Leave it in place, and add it to .gitignore in a
project. A command that waits 10 seconds for the lock exits 1 and changes nothing.
If the config you name with --config, or the global kb.toml, is a symbolic link, these commands
write to the file the link points to, in whatever folder it is, and keep the link. The lock sits
beside that file. A project .contextlake.kb.toml that the command finds by walking up from the
working directory is not followed: a link there is replaced by a regular file, and the file it
pointed to is not touched.
An example workflow:
contextlake kb source add # interactive: what type? what name? which MCP URL?
contextlake kb source list # show what you've configured + status
contextlake kb source test my-atlassian # does it work? what's in scope?
contextlake kb connect # now link repos to their items
init can also prompt you to connect a source during first-run setup, and doctor reports per-source
reachability as part of its environment check, so hand-editing is optional; the CLI guides you through the
whole flow.
Every fact carries its receipt. Each is provenance-stamped (source file + verified date) and
confidence-tagged as one of three tiers, EXTRACTED (read straight from source/AST), INFERRED (a
resolved call or link), or AMBIGUOUS (an unconfirmed candidate), and sanitized before it reaches an
agent. The dashboard and the graph legend use these same tiers.
Query-driven enrichment#
contextlake kb enrich performs query-driven enrichment: it derives search terms from each repo's code
graph (the repo's name and its top searchable symbols by graph degree, which is the symbol kinds the
embedder covers, not files or packages) and queries your connected sources (Atlassian
Rovo search, or any mcp source with a tool and arg_template configured) with those terms, then stores
the returned documents in a searchable, embedded @enrich:<repo> partition, idempotent and re-runnable
across the whole fleet or a single repo:
contextlake kb enrich --workspace ~/work # all indexed repos
contextlake kb enrich acme/forecast-api # one repo
kb enrich and kb connect stop with exit code 1 when an id you name is not in the store. They
print Unknown repo '<id>' with the closest stored ids, and run nothing, even if the other ids are
valid. This check comes first, so it holds when no source is configured. --workspace and
kb connect --source <dir> do not read the ids. An empty store with no id named still prints
No repos to enrich (index some first ...) and exits 0.
Which symbols become terms. Ranking is by graph degree, and by nothing else. There is no
per-kind quota, so a repo whose highest-degree definitions are all classes and functions gets
classes and functions, and no field or endpoint name at all, even when it holds many of
them. That is on purpose: a repo gets its name plus 9 symbol names by default, and reserving one for
each of the 19 embeddable kinds would leave the ranking two or three slots to decide.
Prerequisites. Two things must be true:
- The code graph is indexed with
contextlake kb index. - At least one term-searchable source is configured. That means an
mcpsource withtoolandarg_templatekeys, anatlassiansource, or anapisource with asearch_url(next section).
Sources without those capabilities, such as a plain files or web source, are skipped
gracefully.
Searching Jira and Confluence with an API token#
An api source with a search_url is searched once per term. Put {term} where the term goes;
it is URL-encoded, and " and \ are removed from it first so it cannot end a quoted JQL or
CQL string. {terms} sends one search with every term joined instead.
kb ingest does not use search_url. A source that has only a search_url makes no ingest
request, and kb ingest prints nothing to ingest: an api source with only search_url is queried by
kb enrich, not kb ingest for it.
[[sources]]
type = "api"
name = "jira"
search_url = "https://your-site.atlassian.net/rest/api/3/search/jql?jql=project%20in%20(%22ACME%22,%22OPS%22)%20AND%20text%20~%20%22{term}%22&fields=summary&maxResults=20"
items = "issues"
id_field = "key"
title_field = "fields.summary"
text_field = "fields.summary"
auth = "basic"
user = "[email protected]"
token_env = "ATLASSIAN_API_TOKEN"
[[sources]]
type = "api"
name = "confluence"
search_url = "https://your-site.atlassian.net/wiki/rest/api/search?cql=space%20in%20(ENG)%20AND%20text%20~%20%22{term}%22&limit=20"
items = "results"
id_field = "content.id"
title_field = "title"
text_field = "excerpt"
auth = "basic"
user = "[email protected]"
token_env = "ATLASSIAN_API_TOKEN"
Put each Jira project key in double quotes (%22 in the URL). A key that is also a JQL word,
such as IN, otherwise fails every search with a 400, and every repo then keeps its previous
results.
What this path guarantees:
- It only reads. Every request is a GET.
- One page per search.
maxResultsorlimitin the URL sets the size of that page.max_pageshas no effect onkb enrich. The log linestopped at the 1-page capis expected when the API has more pages. - The token stays on its host. A redirect to another origin is followed without it.
- A failed search keeps the old results. A 401, 403, 429 or dead host counts as an unavailable source, so the repo keeps what it had instead of being cleared.
search_urlis a privileged key. It decides where search terms built from your code are sent, so only the global config or a file named with--configmay set it.
Before the first real run, --dry-run prints each repo's terms and every URL it would request,
and sends nothing. --max-documents N stops sending searches once N documents were taken in the
run. Repos it did not reach keep their previous results.
contextlake kb enrich --config ~/enrich.toml --dry-run acme/forecast-api
contextlake kb enrich --config ~/enrich.toml --max-documents 200 acme/forecast-api
A known limit: each stored document links to the search request that found it, not to the issue or page itself.
What you get. Each repo's enrichment documents live in their own partition, so they can be re-fetched without clobbering earlier results.
With the semantic tier enabled they are embedded too, so they appear in semantic search as
document nodes tagged with their source in attrs.source.
A result that names one of the repo's symbols is linked straight to it with a documented_by
edge, so the enrichment lands on the graph rather than beside it.
How to read the run. Each repo prints the terms tried, the documents returned and the edges attached to code. Both numbers are reported because they answer different questions: documents returned says whether your sources had anything, edges to code says whether a question about the code can reach it.
The closing line puts every targeted repo in one bucket, and the buckets add up to the number of repos the run planned to touch:
| Bucket | What it means |
|---|---|
enriched |
Documents came back and at least one names a symbol in the repo. |
nothing returned |
The repo was searched and the sources had nothing. |
returned but unattached |
Documents came back and none names a symbol in the repo. |
failed |
The store or shard write failed for that repo. The run continues. |
skipped |
No graph shard, so no terms were built. Run kb index first. |
kept previous results |
A source could not be reached, so the repo's earlier results stay. |
not searched (cap reached) |
--max-documents was reached first; earlier results stay. |
returned but unattached is a normal outcome, not a failure, and the run still ends with a
✓. Symbol matching is whole-word and ignores names under three characters, so a ticket that
discusses the repo in prose without naming any of its code correctly attaches to nothing. If
you expected attachments, check the repo is indexed and that the document text spells the
symbol names the way the code does.
After contextlake kb wiki runs, these documents become an attributed "External context"
section in the curated wiki, grounded to the code graph's terms.
Configuring document sources, including the built-in files source, plugin packages and MCP endpoints, is in Document sources and RAG.
When a source stops answering#
connect and enrich are the only stages that leave the machine, and a fleet run asks each source once
per repo. If a source goes down mid-run, contextlake stops asking it rather than paying its timeout on
every remaining repo: after three consecutive failures the source is skipped for 60 seconds, then one
call is let through to see whether it came back. A run against an unreachable MCP server finishes in
seconds instead of timeout x repos.
You will see this in the output, it is never silent, because "the source was down" and "the source had nothing" would otherwise look identical:
resilience: circuit OPEN for mcp:npx:https://mcp.example.test after 3 consecutive
failure(s) (TimeoutError) -- further calls are skipped for 60s
resilience: skipping mcp:npx:https://mcp.example.test for 60s -- circuit open after 3
consecutive failure(s) (TimeoutError); results from this source will be incomplete
The name in that line identifies the endpoint by transport and host only, never the rest of the URL, since a hosted MCP endpoint can carry a token in its path or query.
Failures the server rejected rather than failed on, an unknown tool, a bad token, are reported as
themselves and never trip the skip: no amount of waiting fixes a wrong request. Raise timeout on the
source if the server is merely slow. kb enrich reads it for an Atlassian source and for an mcp source
with a tool.
When one repository is unreadable#
A repository that fails outright costs that repository, not the run. connect names it, skips it, and
carries on with the rest:
api-gateway: 'utf-8' codec can't decode byte 0x96 in position 99486: invalid start byte
⚠ Connect complete: 143 external link(s) stored
⚠ 1 of 20 repo(s) failed and were skipped; the rest were enriched. Re-run to retry
them, or narrow with `contextlake kb connect <repo-id>`.
The exit code is non-zero when any repository was skipped, the same verdict kb index gives a
workspace where one repo failed to parse: the graph an agent will cite from is not the one you asked
for, so the run should not read as clean.
A source that could not be reached is not an empty answer.
- A repo whose source failed keeps the links, nodes and vectors from its last complete run, and the run names it in a warning.
- The exit code is 1 when nothing was stored at all, and 0 with that warning when other repos got results.
- A source that answers with no results still clears the repo's previous ones.
- A repo whose docs and commits no longer mention any issue key or link has its previous links
cleared too (the run logs
cleared the previous links). A repo folder that is missing keeps them. - With several sources, one that stays unreachable keeps every affected repo's previous results, so the other sources' results for those repos wait too. The run exits 1 until that source is fixed or removed from the config.
