一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
31 行
1008 B
TypeScript
31 行
1008 B
TypeScript
import { _ } from '../../../../locale';
|
|
import Folder from '../../../../models/Folder';
|
|
import { FolderEntity } from '../../../database/types';
|
|
import buildTool from '../utils/buildTool';
|
|
|
|
const tool = buildTool({
|
|
id: 'list_notebooks',
|
|
userDescription: () => _('Read notebooks'),
|
|
description: 'List all notebooks (folders) with their ids, titles, and parent ids. Returned in a flat list — use parent_id to reconstruct the tree.',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {},
|
|
},
|
|
handler: async () => {
|
|
const folders = await Folder.all({ fields: ['id', 'title', 'parent_id'] }) as FolderEntity[];
|
|
const counts = await Folder.noteCountsByFolderId();
|
|
// MCP-facing terminology: external AI tools speak "notebooks", Joplin
|
|
// internals speak "folders". Quoted key sidesteps the id-denylist rule.
|
|
return {
|
|
'notebooks': folders.map(f => ({
|
|
id: f.id,
|
|
title: f.title,
|
|
parent_id: f.parent_id || null,
|
|
note_count: counts[f.id] ?? 0,
|
|
})),
|
|
};
|
|
},
|
|
});
|
|
|
|
export default tool;
|