Skip to main content
Glama
bazinga012

MCP Code Executor

install_dependencies

Install Python packages in the Conda environment to enable code execution with required libraries and dependencies.

Instructions

Install Python dependencies in the conda environment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packagesYesList of packages to install

Implementation Reference

  • The core handler function that executes the installation of specified Python packages using the configured environment (conda, venv, or uv-venv). It constructs platform-specific shell commands, executes them, and returns success/error JSON responses.
    async function installDependencies(packages: string[]) {
        try {
            if (!packages || packages.length === 0) {
                return {
                    type: 'text',
                    text: JSON.stringify({
                        status: 'error',
                        error: 'No packages specified'
                    }),
                    isError: true
                };
            }
    
            // Build the install command based on environment type
            let installCmd = '';
            const packageList = packages.join(' ');
            
            switch (ENV_CONFIG.type) {
                case 'conda':
                    if (!ENV_CONFIG.conda_name) {
                        throw new Error("conda_name is required for conda environment");
                    }
                    installCmd = `conda install -y -n ${ENV_CONFIG.conda_name} ${packageList}`;
                    break;
                    
                case 'venv':
                    installCmd = `pip install ${packageList}`;
                    break;
                    
                case 'venv-uv':
                    installCmd = `uv pip install ${packageList}`;
                    break;
                    
                default:
                    throw new Error(`Unsupported environment type: ${ENV_CONFIG.type}`);
            }
    
            // Get platform-specific command
            const { command, options } = getPlatformSpecificCommand(installCmd);
    
            // Execute installation with unbuffered Python
            const { stdout, stderr } = await execAsync(command, {
                cwd: CODE_STORAGE_DIR,
                env: { ...process.env, PYTHONUNBUFFERED: '1' },
                ...options
            });
    
            const response = {
                status: 'success',
                env_type: ENV_CONFIG.type,
                installed_packages: packages,
                output: stdout,
                warnings: stderr || undefined
            };
    
            return {
                type: 'text',
                text: JSON.stringify(response),
                isError: false
            };
        } catch (error) {
            const response = {
                status: 'error',
                env_type: ENV_CONFIG.type,
                error: error instanceof Error ? error.message : String(error)
            };
    
            return {
                type: 'text',
                text: JSON.stringify(response),
                isError: true
            };
        }
    }
  • src/index.ts:618-633 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema for the install_dependencies tool.
        name: "install_dependencies",
        description: `Install Python dependencies in the ${ENV_CONFIG.type} environment`,
        inputSchema: {
            type: "object",
            properties: {
                packages: {
                    type: "array",
                    items: {
                        type: "string"
                    },
                    description: "List of packages to install"
                }
            },
            required: ["packages"]
        }
    },
  • TypeScript interface defining the expected arguments for the install_dependencies tool handler.
    interface InstallDependenciesArgs {
        packages?: string[];
    }
  • src/index.ts:860-875 (registration)
    Dispatcher case in the central CallToolRequest handler that validates args and invokes the installDependencies function.
    case "install_dependencies": {
        const args = request.params.arguments as InstallDependenciesArgs;
        if (!args?.packages || !Array.isArray(args.packages)) {
            throw new Error("Valid packages array is required");
        }
    
        const result = await installDependencies(args.packages);
    
        return {
            content: [{
                type: "text",
                text: result.text,
                isError: result.isError
            }]
        };
    }
  • Helper function used by installDependencies (and others) to generate platform-specific shell commands for environment activation.
    function getPlatformSpecificCommand(pythonCommand: string): { command: string, options: ExecOptions } {
        const isWindows = platform() === 'win32';
        let command = '';
        let options: ExecOptions = {};
        
        switch (ENV_CONFIG.type) {
            case 'conda':
                if (!ENV_CONFIG.conda_name) {
                    throw new Error("conda_name is required for conda environment");
                }
                if (isWindows) {
                    command = `conda run -n ${ENV_CONFIG.conda_name} ${pythonCommand}`;
                    options = { shell: 'cmd.exe' };
                } else {
                    command = `source $(conda info --base)/etc/profile.d/conda.sh && conda activate ${ENV_CONFIG.conda_name} && ${pythonCommand}`;
                    options = { shell: '/bin/bash' };
                }
                break;
                
            case 'venv':
                if (!ENV_CONFIG.venv_path) {
                    throw new Error("venv_path is required for virtualenv");
                }
                if (isWindows) {
                    command = `${join(ENV_CONFIG.venv_path, 'Scripts', 'activate')} && ${pythonCommand}`;
                    options = { shell: 'cmd.exe' };
                } else {
                    command = `source ${join(ENV_CONFIG.venv_path, 'bin', 'activate')} && ${pythonCommand}`;
                    options = { shell: '/bin/bash' };
                }
                break;
                
            case 'venv-uv':
                if (!ENV_CONFIG.uv_venv_path) {
                    throw new Error("uv_venv_path is required for uv virtualenv");
                }
                if (isWindows) {
                    command = `${join(ENV_CONFIG.uv_venv_path, 'Scripts', 'activate')} && ${pythonCommand}`;
                    options = { shell: 'cmd.exe' };
                } else {
                    command = `source ${join(ENV_CONFIG.uv_venv_path, 'bin', 'activate')} && ${pythonCommand}`;
                    options = { shell: '/bin/bash' };
                }
                break;
                
            default:
                throw new Error(`Unsupported environment type: ${ENV_CONFIG.type}`);
        }
        
        return { command, options };
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 states the action ('install') but doesn't reveal critical traits such as whether this requires admin permissions, if it's idempotent, potential side effects on the environment, or error handling. This leaves significant gaps 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.

Conciseness5/5

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

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose, making it easy to parse quickly, which is ideal for conciseness in tool descriptions.

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?

For a tool that performs installation (a mutation operation) with no annotations and no output schema, the description is inadequate. It lacks details on behavior, error cases, or what success looks like, leaving the agent under-informed about how to use it effectively in context.

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%, with the 'packages' parameter fully documented in the schema. The description doesn't add any meaning beyond what the schema provides (e.g., package format examples or installation options), so it meets the baseline for high schema coverage without extra value.

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 ('install') and target ('Python dependencies in the conda environment'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from sibling tools like 'check_installed_packages' or 'configure_environment', which prevents a perfect score.

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 'check_installed_packages' for verification or 'configure_environment' for setup. There's no mention of prerequisites, typical use cases, or exclusions, leaving the agent with minimal contextual direction.

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/bazinga012/mcp_code_executor'

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