Skip to main content
Glama
el95149

Baloosearch MCP Server

by el95149

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
NameRequiredDescriptionDefault
pathYesThe absolute path to the file to show indexed words & meta-data for

Implementation Reference

  • 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}` }]
        }
      }
    }
  • 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")
    },
  • 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}` }]
          }
        }
      }
    )
  • 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}`)
      }
    }
Install Server

Other Tools

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/el95149/baloosearch-mcp'

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