list_corpora
Discover all saved corpora on disk with their manifest details including scope, project root, sizes, and timestamps to identify which corpora are available for querying.
Instructions
List every corpus saved on disk with its manifest (scope, project_root, sizes, timestamps). Read-only. Use to discover what corpora are available to query.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/register/knowledge.ts:121-131 (handler)Handler: The MCP tool handler for 'list_corpora'. Lists all saved corpora on disk by calling corpora.list() and returns the array of manifests with a total count. No input schema needed (empty object).
server.tool( 'list_corpora', 'List every corpus saved on disk with its manifest (scope, project_root, sizes, timestamps). Read-only. Use to discover what corpora are available to query.', {}, async () => { const items = corpora.list(); return { content: [{ type: 'text', text: j({ corpora: items, total: items.length }) }], }; }, ); - src/memory/corpus-store.ts:186-203 (helper)Helper: CorpusStore.list() — iterates over the corpora directory, reads each .json manifest file, validates name against NAME_PATTERN, loads the manifest, and returns them sorted alphabetically.
/** List every corpus manifest currently on disk. */ list(): CorpusManifest[] { if (!fs.existsSync(this.rootDir)) return []; const entries = fs.readdirSync(this.rootDir, { withFileTypes: true }); const out: CorpusManifest[] = []; for (const entry of entries) { if (!entry.isFile()) continue; if (!entry.name.endsWith('.json')) continue; const name = entry.name.slice(0, -'.json'.length); // Hidden / sidecar files (e.g. .DS_Store after `.json` strip) are // trivially rejected by NAME_PATTERN. if (!NAME_PATTERN.test(name)) continue; const manifest = this.load(name); if (manifest !== null) out.push(manifest); } out.sort((a, b) => a.name.localeCompare(b.name)); return out; } - src/server/server.ts:601-601 (registration)Registration: The call to registerKnowledgeTools which registers all knowledge tools (including list_corpora) on the MCP server during server initialization.
registerKnowledgeTools(server, ctx); - src/memory/corpus-store.ts:34-59 (schema)Schema: CorpusManifest interface — the type definition for each corpus manifest returned by list_corpora. Contains name, scope, sizes, timestamps, and other metadata.
export interface CorpusManifest { /** User-supplied slug; primary key. */ name: string; /** Absolute path of the project this corpus was built from. */ projectRoot: string; /** Pack scope: project (whole repo) / module (subdir) / feature (NL query). */ scope: CorpusScope; /** Subdirectory path when scope=module. */ modulePath?: string; /** Natural-language query when scope=feature. */ featureQuery?: string; /** Token budget passed to packContext. */ tokenBudget: number; /** Symbols included (count after pack). */ symbolCount: number; /** Files included (count after pack). */ fileCount: number; /** Approximate token count of the packed text. */ estimatedTokens: number; /** Provider used to embed / pack (informational). */ packStrategy: 'most_relevant' | 'core_first' | 'compact'; createdAt: string; updatedAt: string; /** Free-form description from the user. */ description?: string; }