Find Orphaned Notes
links.orphanedIdentify notes with no incoming or outgoing links. Use this to clean up disconnected content in your vault.
Instructions
Return every note with zero incoming AND zero outgoing links — i.e., notes that are disconnected from the rest of the vault graph. Useful for cleanup passes. Read-only. Often paired with links.hubs and links.broken in a weekly vault-health routine.
Operates on the session-active vault (see vault.current — selectable via vault.select) unless an explicit vaultPath argument is passed, which always wins.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vaultPath | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| total | Yes | Number of items in `items`. | |
| items | Yes | List of result items; per-item shape depends on the tool. |
Implementation Reference
- src/domain/links.ts:289-295 (handler)Core handler function for 'links.orphaned'. Builds the full link graph then filters for notes with zero inlinks AND zero outlinks (disconnected from the graph). Returns the list of orphaned file paths.
export async function findOrphanedNotes(context: DomainContext, args: { vaultPath?: string }) { const graph = (await getLinkGraph(context, args)).graph; const items = Object.entries(graph) .filter(([, value]) => value.inlinks.length === 0 && value.outlinks.length === 0) .map(([filePath]) => ({ filePath, inlinkCount: 0, outlinkCount: 0 })); return { items, total: items.length }; } - src/schema/links.ts:49-50 (schema)Input schema for 'links.orphaned' — accepts an optional vaultPath string.
export const linksOrphanedArgsSchema = z.object({ vaultPath: z.string().optional() }).strict(); export type LinksOrphanedArgs = z.input<typeof linksOrphanedArgsSchema>; - src/server/tools/links.ts:85-97 (registration)Tool registration for 'links.orphaned' in the linkTools array. Maps the tool name to input schema, output schema, and handler.
{ name: "links.orphaned", title: "Find Orphaned Notes", description: "Return every note with zero incoming AND zero outgoing links — i.e., notes that are disconnected from the rest of the vault graph. Useful for cleanup passes. Read-only. Often paired with `links.hubs` and `links.broken` in a weekly vault-health routine.", inputSchema: linksOrphanedArgsSchema, outputSchema: listResultSchema, annotations: READ_ONLY, handler: async (context, rawArgs) => { const args = linksOrphanedArgsSchema.parse(rawArgs) as LinksOrphanedArgs; return findOrphanedNotes(context, args); }, },