search_registry
Search the Windows registry by a specified keyword to retrieve entries, with options to limit results. Part of the Windows Diagnostics MCP Server for system analysis.
Instructions
Search the Windows registry by keyword
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | Maximum number of results to return (default: 50) | |
| searchTerm | Yes | Keyword to search for in the registry |
Implementation Reference
- src/tools/registry.ts:11-48 (handler)The main handler function that executes the 'search_registry' tool. It runs a PowerShell script to search the registry, processes the JSON results, formats them into a markdown list, and returns an MCP-formatted response.
export async function searchRegistry(args: { searchTerm?: string; maxResults?: number }) { const searchTerm = args.searchTerm ?? ''; const maxResults = args.maxResults ?? 50; const result = await runPowerShellScript( REGISTRY_SCRIPT, { SearchTerm: searchTerm, MaxResults: maxResults, JsonOutput: true, } ) as AllTypes.RegistryDiagnosticResults; const searchResultsText = result.SearchResults && result.SearchResults.length > 0 ? result.SearchResults .map( r => `- **Path**: ${r.Path} **Type**: ${r.Type} **Match**: ${r.Match} **Found**: ${r.Found || 'N/A'} **Value**: ${r.ValueName || 'N/A'} **Data**: ${r.ValueData || 'N/A'}` ) .join('\n\n') : 'No results found.'; return { content: [ { type: 'text', text: `# Registry Search Results for "${searchTerm}" ${searchResultsText}`, }, ], }; } - src/index.ts:121-135 (schema)The input schema definition for the 'search_registry' tool, specifying parameters searchTerm (required string) and maxResults (optional number, default 50).
inputSchema: { type: 'object', properties: { searchTerm: { type: 'string', description: 'Keyword to search for in the registry' }, maxResults: { type: 'number', description: 'Maximum number of results to return (default: 50)', default: 50 } }, required: ['searchTerm'] } - src/index.ts:549-550 (registration)The dispatch registration in the CallToolRequestSchema handler that routes calls to the searchRegistry function.
case 'search_registry': return await registry.searchRegistry(args as { searchTerm?: string; maxResults?: number }); - src/index.ts:118-136 (registration)The tool registration in the ListToolsRequestSchema handler, including name, description, and input schema.
{ name: 'search_registry', description: 'Search the Windows registry by keyword', inputSchema: { type: 'object', properties: { searchTerm: { type: 'string', description: 'Keyword to search for in the registry' }, maxResults: { type: 'number', description: 'Maximum number of results to return (default: 50)', default: 50 } }, required: ['searchTerm'] } },