available-files
Lists available files and resources in the Hugging Face Spaces environment, helping users identify specific items like recent images or audio files by displaying their URIs, names, sizes, and metadata.
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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:98-111 (handler)Handler logic for the 'available-files' tool call. Returns a markdown-formatted resource table generated by WorkingDirectory.generateResourceTable().if (AVAILABLE_FILES === request.params.name) { return { content: [ { type: `resource`, resource: { uri: `/available-files`, mimeType: `text/markdown`, text: await workingDir.generateResourceTable(), }, }, ], }; }
- src/index.ts:78-92 (registration)Registration of the 'available-files' tool in the ListTools response, including 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: {}, }, }, ...Array.from(endpoints.values()).map((endpoint) => endpoint.toolDefinition(), ),
- src/working_directory.ts:132-156 (helper)Helper method in WorkingDirectory class that generates the markdown table listing all available files/resources with URI, name, MIME type, size, and last modified date.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(); }
- src/index.ts:85-89 (schema)Input schema for the 'available-files' tool: an empty object (no parameters).inputSchema: { type: "object", properties: {}, }, },