-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathget-indexing-status.ts
More file actions
56 lines (53 loc) · 1.72 KB
/
get-indexing-status.ts
File metadata and controls
56 lines (53 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
import type { ToolContext, ToolResponse } from './types.js';
export const definition: Tool = {
name: 'get_indexing_status',
description:
'Get current indexing status: state, statistics, and progress. ' +
'Use refresh_index to manually trigger re-indexing when needed.',
inputSchema: {
type: 'object',
properties: {}
}
};
export async function handle(
_args: Record<string, unknown>,
ctx: ToolContext
): Promise<ToolResponse> {
const progress = ctx.indexState.indexer?.getProgress();
return {
content: [
{
type: 'text',
text: JSON.stringify(
{
status: ctx.indexState.status,
rootPath: ctx.rootPath,
lastIndexed: ctx.indexState.lastIndexed?.toISOString(),
stats: ctx.indexState.stats
? {
totalFiles: ctx.indexState.stats.totalFiles,
indexedFiles: ctx.indexState.stats.indexedFiles,
totalChunks: ctx.indexState.stats.totalChunks,
duration: `${(ctx.indexState.stats.duration / 1000).toFixed(2)}s`,
incremental: ctx.indexState.stats.incremental
}
: undefined,
progress: progress
? {
phase: progress.phase,
percentage: progress.percentage,
filesProcessed: progress.filesProcessed,
totalFiles: progress.totalFiles
}
: undefined,
error: ctx.indexState.error,
hint: 'Use refresh_index to manually trigger re-indexing when needed.'
},
null,
2
)
}
]
};
}