Skip to main content
Glama
Amana03

Universal MCP Server

by Amana03

delete_file

Remove files from storage systems by specifying the file key or name to permanently delete them.

Instructions

Delete a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesThe file key/name to delete

Implementation Reference

  • MCP tool handler for 'delete_file': extracts the file key from arguments, logs the operation, delegates deletion to FileStorage.delete(), and returns a JSON response indicating success or if the file was not found.
    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, provided in the ListTools response.
    {
      name: 'delete_file',
      description: 'Delete a file',
      inputSchema: {
        type: 'object',
        properties: {
          key: {
            type: 'string',
            description: 'The file key/name to delete',
          },
        },
        required: ['key'],
      },
    },
  • Core implementation of file deletion in FileStorage class: acquires a lock for concurrency safety, computes safe file path, uses fs.unlink to delete the file, handles not-found gracefully by returning false, with comprehensive logging.
    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();
      }
    }
  • src/index.ts:116-167 (registration)
    Registration of all tools including 'delete_file' via the ListToolsRequestSchema handler, which returns the tool list with schemas.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'write_file',
            description: 'Write content to a file',
            inputSchema: {
              type: 'object',
              properties: {
                key: {
                  type: 'string',
                  description: 'The file key/name',
                },
                content: {
                  type: 'string',
                  description: 'The content to write',
                },
              },
              required: ['key', 'content'],
            },
          },
          {
            name: 'delete_file',
            description: 'Delete a file',
            inputSchema: {
              type: 'object',
              properties: {
                key: {
                  type: 'string',
                  description: 'The file key/name to delete',
                },
              },
              required: ['key'],
            },
          },
          {
            name: 'search_files',
            description: 'Search for files containing specific text',
            inputSchema: {
              type: 'object',
              properties: {
                query: {
                  type: 'string',
                  description: 'The text to search for',
                },
              },
              required: ['query'],
            },
          },
        ],
      };
    });
  • Identical MCP tool handler for 'delete_file' in the multi-mode server variant.
    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)
        }]
      };
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Delete a file' implies a destructive mutation, but it doesn't specify whether deletion is permanent or reversible, what permissions are required, if there are rate limits, or what happens on success/failure. For a destructive tool with zero annotation coverage, this is a critical gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description 'Delete a file' is extremely concise—three words that directly state the action. It's front-loaded with the core purpose and has zero wasted words, making it efficient and easy to parse. This is an example of optimal brevity for a simple tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a destructive operation with no annotations and no output schema), the description is incomplete. It doesn't address behavioral aspects like safety, permissions, or outcomes, which are crucial for a deletion tool. The high schema coverage helps with parameters, but overall context is lacking for informed use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the single parameter 'key' documented as 'The file key/name to delete'. The description adds no additional meaning beyond this, as it doesn't elaborate on parameter usage, format, or examples. With high schema coverage, the baseline score of 3 is appropriate, as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Delete a file' states a clear verb ('Delete') and resource ('a file'), providing basic purpose. However, it lacks specificity about what type of file or system is involved, and doesn't distinguish from sibling tools like 'write_file' or 'search_files' beyond the obvious action difference. It's not tautological but remains vague in scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There are sibling tools like 'search_files' and 'write_file', but no indication of prerequisites, dependencies, or scenarios where deletion is appropriate versus other operations. Usage is implied by the action name alone, with no explicit context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

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