Skip to main content
Glama

Update Project Main

update_project_main

Creates or fully replaces main.md content for projects on the Knowledge MCP Server. Use to migrate, initialize, or rewrite project guidelines with automatic git commits and markdown validation. Ideal for complete updates, not minor changes.

Instructions

Create or completely replace main.md content for a project.

When to use this tool:

  • Migrating CLAUDE.md content to centralized MCP storage

  • Creating a new project's instruction set

  • Completely rewriting project guidelines

  • Setting up initial project configuration

Key features:

  • Creates project if it doesn't exist (auto-initialization)

  • Completely replaces existing content (destructive update)

  • Automatically commits changes to git

  • Validates markdown structure

You should:

  1. Check if project exists first with get_project_main

  2. Preserve important sections when doing full updates

  3. Use update_project_section for partial changes instead

  4. Include all necessary sections in the new content

  5. Validate markdown formatting before submission

  6. Consider the impact of complete replacement

  7. Document why full replacement is necessary

DO NOT use when:

  • Making small updates (use update_project_section instead)

  • You haven't read the existing content first

  • Uncertain about losing existing content

Returns: {success: bool, message?: str, error?: str}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe new markdown content for main.md
project_idYesThe project identifier

Implementation Reference

  • The core asynchronous handler function that executes the tool logic: creates project directory if needed, writes content to main.md, auto-commits changes to git, handles errors with MCPError.
    async updateProjectMainAsync(params: {
      project_id: z.infer<typeof secureProjectIdSchema>;
      content: z.infer<typeof secureContentSchema>;
    }): Promise<string> {
      const context = this.createContext('update_project_main', params);
    
      try {
        const { project_id, content } = params;
        // Use createProjectEntryAsync for write operations that create new projects
        const [originalId, projectPath] = await createProjectEntryAsync(this.storagePath, project_id);
    
        // Create project directory if it doesn't exist
        await mkdir(projectPath, { recursive: true });
    
        // Write main.md file
        const validatedPath = await validatePathAsync(projectPath, 'main.md');
        await writeFile(validatedPath, content);
    
        // Auto-commit changes
        await autoCommitAsync(this.storagePath, `Update project main for ${originalId}`);
    
        await this.logSuccessAsync('update_project_main', { project_id }, context);
        return this.formatSuccessResponse({
          message: `Project main updated for ${originalId}`,
        });
      } catch (error) {
        const mcpError =
          error instanceof MCPError
            ? error
            : new MCPError(
                MCPErrorCode.FILE_SYSTEM_ERROR,
                `Failed to update project main: ${error instanceof Error ? error.message : String(error)}`,
                {
                  project_id: params.project_id,
                  method: 'update_project_main',
                  traceId: context.traceId,
                }
              );
        await this.logErrorAsync(
          'update_project_main',
          { project_id: params.project_id },
          mcpError,
          context
        );
        return this.formatErrorResponse(mcpError, context);
      }
    }
  • Registers the 'update_project_main' tool with the MCP server, defining input schema using Zod schemas, tool description, title, and wiring the async handler.
    server.registerTool(
      'update_project_main',
      {
        title: 'Update Project Main',
        description: TOOL_DESCRIPTIONS.update_project_main,
        inputSchema: {
          project_id: secureProjectIdSchema.describe('The project identifier'),
          content: secureContentSchema.describe('The new markdown content for main.md'),
        },
      },
      async ({ project_id, content }) => {
        const result = await projectHandler.updateProjectMainAsync({ project_id, content });
        return {
          content: [
            {
              type: 'text',
              text: result,
            },
          ],
        };
      }
    );
  • Detailed description string for the tool used in registration, providing usage guidelines, when to use, key features, and return format.
      update_project_main: `Create or completely replace main.md content for a project.
    
    When to use this tool:
    - Migrating CLAUDE.md content to centralized MCP storage
    - Creating a new project's instruction set
    - Completely rewriting project guidelines
    - Setting up initial project configuration
    
    Key features:
    - Creates project if it doesn't exist (auto-initialization)
    - Completely replaces existing content (destructive update)
    - Automatically commits changes to git
    - Validates markdown structure
    
    You should:
    1. Check if project exists first with get_project_main
    2. Preserve important sections when doing full updates
    3. Use update_project_section for partial changes instead
    4. Include all necessary sections in the new content
    5. Validate markdown formatting before submission
    6. Consider the impact of complete replacement
    7. Document why full replacement is necessary
    
    DO NOT use when:
    - Making small updates (use update_project_section instead)
    - You haven't read the existing content first
    - Uncertain about losing existing content
    
    Returns: {success: bool, message?: str, error?: str}`,
  • Synchronous version of the handler (similar logic using sync fs/git utils), provided for completeness though async is used in registration.
    updateProjectMain(params: {
      project_id: z.infer<typeof secureProjectIdSchema>;
      content: z.infer<typeof secureContentSchema>;
    }): string {
      const context = this.createContext('update_project_main', params);
    
      try {
        const { project_id, content } = params;
        // Use createProjectEntry for write operations that create new projects
        const [originalId, projectPath] = createProjectEntry(this.storagePath, project_id);
    
        // Create project directory if it doesn't exist
        mkdirSync(projectPath, { recursive: true });
    
        // Write main.md file
        const validatedPath = validatePath(projectPath, 'main.md');
        writeFileSync(validatedPath, content);
    
        // Auto-commit changes
        autoCommit(this.storagePath, `Update project main for ${originalId}`);
    
        this.logSuccess('update_project_main', { project_id }, context);
        return this.formatSuccessResponse({
          message: `Project main updated for ${originalId}`,
        });
      } catch (error) {
        const mcpError =
          error instanceof MCPError
            ? error
            : new MCPError(
                MCPErrorCode.FILE_SYSTEM_ERROR,
                `Failed to update project main: ${error instanceof Error ? error.message : String(error)}`,
                {
                  project_id: params.project_id,
                  method: 'update_project_main',
                  traceId: context.traceId,
                }
              );
        this.logError('update_project_main', { project_id: params.project_id }, mcpError, context);
        return this.formatErrorResponse(mcpError, context);
      }
    }
