Skip to main content
Glama
mattlemmone

Expo MCP Server

by mattlemmone

writeFile

Store content in a specified file path for Expo-based React Native projects, enabling efficient file manipulation and project management within the Expo MCP Server environment.

Instructions

Write content to a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe content to write to the file
filePathYesThe path to the file to write

Implementation Reference

  • The writeFile tool handler function. It normalizes the path, creates the directory if necessary, writes the file content using Node.js fs.promises.writeFile, handles errors, logs operations, and returns an MCP-formatted response.
    export async function writeFile(args: { filePath: string; content: string }, { log }: LogContext) {
      try {
        log.info(`Writing to file at path: ${args.filePath}`);
    
        const normalizedPath = path.normalize(args.filePath);
        const directory = path.dirname(normalizedPath);
        await fs.promises.mkdir(directory, { recursive: true });
        await fs.promises.writeFile(normalizedPath, args.content);
    
        log.info(`Successfully wrote to file: ${normalizedPath}`);
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully wrote ${args.content.length} characters to ${normalizedPath}`,
            },
          ],
        };
      } catch (error: any) {
        log.error(`Error writing file: ${error.message}`);
        throw new Error(`Failed to write file: ${error.message}`);
      }
    }
  • src/index.ts:27-35 (registration)
    Registration of the writeFile tool on the FastMCP server using addTool. Includes the tool name, description, Zod input schema for parameters, and binding to the execute handler.
    addTool({
      name: "writeFile",
      description: "Write content to a file",
      parameters: z.object({
        filePath: z.string().describe("The path to the file to write"),
        content: z.string().describe("The content to write to the file"),
      }),
      execute: writeFile,
    });
  • Zod schema definition for the writeFile tool input parameters: filePath (string) and content (string). Used for validation in the MCP tool registration.
    parameters: z.object({
      filePath: z.string().describe("The path to the file to write"),
      content: z.string().describe("The content to write to the file"),
    }),
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 of behavioral disclosure. 'Write content to a file' implies a mutation operation, but it doesn't specify whether this creates new files, overwrites existing ones, requires specific permissions, handles errors, or has side effects like file locking. For a write tool with zero annotation coverage, this leaves critical behavioral traits unaddressed.

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 extremely concise with a single, direct sentence that front-loads the core action. There is no wasted language or unnecessary elaboration, making it efficient for quick understanding. Every word earns its place by clearly conveying the tool's function.

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

Completeness2/5

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

Given the tool's complexity as a write operation with no annotations and no output schema, the description is incomplete. It lacks information on behavioral traits, error handling, return values, and usage context. For a mutation tool that modifies files, more detail is needed to ensure safe and correct invocation by an AI agent.

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 description adds no parameter semantics beyond what the input schema provides. The schema has 100% description coverage with clear definitions for 'content' and 'filePath', so the baseline score of 3 is appropriate. The description doesn't elaborate on parameter usage, constraints, or examples, but the schema adequately documents them.

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 ('Write content') and target resource ('to a file'), making the purpose immediately understandable. It distinguishes from sibling tools like 'readFile' and 'listFiles' by specifying a write operation rather than read or list operations. However, it doesn't specify file creation vs. overwriting, which could provide more precise differentiation.

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 when to choose 'writeFile' over other file operations like 'readFile' or 'tailFile', nor does it specify prerequisites, constraints, or typical use cases. The agent must infer usage 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

Related 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/mattlemmone/expo-mcp'

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