Skip to main content
Glama

devcontainer_run_user_commands

Execute user-defined setup and initialization scripts in a development container for a specified workspace folder, ensuring required commands run after the container starts.

Instructions

Run the user-defined postCreateCommand and postStartCommand scripts in the devcontainerfor the specified workspace folder. Use this to execute setup or initialization commandsafter the devcontainer starts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
outputFilePathNo
workspaceFolderYes

Implementation Reference

  • Core handler function that executes the devcontainer CLI 'run-user-commands' subcommand by spawning the binary with workspace folder argument and handling stdout.
    export async function runUserCommands(options: DevContainerRunUserCommandsOptions): Promise<number> { return runCommand( ['run-user-commands', '--workspace-folder', options.workspaceFolder], createStdoutStream(options) ); }
  • src/server.ts:32-53 (registration)
    Registers the MCP tool 'devcontainer_run_user_commands' with name, description, Zod input schema, and thin async wrapper that calls the core handler.
    server.tool( "devcontainer_run_user_commands", "Run the user-defined postCreateCommand and postStartCommand scripts in the devcontainer" + "for the specified workspace folder. Use this to execute setup or initialization commands" + "after the devcontainer starts.", { workspaceFolder: z.string(), outputFilePath: z.string().optional(), }, async ({ workspaceFolder, outputFilePath }) => { await devcontainers.runUserCommands({ workspaceFolder, stdioFilePath: outputFilePath }); return { content: [ { type: "text", text: `User commands run in ${workspaceFolder}`, } ] } } );
  • Zod validation schema for tool parameters used in MCP tool registration.
    { workspaceFolder: z.string(), outputFilePath: z.string().optional(), },
  • TypeScript interface defining input options for the runUserCommands handler.
    interface DevContainerRunUserCommandsOptions extends DevcontainerOptions { workspaceFolder: string; }
  • Shared helper function for spawning devcontainer CLI processes, piping stdout, and resolving/rejecting based on exit code.
    async function runCommand(args: string[], stdout: fs.WriteStream): Promise<number> { return new Promise((resolve, reject) => { const proc = spawn('node', [devcontainerBinaryPath(), ...args], { stdio: ['ignore', 'pipe', 'inherit'], }); proc.stdout.pipe(stdout); proc.on('close', (code) => { stdout.end(); if (code === 0) { resolve(code); } else { reject(new Error(`devcontainer command ${args.join(' ')} exited with code ${code}`)); } }); }); }

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/crunchloop/mcp-devcontainers'

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