Behavior5/5

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

With no annotations provided, the description fully discloses behavioral traits beyond the input schema. It details auto-initialization, destructive updates, git commits, and markdown validation. It also warns about impact ('Consider the impact of complete replacement') and provides actionable steps, adding significant value 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.

Conciseness4/5

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

The description is well-structured with clear sections (purpose, usage, features, guidelines, exclusions) and uses bullet points for readability. It is appropriately sized but could be slightly more concise by integrating some points; however, every sentence adds value, earning a high score.

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

Completeness5/5

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

Given the tool's complexity (destructive update with auto-initialization), no annotations, and no output schema, the description provides comprehensive context. It explains behavior, usage scenarios, alternatives, precautions, and even hints at return values ('Returns: {success: bool...}'), making it complete enough for effective agent use.

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 schema description coverage is 100%, so the schema already documents both parameters ('content' and 'project_id'). The description implies parameter usage (e.g., 'new markdown content' and 'project identifier') but doesn't add syntax or format details beyond the schema. This meets the baseline of 3 when schema coverage is high.

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 tool's purpose with specific verbs ('Create or completely replace') and resource ('main.md content for a project'). It distinguishes from sibling tools like 'update_project_section' by emphasizing complete replacement versus partial updates, making the purpose unambiguous.

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 guidance with dedicated 'When to use this tool' and 'DO NOT use when' sections, listing specific scenarios like migrating content or creating new projects. It names alternatives (e.g., 'use update_project_section for partial changes') and includes prerequisites (e.g., 'Check if project exists first with get_project_main'), offering comprehensive usage context.

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/sven-borkert/knowledge-mcp'

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