Skip to main content
Glama

delete_room

Permanently delete a communication room and all its messages. Optionally force deletion even if the room is not closed.

Instructions

Permanently delete a communication room and all its messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
roomNameYesName of the communication room to permanently delete. This will remove all messages and data associated with the room.
forceDeleteNoWhether to force delete the room even if it's not closed. Defaults to false. If false, the room must be closed before deletion. If true, will delete the room regardless of status.

Implementation Reference

  • The main handler for the 'delete_room' tool. It normalizes arguments (supporting both snake_case and camelCase), validates via DeleteRoomSchema, checks if the room exists and is closed (or forceDelete is true), terminates associated agents, then calls communicationService.deleteRoom() to permanently remove the room and all its messages. Returns a DeleteRoomResponse with success/error details.
    /**
     * Permanently delete a communication room and all its messages
     */
    async deleteRoom(args: any): Promise<DeleteRoomResponse> {
      // Map snake_case to camelCase for compatibility
      const normalizedArgs = {
        roomName: args.roomName || args.room_name,
        forceDelete: args.forceDelete || args.force_delete
      };
      
      const { roomName, forceDelete = false } = DeleteRoomSchema.parse(normalizedArgs);
      const startTime = performance.now();
      
      try {
        const room = await this.communicationService.getRoom(roomName);
        if (!room) {
          const executionTime = performance.now() - startTime;
          return createErrorResponse(
            `Room '${roomName}' not found`,
            `Room '${roomName}' not found`,
            'ROOM_NOT_FOUND'
          ) as DeleteRoomResponse;
        }
    
        // Check if room is closed or force delete
        const isClosed = room.roomMetadata?.status === 'closed';
        if (!isClosed && !forceDelete) {
          const executionTime = performance.now() - startTime;
          return createErrorResponse(
            `Room '${roomName}' must be closed before deletion. Use force_delete=true to override.`,
            `Room '${roomName}' must be closed before deletion`,
            'ROOM_NOT_CLOSED'
          ) as DeleteRoomResponse;
        }
    
        // Terminate any remaining agents
        const agents = await this.agentService.listAgents(room.repositoryPath);
        const roomAgents = agents.filter(agent => 
          agent.agentMetadata?.roomId === room.id || 
          agent.agentMetadata?.roomName === roomName
        );
        
        if (roomAgents.length > 0) {
          for (const agent of roomAgents) {
            try {
              await this.agentService.terminateAgent(agent.id);
            } catch (error: any) {
              console.warn(`Failed to terminate agent ${agent.id}:`, error);
            }
          }
        }
    
        // Delete the room
        await this.communicationService.deleteRoom(roomName);
        
        const executionTime = performance.now() - startTime;
        
        return createSuccessResponse(
          `Room '${roomName}' permanently deleted`,
          {
            room_name: roomName,
            messages_deleted: true,
            agents_terminated: roomAgents.length
          },
          executionTime
        ) as DeleteRoomResponse;
    
      } catch (error: any) {
        const executionTime = performance.now() - startTime;
        return createErrorResponse(
          'Failed to delete room',
          error instanceof Error ? error.message : 'Unknown error occurred',
          'DELETE_ROOM_ERROR'
        ) as DeleteRoomResponse;
      }
    }
  • The DeleteRoomSchema Zod definition specifying the input parameters: roomName (string) and forceDelete (boolean, defaults to false).
    export const DeleteRoomSchema = z.object({
      roomName: z.string().describe('Name of the communication room to permanently delete. This will remove all messages and data associated with the room.'),
      forceDelete: z.boolean().default(false).describe('Whether to force delete the room even if it\'s not closed. Defaults to false. If false, the room must be closed before deletion. If true, will delete the room regardless of status.')
    });
  • The DeleteRoomResponseSchema Zod definition specifying the output structure: success, message, timestamp, execution_time_ms, and data containing room_name, messages_deleted, and agents_terminated.
    // Delete Room Response
    export const DeleteRoomResponseSchema = z.object({
      success: z.boolean().describe('Whether the room was successfully deleted permanently. True if room and all associated data were removed.'),
      message: z.string().describe('Human-readable description of the deletion result, including room name and data removal confirmation.'),
      timestamp: z.string().describe('ISO timestamp string indicating when the room was permanently deleted.'),
      execution_time_ms: z.number().optional().describe('Time taken to delete the room in milliseconds, including message deletion and agent cleanup.'),
      data: z.object({
        room_name: z.string().describe('Name of the room that was permanently deleted.'),
        messages_deleted: z.boolean().describe('Whether all messages in the room were successfully deleted from the database.'),
        agents_terminated: z.number().describe('Number of agents that were terminated as part of the room deletion process.')
      }).optional().describe('Room deletion details returned when successful, containing room name and confirmation of data removal.')
    });
  • Registration of the 'delete_room' tool within the getTools() method of CommunicationTools class, defining its name, description, input/output schemas, and binding the handler.
    {
      name: 'delete_room',
      description: 'Permanently delete a communication room and all its messages',
      inputSchema: zodToJsonSchema(DeleteRoomSchema),
      outputSchema: zodToJsonSchema(DeleteRoomResponseSchema),
      handler: this.deleteRoom.bind(this)
    },
  • The CommunicationService.deleteRoom method which looks up the room by name, delegates to commRepo.deleteRoom() for the actual database deletion, then emits a 'room_closed' event on the eventBus.
    async deleteRoom(roomName: string): Promise<void> {
      const room = await this.commRepo.getRoomByName(roomName);
      if (!room) {
        throw new Error(`Room ${roomName} not found`);
      }
    
      await this.commRepo.deleteRoom(roomName);
      
      // Emit room closed event
      await eventBus.emit('room_closed', {
        roomId: room.name, // Using name as ID since it's the primary key
        roomName: room.name,
        timestamp: new Date(),
        repositoryPath: room.repositoryPath
      });
    }
  • The CommunicationRepository.deleteRoom method that performs the actual database operations: deletes chat messages, room participants, and the chat room itself in that order using Drizzle ORM.
    /**
     * Delete a room and all its messages by ID
     */
    async deleteRoom(id: string): Promise<boolean> {
      try {
        // Delete in proper order: messages -> participants -> room
        await this.drizzle
          .delete(chatMessages)
          .where(eq(chatMessages.roomId, id))
          .execute();
    
        // Delete participants
        await this.drizzle
          .delete(roomParticipants)
          .where(eq(roomParticipants.roomId, id))
          .execute();
    
        // Delete room
        const result = await this.drizzle
          .delete(chatRooms)
          .where(eq(chatRooms.id, id))
          .execute();
    
        return result.changes > 0;
      } catch (error) {
        throw new RepositoryError(
          `Failed to delete room: ${id}`,
          'deleteRoom',
          this.getTableName(),
          error
        );
      }
    }
Behavior3/5

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

No annotations provided, so description carries full burden. It conveys destructive behavior ('permanently delete') and scope (all messages), but omits permissions, irreversible nature, or effect on active rooms. The schema's forceDelete param adds some context.

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?

A single, concise sentence front-loading the action and scope. Every word is necessary and earned.

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

Completeness4/5

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

For a simple delete operation, the description covers the core effect. However, it does not mention error states or linked data impacts, though the schema covers parameters well.

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?

Schema coverage is 100% with parameter descriptions, so the description adds no additional meaning beyond what the schema already provides. Baseline of 3 is appropriate.

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

Purpose5/5

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

The description clearly states a specific verb 'delete' and resource 'communication room', and distinguishes from siblings like close_room and cleanup_stale_rooms by emphasizing permanence and message removal.

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

Usage Guidelines3/5

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

The description implies usage for permanent room deletion but lacks explicit when-to-use or when-not-to-use guidance. The forceDelete parameter description gives some context, but no direct comparison to alternatives like close_room.

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/ZachHandley/ZMCPTools'

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