MCPcopy Index your code
hub / github.com/PatrickSys/codebase-context / handle

Function handle

src/tools/search-codebase.ts:143–1318  ·  view source on GitHub ↗
(
  args: Record<string, unknown>,
  ctx: ToolContext
)

Source from the content-addressed store, hash-verified

141};
142
143export async function handle(
144 args: Record<string, unknown>,
145 ctx: ToolContext
146): Promise<ToolResponse> {
147 const { query, limit, filters, intent, includeSnippets, mode } = args as {
148 query?: unknown;
149 limit?: number;
150 filters?: Record<string, unknown>;
151 intent?: string;
152 includeSnippets?: boolean;
153 mode?: string;
154 };
155 const queryStr = typeof query === 'string' ? query.trim() : '';
156
157 if (!queryStr) {
158 return {
159 content: [
160 {
161 type: 'text',
162 text: JSON.stringify(
163 {
164 status: 'error',
165 errorCode: 'invalid_params',
166 message: "Invalid params: 'query' is required and must be a non-empty string.",
167 hint: "Provide a query like 'how are routes configured' or 'AlbumApiService'."
168 },
169 null,
170 2
171 )
172 }
173 ],
174 isError: true
175 };
176 }
177
178 if (ctx.indexState.status === 'indexing') {
179 return {
180 content: [
181 {
182 type: 'text',
183 text: JSON.stringify(
184 {
185 status: 'indexing',
186 message: 'Index is still being built. Retry in a moment.',
187 progress: ctx.indexState.indexer?.getProgress()
188 },
189 null,
190 2
191 )
192 }
193 ]
194 };
195 }
196
197 if (ctx.indexState.status === 'error') {
198 return {
199 content: [
200 {

Callers

nothing calls this directly

Calls 15

searchMethod · 0.95
readMemoriesFileFunction · 0.85
withConfidenceFunction · 0.85
readHealthFileFunction · 0.85
indexHealthByFileFunction · 0.85
normalizeGraphPathFunction · 0.85
getMemoryTextMatchCountFunction · 0.85
getMemoryScopeBoostFunction · 0.85
getImportsGraphFunction · 0.85
assessSearchQualityFunction · 0.85
computeImpactCandidatesFunction · 0.85
computeIndexConfidenceFunction · 0.85

Tested by

no test coverage detected