Skip to main content
Glama
bswa006

AI Agent Template MCP Server

by bswa006

initialize_agent_workspace

Set up AI agent development workspace with template files and project context for coding projects.

Instructions

Initialize AI agent workspace with template files and context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the project directory
projectNameYesName of the project
techStackNoOptional tech stack configuration

Implementation Reference

  • Core handler function that initializes the agent workspace by creating and customizing essential template files like AGENT-CODING-TEMPLATE.md, AGENT-CONTEXT.md, AGENT-MEMORY.md, .context7.yaml, and CODEBASE-CONTEXT.md.
    export async function initializeAgentWorkspace(
      config: WorkspaceConfig
    ): Promise<InitializationResult> {
      const result: InitializationResult = {
        success: false,
        filesCreated: [],
        configuration: {
          templatePath: '',
          contextPath: '',
          memoryPath: '',
          context7Path: '',
        },
        nextSteps: [],
        message: '',
      };
    
      try {
        // Ensure project directory exists
        if (!existsSync(config.projectPath)) {
          mkdirSync(config.projectPath, { recursive: true });
        }
    
        // Define file paths
        const templatePath = join(config.projectPath, 'AGENT-CODING-TEMPLATE.md');
        const contextPath = join(config.projectPath, 'AGENT-CONTEXT.md');
        const memoryPath = join(config.projectPath, 'AGENT-MEMORY.md');
        const context7Path = join(config.projectPath, '.context7.yaml');
        const codebaseContextPath = join(config.projectPath, 'CODEBASE-CONTEXT.md');
    
        // Copy and customize AGENT-CODING-TEMPLATE.md
        if (!existsSync(templatePath)) {
          const templateContent = readFileSync(
            join(__dirname, '../../../AGENT-CODING-TEMPLATE.md'),
            'utf-8'
          );
          const customizedTemplate = customizeTemplate(templateContent, config);
          writeFileSync(templatePath, customizedTemplate);
          result.filesCreated.push('AGENT-CODING-TEMPLATE.md');
        }
    
        // Copy and customize AGENT-CONTEXT.md
        if (!existsSync(contextPath)) {
          const contextContent = readFileSync(
            join(__dirname, '../../../AGENT-CONTEXT.md'),
            'utf-8'
          );
          const customizedContext = initializeContext(contextContent, config);
          writeFileSync(contextPath, customizedContext);
          result.filesCreated.push('AGENT-CONTEXT.md');
        }
    
        // Copy AGENT-MEMORY.md
        if (!existsSync(memoryPath)) {
          const memoryContent = readFileSync(
            join(__dirname, '../../../AGENT-MEMORY.md'),
            'utf-8'
          );
          writeFileSync(memoryPath, memoryContent);
          result.filesCreated.push('AGENT-MEMORY.md');
        }
    
        // Copy and customize .context7.yaml
        if (!existsSync(context7Path)) {
          const context7Content = readFileSync(
            join(__dirname, '../../../.context7.yaml'),
            'utf-8'
          );
          const customizedContext7 = customizeContext7(context7Content, config);
          writeFileSync(context7Path, customizedContext7);
          result.filesCreated.push('.context7.yaml');
        }
    
        // Create initial CODEBASE-CONTEXT.md if it doesn't exist
        if (!existsSync(codebaseContextPath)) {
          const codebaseContext = generateInitialCodebaseContext(config);
          writeFileSync(codebaseContextPath, codebaseContext);
          result.filesCreated.push('CODEBASE-CONTEXT.md');
        }
    
        // Set configuration paths
        result.configuration = {
          templatePath,
          contextPath,
          memoryPath,
          context7Path,
        };
    
        // Define next steps
        result.nextSteps = [
          '1. Review AGENT-CODING-TEMPLATE.md for your mission briefing',
          '2. Check CODEBASE-CONTEXT.md and customize for your project',
          '3. Update .context7.yaml with your specific library versions',
          '4. Start development with pre-flight checklist from template',
          '5. Use tracking tools to monitor performance',
        ];
    
        result.success = true;
        result.message = `Workspace initialized successfully for ${config.projectName}. Agent memory system is now active!`;
    
      } catch (error) {
        result.success = false;
        result.message = `Failed to initialize workspace: ${error}`;
      }
    
      return result;
    }
  • Dispatch handler in the main tool router that parses input arguments with Zod and delegates to the initializeAgentWorkspace implementation.
    case 'initialize_agent_workspace': {
      const params = z.object({
        projectPath: z.string(),
        projectName: z.string(),
        techStack: z.object({
          language: z.string().optional(),
          framework: z.string().optional(),
          uiLibrary: z.string().optional(),
          testFramework: z.string().optional(),
        }).optional(),
      }).parse(args);
      
      const result = await initializeAgentWorkspace(params);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • JSON schema definition for the tool's input parameters, used for validation and tool listing.
    {
      name: 'initialize_agent_workspace',
      description: 'Initialize AI agent workspace with template files and context',
      inputSchema: {
        type: 'object',
        properties: {
          projectPath: {
            type: 'string',
            description: 'Path to the project directory',
          },
          projectName: {
            type: 'string',
            description: 'Name of the project',
          },
          techStack: {
            type: 'object',
            properties: {
              language: { type: 'string' },
              framework: { type: 'string' },
              uiLibrary: { type: 'string' },
              testFramework: { type: 'string' },
            },
            description: 'Optional tech stack configuration',
          },
        },
        required: ['projectPath', 'projectName'],
      },
    },
  • Registration of the tool list handler that returns all tool definitions, including initialize_agent_workspace.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      console.error(`Handling tools/list request, returning ${toolDefinitions.length} tools`);
      return { tools: toolDefinitions };
    });
  • Helper function to customize the AGENT-CODING-TEMPLATE.md with project-specific details.
    function customizeTemplate(template: string, config: WorkspaceConfig): string {
      const now = new Date().toISOString();
      
      return template
        .replace(/\[PROJECT_NAME\]/g, config.projectName)
        .replace(/\[PROJECT_PATH\]/g, config.projectPath)
        .replace(/\[DETECTED_LANGUAGE\]/g, config.techStack?.language || 'typescript')
        .replace(/\[DETECTED_FRAMEWORK\]/g, config.techStack?.framework || 'react')
        .replace(/\[DETECTED_UI_LIBRARY\]/g, config.techStack?.uiLibrary || 'tailwindcss')
        .replace(/\[DETECTED_TEST_FRAMEWORK\]/g, config.techStack?.testFramework || 'jest')
        .replace(/\[AUTO_UPDATE\]/g, now)
        .replace(/\[TIMESTAMP\]/g, now);
    }
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. It mentions 'initialize' but doesn't disclose behavioral traits like whether this is a one-time setup, if it overwrites existing files, what permissions are needed, or what happens on failure. This is a significant gap for a tool that likely modifies a workspace.

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, efficient sentence that front-loads the core purpose without unnecessary words. Every part earns its place by clearly stating 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 complexity (3 parameters with nested objects, no output schema, and no annotations), the description is incomplete. It doesn't explain what 'initialize' entails operationally, what the output or success criteria are, or address potential side effects, making it inadequate for safe and effective 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?

Schema description coverage is 100%, so the schema already documents all parameters. The description adds no additional meaning beyond implying that 'techStack' relates to configuration, but it doesn't explain how parameters interact or provide examples. Baseline 3 is appropriate as 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 ('initialize') and the resource ('AI agent workspace'), specifying it involves 'template files and context'. However, it doesn't explicitly differentiate this from sibling tools like 'complete_setup_workflow' or 'create_ide_configs', which might have overlapping functionality.

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, timing, or compare it to siblings such as 'complete_setup_workflow', leaving the agent to infer 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

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/bswa006/mcp-context-manager'

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