Skip to main content
Glama

available-files

List and identify available files and resources by retrieving details like URI, name, size, last modified, and mime type in a markdown table. Use to pinpoint specific resources such as recent images or audio files.

Instructions

A list of available file and resources. If the User requests things like 'most recent image' or 'the audio' use this tool to identify the intended resource.This tool returns 'resource uri', 'name', 'size', 'last modified' and 'mime type' in a markdown table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:81-91 (registration)
    Tool registration for 'available-files' with name, description, and empty input schema
    name: AVAILABLE_FILES, description: "A list of available file and resources. " + "If the User requests things like 'most recent image' or 'the audio' use " + "this tool to identify the intended resource." + "This tool returns 'resource uri', 'name', 'size', 'last modified' and 'mime type' in a markdown table", inputSchema: { type: "object", properties: {}, }, },
  • Main handler for 'available-files' tool call that returns a resource with the generated file table
    server.setRequestHandler(CallToolRequestSchema, async (request) => { if (AVAILABLE_FILES === request.params.name) { return { content: [ { type: `resource`, resource: { uri: `resource://mcp-hfspace/available-files`, mimeType: `text/markdown`, text: await workingDir.generateResourceTable(), }, }, ], }; }
  • Core implementation logic that generates the markdown table of available files with URI, name, MIME type, size, and last modified details
    async generateResourceTable(): Promise<string> { const files = await this.listFiles(); const resources = await Promise.all( files .filter((entry) => entry.isFile()) .map(async (entry) => await this.getResourceFile(entry)), ); if (resources.length === 0) { return "No resources available."; } return ` The following resources are available for tool calls: | Resource URI | Name | MIME Type | Size | Last Modified | |--------------|------|-----------|------|---------------| ${resources .map( (f) => `| ${f.uri} | ${f.name} | ${f.mimeType} | ${this.formatFileSize(f.size)} | ${f.lastModified.toISOString()} |`, ) .join("\n")} Prefer using the Resource URI for tool parameters which require a file input. URLs are also accepted.`.trim(); }
  • Helper method to get file metadata including URI, name, MIME type, size, and last modified timestamp
    async getResourceFile(file: Dirent): Promise<ResourceFile> { const fullPath = path.join(file.parentPath || "", file.name); const relativePath = path .relative(this.directory, fullPath) .replace(/\\/g, "/"); const stats = await fs.stat(fullPath); return { uri: `file:./${relativePath}`, name: file.name, mimeType: mime.getType(file.name) || FALLBACK_MIME_TYPE, size: stats.size, lastModified: stats.mtime, }; }
  • Helper method to format file sizes from bytes to human-readable format (B, KB, MB, GB)
    formatFileSize(bytes: number): string { const units = ["B", "KB", "MB", "GB"]; let size = bytes; let unitIndex = 0; while (size >= 1024 && unitIndex < units.length - 1) { size /= 1024; unitIndex++; } return `${size.toFixed(1)} ${units[unitIndex]}`; }

Other Tools

Related 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/evalstate/mcp-hfspace'

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