list_schemas
Lists all loaded schemas with names, descriptions, and types (note or folder) to help you understand available conventions.
Instructions
Lists all loaded schemas. No arguments. Returns { root, schemas[] } where each schema has name, description, type (note|folder), and type-specific details.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/schema-tools.ts:175-204 (handler)Handler function for list_schemas tool. Calls services.schema.refresh() then listSchemas() and returns the list of loaded schemas.
function makeListSchemasTool(container: ServiceContainer): ToolHandler { return { name: "list_schemas", description: "Lists all loaded schemas. No arguments. Returns `{ root, schemas[] }` where each schema has `name`, `description`, `type` (`note`|`folder`), and type-specific details.", inputSchema: ListSchemasSchema, async handler(_args): Promise<ToolResponse> { try { const services = requireServices(container); log.info("list_schemas called"); await services.schema.refresh(); const schemas = services.schema.listSchemas(); log.info({ count: schemas.length }, "list_schemas complete"); return { content: [{ type: "text", text: JSON.stringify({ root: getRoot(container), schemas }, null, 2) }], }; } catch (err) { log.error({ err }, "list_schemas failed"); return { content: [{ type: "text", text: JSON.stringify({ root: getRoot(container), error: err instanceof Error ? err.message : String(err), possibleSolutions: ["Check the schemas directory is configured correctly", "Verify schema YAML files are valid"], }) }], isError: true, }; } }, }; } - src/tools/schema-tools.ts:173-173 (schema)Input schema for list_schemas — takes no arguments (empty object).
const ListSchemasSchema = z.object({}); - src/tools/schema-tools.ts:269-284 (registration)Registration function that registers list_schemas (and other schema tools) into the tool registry map.
export function registerSchemaTools( registry: Map<string, ToolHandler>, container: ServiceContainer, ): void { const tools = [ makeLintNoteTool(container), makeValidateFolderTool(container), makeValidateAreaTool(container), makeValidateAllTool(container), makeListSchemasTool(container), ]; for (const tool of tools) { registry.set(tool.name, tool); } } - src/tools/index.ts:38-50 (registration)Whitelist entry — list_schemas is exposed in --lite mode as part of schema lint tools.
export const LITE_TOOL_NAMES: ReadonlySet<string> = new Set([ // Schema / lint "lint_note", "validate_folder", "validate_area", "validate_all", "list_schemas", // Link graph "find_broken_links", "find_orphans", "find_unlinked_mentions", "find_bidirectional_mentions", "get_backlinks", - Implements SchemaEngine.listSchemas(), delegates to SchemaRegistry.listAll() to collect all loaded schemas.
listSchemas(): SchemaInfo[] { return this.registry.listAll(); } // ========================================================================== // Private helpers // ========================================================================== private async lintNoteWithPreRead( notePath: string, preReadNote?: ParsedNote, vaultIndex?: VaultIndex, ): Promise<LintResult> { if (preReadNote) { let schema: NoteSchema | null = null; if (typeof preReadNote.frontmatter.note_schema === "string") { schema = this.registry.getNoteSchema(preReadNote.frontmatter.note_schema); } if (!schema) { schema = this.resolveNoteSchema(notePath); } return this.noteEngine.lintNote(notePath, schema, preReadNote, vaultIndex); } return this.lintNote(notePath); } /** * True if any registered note schema has a `noBrokenWikilinks` content rule. * Used to skip the O(N) vault read when no folder/area validation needs it. */ private schemaNeedsVaultIndex(schema: NoteSchema): boolean { return schema.content.rules.some((r) => r.check === "noBrokenWikilinks"); } private anyRegisteredSchemaNeedsVaultIndex(): boolean { for (const info of this.registry.listAll()) { if (info.type !== "note") continue; const noteSchema = this.registry.getNoteSchema(info.name); if (noteSchema && this.schemaNeedsVaultIndex(noteSchema)) return true; } return false; } /** * Build a vault index once if any note schema relies on `noBrokenWikilinks`. * Returns undefined when the index would be unused — saves an O(N) read pass. */ private async maybeBuildVaultIndex(): Promise<VaultIndex | undefined> { if (!this.anyRegisteredSchemaNeedsVaultIndex()) return undefined; return await buildVaultIndex(this.file); } private isLikelyHub(notePath: string, folderSchema: FolderSchema): boolean { if (!folderSchema.hub?.detection) return false; const folderName = path.basename(path.dirname(normalizePath(notePath))); const filename = path.basename(notePath); for (const rule of folderSchema.hub.detection) { if ("pattern" in rule) { const target = expandHubPattern(rule.pattern, folderName); if (filename === target) return true; } // Skip fallback rules — full detection runs during validateFolder } return false; } }