Skip to main content
Glama

check_temp_directory

Verify the temporary directory location for storing code index data to ensure proper operation and data management.

Instructions

Check the temporary directory used for storing index data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function manage_temp_directory that implements the check_temp_directory tool logic when action='check'. Directly called by the MCP tool registration.
    def manage_temp_directory(action: str) -> Dict[str, Any]:
        """
        Manage temporary directory operations.
    
        This is a standalone function that doesn't require project context.
        Handles the logic for create_temp_directory and check_temp_directory MCP tools.
    
        Args:
            action: The action to perform ('create' or 'check')
    
        Returns:
            Dictionary with directory information and operation results
    
        Raises:
            ValueError: If action is invalid or operation fails
        """
        if action not in ['create', 'check']:
            raise ValueError(f"Invalid action: {action}. Must be 'create' or 'check'")
    
        # Try to get the actual temp directory from index manager, fallback to default
        try:
            index_manager = get_index_manager()
            temp_dir = index_manager.temp_dir if index_manager.temp_dir else os.path.join(tempfile.gettempdir(), SETTINGS_DIR)
        except:
            temp_dir = os.path.join(tempfile.gettempdir(), SETTINGS_DIR)
    
        if action == 'create':
            existed_before = os.path.exists(temp_dir)
    
            try:
                # Use ProjectSettings to handle directory creation consistently
                ProjectSettings("", skip_load=True)
    
                result = ResponseFormatter.directory_info_response(
                    temp_directory=temp_dir,
                    exists=os.path.exists(temp_dir),
                    is_directory=os.path.isdir(temp_dir)
                )
                result["existed_before"] = existed_before
                result["created"] = not existed_before
    
                return result
    
            except (OSError, IOError, ValueError) as e:
                return ResponseFormatter.directory_info_response(
                    temp_directory=temp_dir,
                    exists=False,
                    error=str(e)
                )
    
        else:  # action == 'check'
            result = ResponseFormatter.directory_info_response(
                temp_directory=temp_dir,
                exists=os.path.exists(temp_dir),
                is_directory=os.path.isdir(temp_dir) if os.path.exists(temp_dir) else False
            )
            result["temp_root"] = tempfile.gettempdir()
    
            # If the directory exists, list its contents
            if result["exists"] and result["is_directory"]:
                try:
                    contents = os.listdir(temp_dir)
                    result["contents"] = contents
                    result["subdirectories"] = []
    
                    # Check each subdirectory
                    for item in contents:
                        item_path = os.path.join(temp_dir, item)
                        if os.path.isdir(item_path):
                            subdir_info = {
                                "name": item,
                                "path": item_path,
                                "contents": os.listdir(item_path) if os.path.exists(item_path) else []
                            }
                            result["subdirectories"].append(subdir_info)
    
                except (OSError, PermissionError) as e:
                    result["error"] = str(e)
    
            return result
  • MCP tool registration with @mcp.tool() decorator. Delegates execution to manage_temp_directory('check').
    @mcp.tool()
    @handle_mcp_tool_errors(return_type='dict')
    def check_temp_directory() -> Dict[str, Any]:
        """Check the temporary directory used for storing index data."""
        return manage_temp_directory('check')
  • Alternative or supporting handler method in SettingsTool class that performs identical directory check logic.
    def check_temp_directory(self) -> Dict[str, Any]:
        """
        Check the status of the temporary directory.
    
        Returns:
            Dictionary with directory status information
        """
        temp_dir = self.get_temp_directory_path()
    
        result = {
            "temp_directory": temp_dir,
            "temp_root": tempfile.gettempdir(),
            "exists": os.path.exists(temp_dir),
            "is_directory": os.path.isdir(temp_dir) if os.path.exists(temp_dir) else False
        }
    
        # If the directory exists, list its contents
        if result["exists"] and result["is_directory"]:
            try:
                contents = os.listdir(temp_dir)
                result["contents"] = contents
                result["subdirectories"] = []
    
                # Check each subdirectory
                for item in contents:
                    item_path = os.path.join(temp_dir, item)
                    if os.path.isdir(item_path):
                        subdir_info = {
                            "name": item,
                            "path": item_path,
                            "contents": os.listdir(item_path) if os.path.exists(item_path) else []
                        }
                        result["subdirectories"].append(subdir_info)
    
            except (OSError, PermissionError) as e:
                result["error"] = str(e)
    
        return result
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'Check' implies a read-only operation, the description doesn't explicitly state whether this requires permissions, what specific information is returned, or if there are side effects. It mentions the directory's purpose ('storing index data') but lacks details about output format, error conditions, or system impact.

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 is a single, clear sentence with no wasted words. It's front-loaded with the core purpose and efficiently conveys the tool's function. Every word earns its place, making it easy for an agent to parse quickly.

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

Completeness3/5

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

Given the tool has zero parameters, 100% schema coverage, and an output schema exists, the description is minimally complete. However, as a tool with no annotations, it should ideally provide more behavioral context (e.g., what 'checking' entails, what information is returned). The output schema will help, but the description itself is sparse for a tool that might return complex directory status information.

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

Parameters4/5

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

The tool has zero parameters, and schema description coverage is 100% (empty schema). The description appropriately doesn't discuss parameters since none exist. It could theoretically mention that no inputs are required, but this is adequately covered by the schema. A baseline of 4 is appropriate for zero-parameter tools.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Check the temporary directory used for storing index data.' It specifies the verb ('Check') and resource ('temporary directory'), and mentions its specific function related to index data storage. However, it doesn't explicitly differentiate from sibling tools like 'create_temp_directory' or 'refresh_index', which prevents a perfect score.

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. It doesn't mention prerequisites, timing considerations, or comparisons to sibling tools like 'create_temp_directory' or 'get_settings_info' that might relate to temporary directory management. The agent must infer usage context from the tool name alone.

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/johnhuang316/code-index-mcp'

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