Skip to main content
Glama

search_text

Find specific text strings within binary files during reverse engineering analysis. Specify search parameters like case sensitivity and address ranges to locate code or data patterns.

Instructions

Search for text in the binary

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to search for
caseSensitiveNoWhether the search is case sensitive (default: false)
startAddressNoStart address for search (optional)
endAddressNoEnd address for search (optional)

Implementation Reference

  • The handler function for the 'search_text' tool. Validates input using isValidSearchTextArgs, connects to MongoDB, queries the 'strings' collection for matching text using regex (case-insensitive), formats results with memory addresses and text, and returns them as tool content.
    case 'search_text': if (!isValidSearchTextArgs(request.params.arguments)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid search text arguments' ); } try { const { text, caseSensitive, startAddress, endAddress } = request.params.arguments; /*const result = await ida.searchForText(text, { caseSensitive, startAddress, endAddress });*/ await client.connect(); db = client.db(dbName); collection = db.collection("strings"); let searchFor = "lua"; let newRegex = new RegExp(text, "i"); collection = db.collection("strings"); let res = await collection.find({ "TEXT": newRegex }) let result = await res.toArray() let result_count = result.length; let result_str = ""; for (let i = 0; i < result.length; i++) { result_str += ` ${result[i].MEMORY_ADDR} ${result[i].TEXT} \n` } return { content: [ { type: 'text', text: `Found ${result_count} \n\n ${result_str}`, }, ], } } catch (error: any) { return { content: [ { type: 'text', text: `Error searching for text: ${error.message || error}`, }, ], isError: true, }; } break;
  • TypeScript interface defining the input arguments for the search_text tool.
    interface SearchTextArgs { text: string; caseSensitive?: boolean; startAddress?: string | number; endAddress?: string | number; }
  • index.ts:262-287 (registration)
    Tool registration in the ListTools handler, including name, description, and input schema matching SearchTextArgs.
    { name: 'search_text', description: 'Search for text in the binary', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'Text to search for', }, caseSensitive: { type: 'boolean', description: 'Whether the search is case sensitive (default: false)', }, startAddress: { type: 'string', description: 'Start address for search (optional)', }, endAddress: { type: 'string', description: 'End address for search (optional)', }, }, required: ['text'], }, },
  • Validation function to check if arguments conform to SearchTextArgs interface, used in the handler.
    const isValidSearchTextArgs = (args: any): args is SearchTextArgs => { return ( typeof args === 'object' && args !== null && typeof args.text === 'string' ); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fdrechsler/mcp-server-idapro'

If you have feedback or need assistance with the MCP directory API, please join our Discord server