Skip to main content
Glama

set_file

Select a file to enable reading, editing, and managing operations within the editor-mcp server workflow.

Instructions

Set the current file to work with.

This is always the first step in the workflow. You must set a file before you can use other tools like read, select etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'set_file' tool. It validates the file path (existence and protected paths), sets the current file path in the server instance, and returns a success or error message.
    @self.mcp.tool()
    async def set_file(filepath: str) -> str:
        """
        Set the current file to work with.
    
        This is always the first step in the workflow. You must set a file
        before you can use other tools like read, select etc.
        """
    
        if not os.path.isfile(filepath):
            return f"Error: File not found at '{filepath}'"
    
        # Check if the file path matches any of the protected paths
        for pattern in self.protected_paths:
            pattern = pattern.strip()
            if not pattern:
                continue
            # Check for absolute path match
            if filepath == pattern:
                return f"Error: Access to '{filepath}' is denied due to PROTECTED_PATHS configuration"
            # Check for glob pattern match (e.g., *.env, .env*, etc.)
            if "*" in pattern:
                # First try matching the full path
                if fnmatch.fnmatch(filepath, pattern):
                    return f"Error: Access to '{filepath}' is denied due to PROTECTED_PATHS configuration (matches pattern '{pattern}')"
    
                # Then try matching just the basename
                basename = os.path.basename(filepath)
                if fnmatch.fnmatch(basename, pattern):
                    return f"Error: Access to '{filepath}' is denied due to PROTECTED_PATHS configuration (matches pattern '{pattern}')"
    
        self.current_file_path = filepath
        return f"File set to: '{filepath}'"
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 sets a file as a prerequisite for other operations, implying a stateful context, but doesn't disclose behavioral traits like whether the file must exist, what happens on invalid paths, if this persists across sessions, or any error conditions. For a tool with no annotations, this leaves significant gaps.

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 concise and well-structured: two sentences that efficiently convey purpose and usage guidelines without redundancy. Every sentence adds value, and it's front-loaded with the core action.

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's moderate complexity (stateful operation with a prerequisite role), no annotations, and an output schema present (which may cover return values), the description is partially complete. It explains the workflow role but lacks details on parameter semantics and behavioral transparency, making it adequate but with clear gaps.

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 1 parameter with 0% description coverage. The description doesn't add any meaning beyond the schema—it doesn't explain what 'filepath' represents (e.g., absolute/relative path, format, constraints). With low schema coverage, the description fails to compensate, but since there's only one parameter, the baseline is slightly higher than minimal.

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: 'Set the current file to work with.' This is a specific verb ('set') and resource ('current file'), making the action understandable. However, it doesn't explicitly differentiate from sibling tools like 'new_file' or 'delete_file' beyond workflow context.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance: 'This is always the first step in the workflow. You must set a file before you can use other tools like read, select etc.' It clearly states when to use it (first step) and why (prerequisite for other tools), with named alternatives mentioned.

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/danielpodrazka/editor-mcp'

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