Skip to main content
Glama

create_temp_directory

Creates a temporary directory for storing code index data in the code-index-mcp server to enable repository analysis and search functionality.

Instructions

Create the temporary directory used for storing index data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool registration decorator and thin handler wrapper that delegates to manage_temp_directory helper.
    @mcp.tool()
    @handle_mcp_tool_errors(return_type='dict')
    def create_temp_directory() -> Dict[str, Any]:
        """Create the temporary directory used for storing index data."""
        return manage_temp_directory('create')
  • The registered MCP tool handler function for create_temp_directory.
    @mcp.tool()
    @handle_mcp_tool_errors(return_type='dict')
    def create_temp_directory() -> Dict[str, Any]:
        """Create the temporary directory used for storing index data."""
        return manage_temp_directory('create')
  • Core helper function implementing the temp directory creation logic, called by the MCP handler. Handles both create and check actions.
    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)
                )
  • Alternative class-based helper method with similar temp directory creation logic (possibly unused for MCP).
    def create_temp_directory(self) -> Dict[str, Any]:
        """
        Create the temporary directory for settings.
    
        Returns:
            Dictionary with creation results
        """
        temp_dir = self.get_temp_directory_path()
        existed_before = os.path.exists(temp_dir)
    
        try:
            os.makedirs(temp_dir, exist_ok=True)
    
            return {
                "temp_directory": temp_dir,
                "exists": os.path.exists(temp_dir),
                "is_directory": os.path.isdir(temp_dir),
                "existed_before": existed_before,
                "created": not existed_before
            }
    
        except (OSError, IOError) as e:
            return {
                "temp_directory": temp_dir,
                "exists": False,
                "error": str(e)
            }
Behavior2/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. It states the tool creates a directory but does not disclose behavioral traits like whether it overwrites existing directories, requires specific permissions, handles errors, or affects system state beyond creation. This leaves significant gaps for a mutation tool.

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 that directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized, with every part earning its place.

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 no parameters and an output schema exists, the description is minimally adequate. However, as a mutation tool with no annotations, it lacks details on behavioral context like side effects or error handling, which could be important for safe usage in the provided sibling tool context.

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 0 parameters, and the input schema has 100% description coverage (though empty). The description does not need to add parameter semantics, so a baseline of 4 is appropriate, as it efficiently avoids redundancy while being complete for a parameterless tool.

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 action ('Create') and the resource ('temporary directory used for storing index data'), providing a specific purpose. However, it does not explicitly differentiate from sibling tools like 'check_temp_directory' or 'clear_settings', which prevents a score of 5.

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 offers no guidance on when to use this tool versus alternatives, such as when to create versus check the directory, or prerequisites like needing the directory for operations like 'build_deep_index'. It lacks explicit when/when-not instructions or named alternatives.

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