MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / execute

Method execute

src/codegraph/tools.ts:36–66  ·  view source on GitHub ↗
(args: z.infer<typeof FindSymbolArgs>, ctx: ToolContext)

Source from the content-addressed store, hash-verified

34 argsSchema = FindSymbolArgs;
35
36 async execute(args: z.infer<typeof FindSymbolArgs>, ctx: ToolContext): Promise<ToolResult> {
37 const db = requireDB();
38 if ('error' in db) return { content: db.error, isError: true };
39
40 const rows = db.findSymbolsByName(args.name, args.kind);
41 if (rows.length === 0) {
42 // Try prefix search as a hint
43 const prefixMatches = db.searchSymbolsByPrefix(args.name, args.kind, 10);
44 if (prefixMatches.length > 0) {
45 const hints = prefixMatches.slice(0, 8).map(r => ` ${r.kind} ${r.name} → ${path.relative(ctx.cwd, r.file_path)}:${r.start_line}`).join('\n');
46 return {
47 content: `[NOT_FOUND] No ${args.kind ?? 'symbol'} named exactly "${args.name}". Did you mean one of:\n${hints}`,
48 isError: false,
49 };
50 }
51 return {
52 content: `[NOT_FOUND] No ${args.kind ?? 'symbol'} named "${args.name}" in the indexed codebase. If you recently added it, run /index to refresh.`,
53 isError: false,
54 };
55 }
56
57 const lines = rows.map(r => {
58 const rel = path.relative(ctx.cwd, r.file_path);
59 const sig = r.signature ? ` ${r.signature}` : '';
60 return `${r.kind} ${r.name} → ${rel}:${r.start_line}${sig ? '\n' + sig : ''}`;
61 });
62 return {
63 content: `Found ${rows.length} definition${rows.length > 1 ? 's' : ''}:\n${lines.join('\n')}`,
64 metadata: { count: rows.length },
65 };
66 }
67}
68
69// ---------------- search_symbols (prefix) ----------------

Callers

nothing calls this directly

Calls 3

requireDBFunction · 0.85
findSymbolsByNameMethod · 0.80
searchSymbolsByPrefixMethod · 0.80

Tested by

no test coverage detected