pm_knowledge
The pm_knowledge tool turns Valdr’s Workspace Knowledge layer into an agent-callable surface. Agents can attach docs and code, queue ingestion, search across project and global context, record durable notes, and ask symbol-shaped questions such as “definition of HttpClientBuilder” or “callers of parseConfig”.
Use this tool when an agent needs more than the current prompt window. pm_knowledge lets teams keep canonical docs, operational runbooks, indexed source trees, Valdr records, and Agent Memory Notebooks available as structured retrieval instead of re-explaining the same context in every session.
code_map can answer definition, reference, caller, import, export, implementation, and test questions from the graph. search still retrieves indexed code chunks from other languages, and those languages can return structure-level definitions, but their reference queries fall back to retrieval grouping. See Language coverage.Actions
get, update_sources, record_entry, ingest, search, code_map, status, help
Scope Model
Most read actions can target one project, several projects, global Workspace Knowledge, or everything.
| Scope | Use for |
|---|---|
project | One project’s attached knowledge sources |
projects | An explicit set of project IDs |
global | Workspace-wide knowledge not owned by one project |
all | Project and global knowledge together |
scope: "project" requires projectId. scope: "projects" requires projectIds. update_sources and record_entry write to either project or global because every attachment belongs to one scope.
Knowledge Sources
update_sources can attach these source shapes:
| Knowledge type | Resource kind | Typical use |
|---|---|---|
docs | folder | Product docs, architecture notes, runbooks |
code_intelligence | folder | Source trees for code search and code map |
attachment:file, url:url, and code_intelligence:file are compatibility values for older persisted rows. They are not current public attach modes.
record_entry manages first-class records instead:
| Entry type | Purpose |
|---|---|
agent_knowledge | Agent Memory Notebooks for durable per-agent notes |
valdr_record_materialized | Materialized Valdr records such as task snapshots |
Trust tiers influence ranking:
| Trust tier | Typical source |
|---|---|
canonical | First-party docs, primary specs, official project guidance |
operational | Runbooks, operator notes, project references |
memory | Agent Memory Notebook entries, draft observations, lower-confidence context |
get
List knowledge attachments and their underlying resources for a scope.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
scope | string | Yes | project, projects, global, or all |
projectId | string | Conditional | Required when scope is project |
projectIds | string[] | Conditional | Required when scope is projects |
includeDisabled | boolean | No | Include disabled attachments |
Example
pm_knowledge {
action: "get",
scope: "project",
projectId: "proj_checkout_01",
includeDisabled: false
}Returns attachment summaries, resource summaries, and stale/failed counts.
Project-scoped attachment summaries include projectKey alongside the stable scopeId. projectKey is only a readable convenience field; scopeId remains the canonical project identifier.
update_sources
Add, remove, enable, disable, or update source attachments for a project or global scope.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
scope | string | Yes | project or global |
projectId | string | Conditional | Required when scope is project |
operations | array | Yes | One or more source operations |
Operations
| Operation | Required fields | Notes |
|---|---|---|
add | knowledgeType, resourceKind, locator | Optional label, trustTier, rankingWeight, enabled |
remove | attachmentId | Detaches the source from the scope |
enable | attachmentId | Re-enables retrieval from the attachment |
disable | attachmentId | Keeps the attachment but excludes it by default |
update | attachmentId plus one mutable field | Can update label, trustTier, rankingWeight, or enabled |
Example
pm_knowledge {
action: "update_sources",
scope: "project",
projectId: "proj_checkout_01",
operations: [
{
op: "add",
knowledgeType: "code_intelligence",
resourceKind: "folder",
locator: "file:///workspace/acme-checkout/services/checkout/src",
label: "Checkout Service Source",
trustTier: "operational"
}
]
}Source policy rejects sensitive paths, over-broad global folders, unsupported source shapes, and project-scoped paths outside the project’s repository roots.
record_entry
Create, update, delete, or append managed knowledge records that are written through record_entry instead of update_sources.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
mode | string | Yes | create, update, delete, or append |
entryType | string | Yes | agent_knowledge or valdr_record_materialized |
scope | string | Yes | project or global |
projectId | string | Conditional | Required when scope is project |
entryId | string | Conditional | Required for update/delete |
title | string | No | Entry or note title |
body | string | No | Entry body |
trustTier | string | No | Defaults by entry type |
rankingWeight | number | No | 0.1 to 2.0 |
metadata | object | No | Caller-defined metadata |
Agent Memory Notebooks
Use mode: "append" with entryType: "agent_knowledge" to add a note to one Agent Memory Notebook per agent per scope.
pm_knowledge {
action: "record_entry",
mode: "append",
entryType: "agent_knowledge",
scope: "project",
projectId: "proj_checkout_01",
agentHandle: "checkout-reviewer",
title: "Reviewer memory",
body: "Prefer the mock gateway contract when testing refunds."
}Agent handles are normalized to lowercase. create and update are not valid for agent_knowledge; append adds memory, delete removes a notebook or a specific note.
Delete one note from a notebook:
pm_knowledge {
action: "record_entry",
mode: "delete",
entryType: "agent_knowledge",
scope: "project",
projectId: "proj_checkout_01",
entryId: "entry_checkout_reviewer_notes",
noteId: "note_checkout_reviewer_002"
}Materialized Valdr Records
Use valdr_record_materialized for structured snapshots of Valdr records.
pm_knowledge {
action: "record_entry",
mode: "create",
entryType: "valdr_record_materialized",
scope: "project",
projectId: "proj_checkout_01",
recordType: "task",
recordId: "CHECKOUT-42",
recordVersion: 1,
title: "Refund retry acceptance snapshot",
body: "Acceptance notes for retry behavior and alert routing.",
trustTier: "canonical"
}ingest
Queue resources for extraction, chunking, embedding, and code graph indexing.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
scope | string | No | Defaults to all when no explicit IDs are provided |
projectId | string | Conditional | Required when scope is project |
attachmentIds | string[] | No | Ingest exact attachments |
resourceIds | string[] | No | Ingest exact resources |
mode | string | No | incremental default, or rebuild |
execution | string | No | inline default, or background |
Selection precedence is attachmentIds, then resourceIds, then the resolved scope.
Example
pm_knowledge {
action: "ingest",
scope: "project",
projectId: "proj_checkout_01",
mode: "incremental",
execution: "background"
}incremental skips unchanged resources. rebuild re-extracts every chunk and refreshes derived indexes. background returns immediately while Valdr drains the ingest queue; inline waits for the run to finish.
search
Run filtered keyword or prose retrieval across indexed docs, records, notes, and code chunks.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
query | string | Yes | Search text |
scope | string | No | project, projects, global, or all |
projectId / projectIds | string / string[] | Conditional | Required for project scopes |
topK | number | No | 1 to 50, default 10 |
offset | number | No | Pagination offset |
retrievalMode | string | No | auto, lexical, semantic, or hybrid |
knowledgeTypes | string[] | No | Filter by source type |
resourceKinds | string[] | No | Filter by physical source shape |
trustTiers | string[] | No | Filter by trust tier |
languages | string[] | No | Filter code chunks by language |
symbolKinds | string[] | No | Filter code chunks by symbol kind |
pathPrefixes | string[] | No | Accepts file://, absolute, or project-relative prefixes |
exactToken | boolean | No | Require whole-token matches |
enabledOnly | boolean | No | Defaults to true |
includeContent | boolean | No | Include full chunk text in hits[].content |
includeScoreBreakdown | boolean | No | Legacy diagnostics switch; prefer responseProfile: "debug" |
responseProfile | string | No | compact, debug, or full; compact is the default |
Example
pm_knowledge {
action: "search",
scope: "project",
projectId: "proj_checkout_01",
query: "refund retry escalation",
retrievalMode: "hybrid",
topK: 10,
pathPrefixes: ["docs/runbooks"]
}Compact search hits include excerpts, source ids, line ranges when available, scores, and optional full content. Use responseProfile: "debug" or "full" for ranking reasons, score breakdowns, and expanded attachment diagnostics. When semantic retrieval is unavailable, the response reports why in semanticUnavailableReasons.
Compact search responses keep hits small by hoisting attachment summaries into an attachments map. Project-scoped attachment summaries include projectKey; hits refer to them by effectiveAttachmentId or attachmentIds.
code_map
Run symbol-oriented graph navigation grouped by role. Use this when the query is about definitions, callers, references, imports, tests, or docs for a symbol.
Query Patterns
| Intent | Pattern examples |
|---|---|
| Definition | definition of HttpClientBuilder, where is ConnectionPool defined |
| References | references to Future, where do we use RequestContext |
| Callers | callers of parseConfig, who calls normalizeRequest |
| Imports/exports | imports of HttpClientOptions, exports ConnectionPool |
| Tests | tests for CacheManager, where is retryPolicy tested |
| Docs | docs for deployment runbooks, documentation for release checklist |
Plain prose falls back to retrieval grouping. Rephrase into one of the patterns above when graph navigation matters.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
query | string | Yes | Symbol or graph-intent query |
scope | string | No | project, projects, global, or all |
projectId / projectIds | string / string[] | Conditional | Required for project scopes |
topK | number | No | Overall hit target |
knowledgeTypes | string[] | No | Filter source/result hits |
resourceKinds | string[] | No | Filter source/result hits |
languages | string[] | No | Filter by chunk language |
symbolKinds | string[] | No | Filter source/result symbol kinds |
pathPrefixes | string[] | No | Filter returned hits by path |
responseProfile | string | No | compact default, debug, or full |
includeDiagnostics | boolean | No | Infer debug when profile is omitted |
includeContent | boolean | No | Include chunk content |
includeRawRetrieval | boolean | No | Include raw flat retrieval payload |
maxTotalHits | number | No | Cap grouped hits |
maxHitsPerGroup | number | No | Cap each role group |
Example
pm_knowledge {
action: "code_map",
scope: "project",
projectId: "proj_checkout_01",
query: "definition of PaymentRetryPolicy",
languages: ["ts"],
pathPrefixes: ["services/checkout/src"],
topK: 20,
responseProfile: "compact"
}The response groups hits into definitions, references, imports, exports, tests, docs, and related. It also reports whether persisted symbol and reference graphs were used, so agents can distinguish graph-backed answers from retrieval fallback.
code_map does not accept search-only controls such as retrievalMode, exactToken, offset, trustTiers, attachmentIds, or includeScoreBreakdown. Use search for those controls.Language coverage
Not every indexed language answers code_map the same way. Knowing which tier a source sits in tells you whether an agent is reading a real graph or a ranked guess.
| Tier | Languages | What code_map returns |
|---|---|---|
| Full source graph | TypeScript/TSX (ts, tsx), Java (java), Rust (rs), Python (py, pyi) | Persisted symbols plus resolved reference edges: calls, imports, exports, implementations, types, and annotations |
| Structure only | Other indexed languages such as c, cpp, cs, dart, go, js, jsx, kt, php, rb, scala, swift | Structure-derived definitions and ranked retrieval grouping; reference edges are not persisted |
Use the languages parameter to keep a query inside the tier you expect. A code_map response reports whether persisted symbols and references were used, so agents can tell a graph-backed answer from a retrieval fallback without guessing.
cargo metadata --offline --no-deps. Missing Cargo, invalid manifests, timeouts, and optional or target-gated dependencies do not fail ingestion — the affected references simply stay unresolved. Cargo targets and path dependencies resolve when their source is indexed inside the same folder-backed knowledge source. Valdr does not download dependency source, and it does not link Rust references across separate knowledge sources.__all__ re-exports. Dynamic imports, reflection, monkey-patching, runtime-built __all__, wildcard bindings without provable literal exports, and ambiguous module layouts stay unresolved rather than guessed. Valdr does not inspect virtual environments, sys.path, or installed distributions, so third-party packages resolve only when their source is indexed.status
Fetch knowledge health counters for a scope. This is the quickest way to see whether sources have been ingested and whether code graph data exists.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
scope | string | No | Defaults to all |
projectId / projectIds | string / string[] | Conditional | Required for project scopes |
profile | string | No | summary or full |
Example
pm_knowledge {
action: "status",
scope: "project",
projectId: "proj_checkout_01"
}Returns counts for resources, attachments, entries, chunks, code chunks, docs chunks, symbols, references, stale resources, failed resources, indexed languages, and the active embedding model.
help
Return the canonical help payload from the MCP server. pm_knowledge has a specialized help shape because the tool combines source management, ingestion, prose search, and symbol-oriented code navigation in one action surface.
pm_knowledge { action: "help" }The help payload includes:
| Field | Contents |
|---|---|
actions | Every accepted pm_knowledge action: get, update_sources, record_entry, ingest, search, code_map, status, and help |
whenToUse | Focused guidance for choosing search for retrieval controls or code_map for symbol-oriented navigation |
queryPatterns | Recognized code_map templates such as definitions, references, callers, imports, tests, and docs queries |
examples | Representative calls grouped by action, currently search and code_map, so agents can copy the right parameter family |
cautions | Guardrails for compact output, search-only controls, debug/full profiles, symbol fallback, and pagination |
compatibility | Additive notes that preserve existing structured help keys and accepted pm_knowledge input schemas |
Use help when building an agent capability around Workspace Knowledge. Unlike the Vanguard registry tools, pm_knowledge groups examples by action and advertises queryPatterns so agents can distinguish plain retrieval from graph-backed code-map navigation. The compatibility field is additive and does not change accepted pm_knowledge calls.
Error Codes
Common knowledge errors:
| Code | Meaning |
|---|---|
KNOWLEDGE_INVALID_LOCATOR | Locator was not valid or could not be inspected |
KNOWLEDGE_PROJECT_REQUIRED | Project scope was missing a project ID |
KNOWLEDGE_SOURCE_OUTSIDE_PROJECT | Project source was outside the project’s repo roots |
KNOWLEDGE_SOURCE_TOO_BROAD | Global folder pointed at a system root or broad home/tmp path |
KNOWLEDGE_SOURCE_TOO_LARGE | Folder exceeded the source file limit |
KNOWLEDGE_SENSITIVE_SOURCE | Source matched a sensitive path or credential filename |
KNOWLEDGE_UNSUPPORTED_SOURCE_TYPE | Resource kind/type is not supported by the ingest path |
KNOWLEDGE_RESOURCE_NOT_FOUND | Targeted resource ID does not exist |
KNOWLEDGE_ATTACHMENT_NOT_FOUND | Targeted attachment ID does not exist |
KNOWLEDGE_INGEST_TARGET_REQUIRED | Ingest had no resolvable target |
KNOWLEDGE_RECORD_ENTRY_MODE_REQUIRED | record_entry was missing mode |
KNOWLEDGE_UNKNOWN_ACTION | Unknown action name |
Related
- Workspace Knowledge feature guide - product-level overview of workspace context, search, code map, and Agent Memory Notebooks workflow
- pm_project - projects provide the repo roots used by project-scoped knowledge
- pm_task - tasks can be materialized into durable knowledge records
- pm_agent - agents can record and later retrieve scoped notebook memory
- pm_health - verify the running MCP server and available tool inventory