Skip to main content
Glama
itsocialist

Claude Code Connector MCP

by itsocialist

write_to_project

Write content to files within registered project directories, enabling developers to save specifications and manage project files across Claude interfaces.

Instructions

Write content to a file in registered project directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesID of registered project
filePathYesRelative path within project
contentYesFile content to write
createDirsNoCreate parent directories if they don't exist
overwriteNoOverwrite if file exists

Implementation Reference

  • The main handler function that implements the write_to_project tool logic, including project validation, path security checks, file existence handling, directory creation, and file writing using Node.js fs/promises.
    export async function writeToProject(args: WriteToProjectArgs): Promise<{
        success: boolean;
        fullPath: string;
        action: 'created' | 'updated';
        bytes: number;
    }> {
        const projectManager = new ProjectManager();
        const project = await projectManager.getProject(args.projectId);
    
        if (!project) {
            throw new MCPError(ErrorCode.PROJECT_NOT_FOUND, `Project '${args.projectId}' not found`);
        }
    
        // Prevent directory traversal attacks
        if (args.filePath.includes('..') || isAbsolute(args.filePath)) {
            throw new MCPError(ErrorCode.INVALID_PATH, `Invalid file path: ${args.filePath}`);
        }
    
        const fullPath = join(project.rootPath, args.filePath);
    
        // Check if file exists
        let exists = false;
        try {
            await stat(fullPath);
            exists = true;
        } catch (e) {
            exists = false;
        }
    
        if (exists && args.overwrite === false) {
            throw new MCPError(
                ErrorCode.FILE_ALREADY_EXISTS,
                `File '${args.filePath}' already exists`,
                "Set 'overwrite' to true to replace existing content."
            );
        }
    
        // Create directories if requested
        if (args.createDirs !== false) {
            await mkdir(dirname(fullPath), { recursive: true });
        }
    
        try {
            await writeFile(fullPath, args.content, 'utf-8');
            const stats = await stat(fullPath);
    
            // Update last accessed
            // TODO: move this to project manager
            project.lastAccessed = new Date().toISOString();
    
            return {
                success: true,
                fullPath,
                action: exists ? 'updated' : 'created',
                bytes: stats.size
            };
        } catch (error: any) {
            throw new MCPError(
                ErrorCode.INTERNAL_ERROR,
                `Failed to write file: ${error.message}`
            );
        }
    }
  • TypeScript interface defining the input arguments for the write_to_project tool.
    export interface WriteToProjectArgs {
      projectId: string;
      filePath: string;
      content: string;
      createDirs?: boolean;
      overwrite?: boolean;
    }
  • src/index.ts:80-94 (registration)
    Registration of the write_to_project tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: 'write_to_project',
      description: 'Write content to a file in registered project directory',
      inputSchema: {
        type: 'object',
        properties: {
          projectId: { type: 'string', description: 'ID of registered project' },
          filePath: { type: 'string', description: 'Relative path within project' },
          content: { type: 'string', description: 'File content to write' },
          createDirs: { type: 'boolean', description: 'Create parent directories if they don\'t exist' },
          overwrite: { type: 'boolean', description: 'Overwrite if file exists' }
        },
        required: ['projectId', 'filePath', 'content']
      }
    },
  • src/index.ts:129-132 (registration)
    Tool execution dispatch in the CallToolRequestSchema handler's switch statement, calling the writeToProject function.
    case 'write_to_project':
      return {
        content: [{ type: 'text', text: JSON.stringify(await writeToProject(args as unknown as WriteToProjectArgs), null, 2) }]
      };
  • src/index.ts:29-29 (registration)
    Import of the writeToProject handler function.
    import { writeToProject } from './tools/write_to_project.js';
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it's a write operation but doesn't mention permission requirements, error conditions (e.g., invalid paths), whether it's idempotent, or what happens on success/failure. The description is minimal and misses important behavioral context for a file write 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 with zero wasted words. It's front-loaded with the core action and target, making it immediately understandable. Every word earns its place in this concise formulation.

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?

For a write operation tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what 'registered project' means (context from sibling 'register_project'), doesn't mention the tool's effect on existing files, and provides no information about return values or error handling. The description leaves significant gaps for proper tool usage.

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?

Schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional parameter semantics beyond what's in the schema (like explaining what 'registered project' means or format expectations). Baseline 3 is appropriate since the schema does the heavy lifting.

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 ('to a file in registered project directory'), which is specific and actionable. It distinguishes from siblings like 'read_from_project' by specifying a write operation, but doesn't explicitly differentiate from other potential write operations beyond the project context.

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 (like needing a registered project), when not to use it, or how it relates to sibling tools like 'register_project' (which might be required first). Usage context is implied but not explicitly stated.

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/itsocialist/claude-code-connector-mcp'

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