show_file_words
Retrieve indexed words and metadata from files using KDE's Baloo search system to analyze content and properties of specific documents.
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)MCP tool handler that invokes the showFileWords helper, serializes results to 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:113-115 (schema)Zod input schema defining the 'path' parameter for the tool.{ 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 MCP server, including description, input schema, and handler function.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 runs 'balooshow -x' command to extract indexed words from a file and returns path and words array.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}`) } }