Skip to main content
Glama
JeremyLakeyJr

Friday MCP Server

write_file

Create or overwrite files in your workspace. Specify the file path and content to write, with optional overwrite control.

Instructions

Write a file within the workspace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
contentYes
overwriteNo

Implementation Reference

  • The write_file tool handler function decorated with @mcp.tool(). It resolves the path safely, checks overwrite flag, creates parent directories if needed, writes the file content, and returns path + byte count.
    @mcp.tool()
    def write_file(path: str, content: str, overwrite: bool = True) -> dict:
        """Write a file within the workspace."""
        target = _resolve_path(path)
        if target.exists() and not overwrite:
            raise ValueError(f"'{path}' already exists and overwrite is disabled.")
    
        target.parent.mkdir(parents=True, exist_ok=True)
        target.write_text(content, encoding="utf-8")
        return {
            "path": str(target),
            "bytes_written": len(content.encode("utf-8")),
        }
  • The register_all_tools function calls workspace.register(mcp, config=config) which decorates all workspace tools (including write_file) onto the MCP server.
    workspace.register(mcp, config=config)
  • The register function in workspace.py is called to register all workspace tools (list_workspace, read_file, write_file, run_bash) onto the MCP server instance via @mcp.tool() decorator.
    def register(mcp, *, config) -> None:
  • The _resolve_path helper resolves a given path relative to the workspace root, enforces security boundaries, and returns the resolved absolute Path.
    def _resolve_path(path: str) -> Path:
        raw_path = Path(path).expanduser()
        resolved = (
            raw_path.resolve()
            if raw_path.is_absolute()
            else (config.workspace_root / raw_path).resolve()
        )
        if config.allow_external_paths:
            return resolved
        if resolved != config.workspace_root and config.workspace_root not in resolved.parents:
            raise ValueError(
                f"Path '{path}' is outside the workspace root {config.workspace_root}."
            )
        return resolved
Behavior2/5

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

Description lacks behavioral details beyond the name, such as overwrite behavior, creation of intermediate directories, or file size limits. Annotations are absent, so description should compensate but doesn't.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very short and front-loaded, but while concise, it sacrifices necessary detail. It fits the tool but is not optimally structured.

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

Completeness1/5

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

The description is incomplete; it doesn't explain what happens on success/failure, return value, or behavior with existing files. Given no output schema, this is a significant gap.

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

Parameters1/5

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

With 0% schema coverage, description adds no parameter semantics. It doesn't explain what path means (relative/absolute), content format (text/binary), or overwrite behavior.

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 the action (write), resource (file), and scope (within workspace), distinguishing it from sibling tools like read_file.

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?

No usage guidelines provided; agent receives no context on when to prefer this tool over alternatives or any constraints.

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/JeremyLakeyJr/mcp-server'

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