Skip to main content
Glama

init_project

Initialize a trace project by creating the .trace-mcp config directory and project structure for watch mode and caching.

Instructions

Initialize a trace project with .trace-mcp config directory. Creates project structure for watch mode and caching.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectDirYesRoot directory for the trace project
producerPathYesRelative path to producer/server code
consumerPathYesRelative path to consumer/client code
producerLanguageNoProducer language (default: typescript)
consumerLanguageNoConsumer language (default: typescript)

Implementation Reference

  • Main handler for the 'init_project' MCP tool. Parses input, loads TraceProject instance, initializes project directories and config if new, handles existing project error, logs and returns success response with config.
    case 'init_project': {
      const input = InitProjectInput.parse(args);
      log(`Initializing trace project at: ${input.projectDir}`);
      
      const project = loadProject(input.projectDir);
      
      if (project.exists()) {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              success: false,
              error: `Project already exists at ${input.projectDir}. Use get_project_status to view it.`,
            }, null, 2),
          }],
        };
      }
      
      const config = project.init({
        producer: {
          path: input.producerPath,
          language: input.producerLanguage || 'typescript',
          include: ['**/*.ts'],
          exclude: ['**/*.test.ts', '**/node_modules/**', '**/dist/**'],
        },
        consumer: {
          path: input.consumerPath,
          language: input.consumerLanguage || 'typescript',
          include: ['**/*.ts', '**/*.tsx'],
          exclude: ['**/*.test.ts', '**/node_modules/**', '**/dist/**'],
        },
      });
      
      log(`Project initialized with config:`, config);
      
      return {
        content: [{
          type: 'text',
          text: JSON.stringify({
            success: true,
            projectDir: input.projectDir,
            traceDir: project.traceDir,
            config,
          }, null, 2),
        }],
      };
    }
  • Zod input schema validation for the init_project tool parameters.
    const InitProjectInput = z.object({
      projectDir: z.string().describe('Root directory for the trace project'),
      producerPath: z.string().describe('Relative path to producer/server code'),
      consumerPath: z.string().describe('Relative path to consumer/client code'),
      producerLanguage: z.enum(['typescript', 'python', 'go', 'rust', 'json_schema']).optional().default('typescript'),
      consumerLanguage: z.enum(['typescript', 'python', 'go', 'rust', 'json_schema']).optional().default('typescript'),
    });
  • src/index.ts:238-251 (registration)
    Tool registration object returned by ListToolsRequestHandler, defining name, description, and inputSchema for init_project.
      name: 'init_project',
      description: 'Initialize a trace project with .trace-mcp config directory. Creates project structure for watch mode and caching.',
      inputSchema: {
        type: 'object',
        properties: {
          projectDir: { type: 'string', description: 'Root directory for the trace project' },
          producerPath: { type: 'string', description: 'Relative path to producer/server code' },
          consumerPath: { type: 'string', description: 'Relative path to consumer/client code' },
          producerLanguage: { type: 'string', enum: ['typescript', 'python', 'go', 'rust', 'json_schema'], description: 'Producer language (default: typescript)' },
          consumerLanguage: { type: 'string', enum: ['typescript', 'python', 'go', 'rust', 'json_schema'], description: 'Consumer language (default: typescript)' },
        },
        required: ['projectDir', 'producerPath', 'consumerPath'],
      },
    },
  • Core initialization logic in TraceProject.init() method: creates .trace-mcp subdirectories (cache, contracts, reports), parses and writes config.json using ProjectConfigSchema, adds .gitignore. Called directly by the tool handler.
    init(config: Partial<ProjectConfig>): ProjectConfig {
      // Create directories
      mkdirSync(this.traceDir, { recursive: true });
      mkdirSync(this.cachePath, { recursive: true });
      mkdirSync(this.contractsPath, { recursive: true });
      mkdirSync(this.reportsPath, { recursive: true });
    
      // Create config with defaults
      const fullConfig = ProjectConfigSchema.parse(config);
      
      // Write config
      writeFileSync(this.configPath, JSON.stringify(fullConfig, null, 2));
      this._config = fullConfig;
    
      // Create .gitignore for cache
      writeFileSync(
        join(this.traceDir, '.gitignore'),
        '# Trace MCP cache (regenerated)\ncache/\nreports/\n'
      );
    
      return fullConfig;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions creating a project structure and config directory, which implies a write operation, but doesn't cover permissions, side effects, error handling, or what happens if the project already exists. This is inadequate for a tool that likely modifies the filesystem.

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 front-loaded with the core purpose in the first sentence and uses a second sentence to add details about the created structure. It's efficient with no wasted words, though it could be slightly more structured by explicitly separating purpose from outcomes.

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 complexity of initializing a project with multiple parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral aspects like mutation effects, error cases, and what the tool returns, making it insufficient for safe and effective use 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-specific information beyond what the input schema provides, which has 100% coverage with detailed descriptions and enums. The baseline score of 3 is appropriate as the schema fully documents the parameters, but the description doesn't enhance understanding of their semantics or interactions.

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 ('Initialize') and resource ('trace project'), specifying it creates a .trace-mcp config directory and project structure for watch mode and caching. However, it doesn't explicitly differentiate from sibling tools like 'scaffold_consumer' or 'scaffold_producer', which might have overlapping initialization functions.

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 like 'scaffold_consumer' or 'scaffold_producer', nor does it mention prerequisites or exclusions. It implies usage for setting up a trace project but lacks explicit context for tool selection.

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/Mnehmos/mnehmos.trace.mcp'

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