Skip to main content
Glama
andresthor

Command-Line MCP Server

by andresthor

approve_directory

Grant temporary or persistent directory access permissions within a controlled command-line environment to enable secure file operations during AI-assisted terminal sessions.

Instructions

Approve access to a directory for the current session.

Args: directory: The directory to approve access to session_id: The session ID remember: Whether to remember this approval for the session

Returns: A dictionary with approval status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYes
session_idYes
rememberNo

Implementation Reference

  • The handler for the 'approve_directory' MCP tool which normalizes the path, checks for existing approvals, and registers the approval in the SessionManager.
    async def approve_directory(
        directory: str, session_id: str, remember: bool = True
    ) -> dict[str, Any]:
        """
        Approve access to a directory for the current session.
    
        Args:
            directory: The directory to approve access to
            session_id: The session ID
            remember: Whether to remember this approval for the session
    
        Returns:
            A dictionary with approval status
        """
        # Normalize the directory path
        normalized_dir = normalize_path(directory)
    
        # Check if directory is already whitelisted globally
        if is_directory_whitelisted(normalized_dir, self.whitelisted_directories):
            return {
                "success": True,
                "message": f"Directory '{normalized_dir}' is already globally whitelisted",
                "directory": normalized_dir,
            }
    
        # Check if directory is already approved for this session
        if self.session_manager.has_directory_approval(session_id, normalized_dir):
            return {
                "success": True,
                "message": f"Directory '{normalized_dir}' is already approved for this session",
                "directory": normalized_dir,
            }
    
        # Approve the directory for this session
        if remember:
            self.session_manager.approve_directory(session_id, normalized_dir)
            return {
                "success": True,
                "message": f"Directory '{normalized_dir}' approved for this session",
                "directory": normalized_dir,
            }
        else:
  • The underlying SessionManager method that records the directory approval for a specific session.
    def approve_directory(self, session_id: str, directory: str) -> None:
        """Approve a directory for a session.
    
        Args:
            session_id: The session ID
            directory: The directory to approve
        """
        session = self.get_session(session_id)
        session["approved_directories"].add(directory)

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/andresthor/cmd-line-mcp'

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