Skip to main content
Glama

Get Project Main Instructions

get_project_main

Retrieve project-specific guidelines and configurations from a centralized repository. Use to ensure consistent adherence to project instructions, replace outdated local files, and parse structured content for clarity.

Instructions

Retrieve main.md content for a project's central instructions and configuration.

When to use this tool:

  • Starting work on any project (ALWAYS use FIRST)

  • Refreshing your understanding of project guidelines

  • Checking for updates to project instructions

  • Migrating from local CLAUDE.md files to centralized storage

Key features:

  • Replaces need for local CLAUDE.md files completely

  • Auto-detects project from git repository or directory name

  • Returns structured content with sections for easy parsing

  • Provides project-specific instructions and context

You should:

  1. ALWAYS call this first when starting work on a project

  2. Use the returned content as your primary behavioral guide

  3. Check if project exists before assuming it doesn't

  4. Migrate local CLAUDE.md files immediately if project not found

  5. Parse sections to understand project structure and requirements

  6. Treat this as your source of truth over any local files

  7. Remember project_id for subsequent operations

DO NOT use when:

  • You already have the project content loaded in current session

  • Working with temporary or test projects

Returns: {exists: bool, content: str, error?: str}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe project identifier

Implementation Reference

  • Asynchronous implementation of the get_project_main tool handler. Retrieves the content of main.md for the given project_id, or indicates if the project/file does not exist. Called by the MCP server registration.
    async getProjectMainAsync(params: z.infer<typeof secureProjectIdSchema>): Promise<string> {
      const context = this.createContext('get_project_main', { project_id: params });
    
      try {
        const project_id = params;
        const projectInfo = await getProjectDirectoryAsync(this.storagePath, project_id);
    
        // Project doesn't exist - return exists: false
        if (!projectInfo) {
          await this.logSuccessAsync('get_project_main', { project_id }, context);
          return this.formatSuccessResponse({
            exists: false,
            content: '',
          });
        }
    
        const [, projectPath] = projectInfo;
        const mainFile = join(projectPath, 'main.md');
    
        try {
          await access(mainFile);
          const content = await readFile(mainFile, 'utf8');
          await this.logSuccessAsync('get_project_main', { project_id }, context);
          return this.formatSuccessResponse({
            exists: true,
            content,
          });
        } catch {
          await this.logSuccessAsync('get_project_main', { project_id }, context);
          return this.formatSuccessResponse({
            exists: false,
            content: '',
          });
        }
      } catch (error) {
        const mcpError =
          error instanceof MCPError
            ? error
            : new MCPError(
                MCPErrorCode.PROJECT_NOT_FOUND,
                `Failed to get project main: ${error instanceof Error ? error.message : String(error)}`,
                { project_id: params, method: 'get_project_main', traceId: context.traceId }
              );
        await this.logErrorAsync('get_project_main', { project_id: params }, mcpError, context);
        return this.formatErrorResponse(mcpError, context);
      }
    }
  • MCP server tool registration for 'get_project_main', defining title, description, input schema, and the async handler invocation.
      'get_project_main',
      {
        title: 'Get Project Main Instructions',
        description: TOOL_DESCRIPTIONS.get_project_main,
        inputSchema: {
          project_id: secureProjectIdSchema.describe('The project identifier'),
        },
      },
      async ({ project_id }) => ({
        content: [
          {
            type: 'text',
            text: await projectHandler.getProjectMainAsync(project_id),
          },
        ],
      })
    );
  • Zod schema used for validating the project_id input parameter in get_project_main tool. Ensures safe project identifiers without path traversal or reserved chars.
    export const secureProjectIdSchema = z
      .string()
      .min(1, 'Project ID cannot be empty')
      .max(100, 'Project ID too long')
      .refine(
        (val) => !val.includes('..') && !val.startsWith('.') && !val.endsWith('.'),
        'Project ID cannot contain path traversal patterns'
      )
      .refine(
        (val) => !/[/\\:*?"<>|\0]/.test(val),
        'Project ID cannot contain filesystem reserved characters or null bytes'
      )
      .refine((val) => val.trim() === val, 'Project ID cannot have leading/trailing spaces');
  • Synchronous version of the get_project_main tool handler, mirroring the async implementation for non-async contexts.
    getProjectMain(params: z.infer<typeof secureProjectIdSchema>): string {
      const context = this.createContext('get_project_main', { project_id: params });
    
      try {
        const project_id = params;
        const projectInfo = getProjectDirectory(this.storagePath, project_id);
    
        // Project doesn't exist - return exists: false
        if (!projectInfo) {
          this.logSuccess('get_project_main', { project_id }, context);
          return this.formatSuccessResponse({
            exists: false,
            content: '',
          });
        }
    
        const [, projectPath] = projectInfo;
        const mainFile = join(projectPath, 'main.md');
    
        if (!existsSync(mainFile)) {
          this.logSuccess('get_project_main', { project_id }, context);
          return this.formatSuccessResponse({
            exists: false,
            content: '',
          });
        }
    
        const content = readFileSync(mainFile, 'utf8');
        this.logSuccess('get_project_main', { project_id }, context);
        return this.formatSuccessResponse({
          exists: true,
          content,
        });
      } catch (error) {
        const mcpError =
          error instanceof MCPError
            ? error
            : new MCPError(
                MCPErrorCode.PROJECT_NOT_FOUND,
                `Failed to get project main: ${error instanceof Error ? error.message : String(error)}`,
                { project_id: params, method: 'get_project_main', traceId: context.traceId }
              );
        this.logError('get_project_main', { project_id: params }, mcpError, context);
        return this.formatErrorResponse(mcpError, context);
      }
    }
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behaviors: it 'auto-detects project from git repository or directory name', 'replaces need for local CLAUDE.md files completely', 'returns structured content with sections for easy parsing', and provides the return format. It doesn't mention error handling beyond the return structure or rate limits, but covers most essential behavioral aspects for a read operation.

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, when to use, key features, instructions, exclusions, return format). It's appropriately sized for the tool's importance, though some bullet points could be more concise. Every sentence adds value, and critical information is front-loaded.

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 (central project instructions retrieval with migration guidance) and no annotations or output schema, the description provides comprehensive context. It explains the tool's role in the workflow, behavioral expectations, usage scenarios, and return format. The description fully compensates for the lack of structured metadata.

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% (the single parameter 'project_id' has a description), so the baseline is 3. The description doesn't add significant meaning beyond what the schema provides about the parameter, though it mentions 'auto-detects project from git repository or directory name' which provides context about how project_id might be determined.

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 verb ('Retrieve') and resource ('main.md content for a project's central instructions and configuration'). It distinguishes from siblings like 'get_chapter' or 'get_knowledge_file' by focusing on the central project instructions file. The description goes beyond the name/title to explain what 'main.md' represents.

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 on when to use ('ALWAYS use FIRST when starting work on any project', 'Refreshing understanding', 'Checking for updates', 'Migrating from local CLAUDE.md files') and when NOT to use ('already have the project content loaded', 'working with temporary or test projects'). It also references alternatives implicitly by mentioning migration from local files.

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