show_file_words
Retrieve indexed words and metadata from a specific file using KDE's Baloo search system to analyze file content and properties.
Instructions
Show indexed content & meta-data in a file using KDE balooshow.
This tool retrieves all the indexed words & meta-data from a specific file that has been indexed by KDE's Baloo search system.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The absolute path to the file to show indexed words & meta-data for |
Implementation Reference
- src/server/mcp-server.js:116-127 (handler)The MCP tool handler for 'show_file_words' that calls the showFileWords helper, formats the result as JSON, and handles errors.async ({ path }) => { try { const results = await showFileWords({ path }) return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] } } catch (error) { return { content: [{ type: "text", text: `Error showing file words: ${error.message}` }] } } }
- src/server/mcp-server.js:114-115 (schema)Zod input schema for the 'show_file_words' tool, requiring a 'path' string parameter.path: z.string().describe("The absolute path to the file to show indexed words & meta-data for") },
- src/server/mcp-server.js:108-128 (registration)Registration of the 'show_file_words' tool with the MCP server, including name, description, schema, and handler.server.tool( "show_file_words", `Show indexed content & meta-data in a file using KDE balooshow. This tool retrieves all the indexed words & meta-data from a specific file that has been indexed by KDE's Baloo search system.`, { path: z.string().describe("The absolute path to the file to show indexed words & meta-data for") }, async ({ path }) => { try { const results = await showFileWords({ path }) return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] } } catch (error) { return { content: [{ type: "text", text: `Error showing file words: ${error.message}` }] } } } )
- src/tools/baloosearch-tool.js:79-105 (helper)Helper function that executes the balooshow command to retrieve indexed words from the specified file path.export async function showFileWords({ path }) { // Validate inputs if (!path || typeof path !== 'string') { throw new Error('Path is required and must be a string') } // Build the balooshow command let command = `balooshow -x "${path}"` try { // Execute the command const { stdout, stderr } = await execPromise(command) // Parse the output const lines = stdout.trim().split('\n').filter(line => line.length > 0) // Filter out any empty lines or error messages const words = lines.filter(line => !line.startsWith('Elapsed:') && line.trim() !== '') return { path: path, words: words } } catch (error) { throw new Error(`Failed to execute balooshow: ${error.message}`) } }