Skip to main content
Glama

delete_file

Remove files from storage systems using file keys or names to manage disk space and organize data.

Instructions

Delete a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesThe file key/name to delete

Implementation Reference

  • MCP tool handler for 'delete_file': extracts key argument, logs the operation, calls storage.delete(key), and returns a JSON response with success status and message.
    case 'delete_file': { const { key } = args as { key: string }; logger.info('Tool request received', { operation: 'tool:delete', toolName: 'delete_file', key, requestId }); const deleted = await storage.delete(key, requestId); return { content: [{ type: 'text', text: JSON.stringify({ success: deleted, message: deleted ? `File '${key}' deleted successfully` : `File '${key}' not found`, key }, null, 2) }] }; }
  • Input schema definition for the 'delete_file' tool, specifying a required 'key' string parameter.
    inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'The file key/name to delete', }, }, required: ['key'], },
  • src/index.ts:138-150 (registration)
    Registration of the 'delete_file' tool in the ListToolsRequestSchema response, including name, description, and input schema.
    name: 'delete_file', description: 'Delete a file', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'The file key/name to delete', }, }, required: ['key'], }, },
  • FileStorage.delete method: implements file deletion using fs.unlink with path sanitization, locking for concurrency, and proper error handling (returns false if not found).
    async delete(key: string, requestId: string): Promise<boolean> { const releaseLock = await this.acquireLock(key); const filePath = this.getFilePath(key); try { logger.debug('Deleting file', { operation: 'delete', key, filePath, requestId }); await fs.unlink(filePath); logger.info('File deleted successfully', { operation: 'delete', key, requestId }); return true; } catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') { logger.warn('File not found for deletion', { operation: 'delete', key, requestId }); return false; } logger.error('Failed to delete file', error as Error, { operation: 'delete', key, requestId }); throw error; } finally { releaseLock(); } }
  • Identical MCP tool handler for 'delete_file' in the multimode variant (supports HTTP), delegating to storage.delete.
    case 'delete_file': { const { key } = args as { key: string }; logger.info('Tool request received', { operation: 'tool:delete', toolName: 'delete_file', key, requestId }); const deleted = await storage.delete(key, requestId); return { content: [{ type: 'text', text: JSON.stringify({ success: deleted, message: deleted ? `File '${key}' deleted successfully` : `File '${key}' not found`, key }, null, 2) }] }; }

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/Amana03/universal-mcp-server'

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