search_system_json
Search and retrieve relevant system JSON files by querying the Advanced Reasoning MCP Server, providing matches with relevance scores for enhanced analysis and decision-making.
Instructions
Search through system JSON files by query.
Parameters:
query: Search query to find matching system JSON files (required)
Returns matching files with relevance scores.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query to find matching system JSON files |
Implementation Reference
- src/index.ts:177-205 (handler)Core implementation of the search logic in the SystemJSON class. Scans the system_json directory, parses each JSON file, calculates a relevance score using word overlap, and returns sorted results if score > 0.1.async searchSystemJSON(query: string): Promise<{ results: Array<{ name: string; score: number; data: SystemJSONData }> }> { try { const files = await fs.readdir(this.systemJsonPath); const results: Array<{ name: string; score: number; data: SystemJSONData }> = []; for (const file of files) { if (file.endsWith('.json') && !file.endsWith('.tmp')) { try { const filePath = path.join(this.systemJsonPath, file); const jsonContent = await fs.readFile(filePath, 'utf-8'); const data = JSON.parse(jsonContent) as SystemJSONData; const score = this.calculateSearchScore(query, data); if (score > 0.1) { results.push({ name: data.name, score, data }); } } catch (error) { // Skip corrupted files console.error(`Skipping corrupted system JSON file: ${file}`, error); } } } return { results: results.sort((a, b) => b.score - a.score) }; } catch (error) { console.error('Failed to search system JSON:', error); return { results: [] }; } }
- src/index.ts:981-1013 (handler)Wrapper handler in AdvancedReasoningServer that calls the core SystemJSON search method and formats the response as MCP tool content.public async searchSystemJSON(query: string): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> { try { const result = await this.systemJson.searchSystemJSON(query); return { content: [{ type: "text", text: JSON.stringify({ query, results: result.results.map(r => ({ name: r.name, score: r.score, domain: r.data.domain, description: r.data.description, tags: r.data.tags })), totalResults: result.results.length }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), status: 'failed' }, null, 2) }], isError: true }; } }
- src/index.ts:1265-1271 (schema)Input schema for the search_system_json tool, defining the required 'query' string parameter.inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query to find matching system JSON files" } }, required: ["query"] }
- src/index.ts:1303-1315 (registration)Registration of the search_system_json tool (as SEARCH_SYSTEM_JSON_TOOL) in the ListToolsRequestSchema handler.tools: [ ADVANCED_REASONING_TOOL, QUERY_MEMORY_TOOL, CREATE_LIBRARY_TOOL, LIST_LIBRARIES_TOOL, SWITCH_LIBRARY_TOOL, GET_LIBRARY_INFO_TOOL, CREATE_SYSTEM_JSON_TOOL, GET_SYSTEM_JSON_TOOL, SEARCH_SYSTEM_JSON_TOOL, LIST_SYSTEM_JSON_TOOL ], }));
- src/index.ts:1356-1359 (registration)Tool execution dispatcher case in CallToolRequestSchema handler that invokes the search handler for search_system_json.case "search_system_json": const { query: searchQuery } = args as { query: string }; return await reasoningServer.searchSystemJSON(searchQuery);