MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / handler

Function handler

packages/tools/src/definitions/sessions.ts:27–47  ·  view source on GitHub ↗
(_params: Record<string, unknown>, context: SessionListContext)

Source from the content-addressed store, hash-verified

25}
26
27function handler(_params: Record<string, unknown>, context: SessionListContext): ToolResult {
28 const keyword = (_params.keyword as string | undefined)?.toLowerCase()
29 const sessionIds = context.listSessionIds()
30
31 const sessions = sessionIds
32 .map((id) => {
33 const db = context.openDb(id)
34 if (!db) return null
35 const meta = getSessionMeta(db)
36 if (!meta) return null
37 if (keyword && !meta.name.toLowerCase().includes(keyword)) return null
38 const overview = getSessionOverview(db)
39 return { id, ...meta, ...overview }
40 })
41 .filter(Boolean)
42
43 return {
44 content: JSON.stringify({ total: sessions.length, sessions }),
45 data: sessions,
46 }
47}
48
49export const sessionsListTool: ToolDefinition = {
50 name: 'list_sessions',

Callers

nothing calls this directly

Calls 3

getSessionMetaFunction · 0.90
getSessionOverviewFunction · 0.90
listSessionIdsMethod · 0.65

Tested by

no test coverage detected