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

Function handler

packages/tools/src/definitions/search.ts:25–50  ·  view source on GitHub ↗
(params: Record<string, unknown>, context: ToolExecutionContext)

Source from the content-addressed store, hash-verified

23}
24
25async function handler(params: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult> {
26 const keyword = params.keyword as string
27 const limit = (params.limit as number) || 50
28
29 const result = await context.dataProvider!.searchMessages([keyword], {
30 timeFilter: context.timeFilter,
31 limit,
32 })
33
34 const data = {
35 total: result.total,
36 returned: result.messages.length,
37 hasMore: result.messages.length < result.total,
38 messages: result.messages.map((m) => ({
39 sender: m.senderName,
40 content: m.content,
41 time: new Date(m.timestamp * 1000).toISOString(),
42 })),
43 }
44
45 return {
46 content: JSON.stringify(data),
47 data,
48 rawMessages: result.messages,
49 }
50}
51
52export const searchTool: ToolDefinition = {
53 name: 'search_keyword',

Callers 3

getFunction · 0.50
allFunction · 0.50
withMaterializedChatMethod · 0.50

Calls 1

searchMessagesMethod · 0.65

Tested by 2

getFunction · 0.40
allFunction · 0.40