MCPcopy Create free account
hub / github.com/PatrickSys/codebase-context / handle

Function handle

src/tools/get-symbol-references.ts:26–94  ·  view source on GitHub ↗
(
  args: Record<string, unknown>,
  ctx: ToolContext
)

Source from the content-addressed store, hash-verified

24};
25
26export async function handle(
27 args: Record<string, unknown>,
28 ctx: ToolContext
29): Promise<ToolResponse> {
30 const { symbol, limit } = args as { symbol?: unknown; limit?: unknown };
31 const normalizedSymbol = typeof symbol === 'string' ? symbol.trim() : '';
32 const normalizedLimit =
33 typeof limit === 'number' && Number.isFinite(limit) && limit > 0 ? Math.floor(limit) : 10;
34
35 if (!normalizedSymbol) {
36 return {
37 content: [
38 {
39 type: 'text',
40 text: JSON.stringify(
41 {
42 status: 'error',
43 message: "Invalid params: 'symbol' is required and must be a non-empty string."
44 },
45 null,
46 2
47 )
48 }
49 ],
50 isError: true
51 };
52 }
53
54 const result = await findSymbolReferences(ctx.rootPath, normalizedSymbol, normalizedLimit);
55
56 if (result.status === 'error') {
57 return {
58 content: [
59 {
60 type: 'text',
61 text: JSON.stringify(
62 {
63 status: 'error',
64 symbol: normalizedSymbol,
65 message: result.message
66 },
67 null,
68 2
69 )
70 }
71 ]
72 };
73 }
74
75 return {
76 content: [
77 {
78 type: 'text',
79 text: JSON.stringify(
80 {
81 status: 'success',
82 symbol: result.symbol,
83 usageCount: result.usageCount,

Callers

nothing calls this directly

Calls 1

findSymbolReferencesFunction · 0.85

Tested by

no test coverage detected