Skip to main content
Glama
bazinga012

MCP Code Executor

configure_environment

Set up Python execution environments by configuring conda or virtualenv settings to manage dependencies for code execution.

Instructions

Change the environment configuration settings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYesType of Python environment
conda_nameNoName of the conda environment (required if type is 'conda')
venv_pathNoPath to the virtualenv (required if type is 'venv')
uv_venv_pathNoPath to the UV virtualenv (required if type is 'venv-uv')

Implementation Reference

  • Main handler implementation for the 'configure_environment' tool. Validates input arguments, checks environment type, uses helper to validate config, updates global ENV_CONFIG, and returns JSON response with previous and current config.
    case "configure_environment": {
        // Safely access and validate arguments
        const rawArgs = request.params.arguments || {};
        
        // Check if type exists and is one of the allowed values
        if (!rawArgs || typeof rawArgs !== 'object' || !('type' in rawArgs) || 
            !['conda', 'venv', 'venv-uv'].includes(String(rawArgs.type))) {
            return {
                content: [{
                    type: "text",
                    text: JSON.stringify({
                        status: 'error',
                        error: "Invalid arguments: 'type' is required and must be one of 'conda', 'venv', or 'venv-uv'"
                    }),
                    isError: true
                }]
            };
        }
        
        // Now we can safely create a properly typed object
        const args: ConfigureEnvironmentArgs = {
            type: String(rawArgs.type) as 'conda' | 'venv' | 'venv-uv',
            conda_name: 'conda_name' in rawArgs ? String(rawArgs.conda_name) : undefined,
            venv_path: 'venv_path' in rawArgs ? String(rawArgs.venv_path) : undefined,
            uv_venv_path: 'uv_venv_path' in rawArgs ? String(rawArgs.uv_venv_path) : undefined,
        };
        
        // Validate configuration
        const validationError = validateEnvironmentConfig(args);
        if (validationError) {
            return {
                content: [{
                    type: "text",
                    text: JSON.stringify({
                        status: 'error',
                        error: validationError
                    }),
                    isError: true
                }]
            };
        }
        
        // Update configuration
        const previousConfig = { ...ENV_CONFIG };
        ENV_CONFIG = {
            ...ENV_CONFIG,
            type: args.type,
            ...(args.conda_name && { conda_name: args.conda_name }),
            ...(args.venv_path && { venv_path: args.venv_path }),
            ...(args.uv_venv_path && { uv_venv_path: args.uv_venv_path })
        };
        
        return {
            content: [{
                type: "text",
                text: JSON.stringify({
                    status: 'success',
                    message: 'Environment configuration updated',
                    previous: previousConfig,
                    current: ENV_CONFIG
                }),
                isError: false
            }]
        };
    }
  • TypeScript interface defining the expected input schema for the configure_environment tool arguments.
    interface ConfigureEnvironmentArgs {
        type: 'conda' | 'venv' | 'venv-uv';
        conda_name?: string;
        venv_path?: string;
        uv_venv_path?: string;
    }
  • src/index.ts:652-677 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema matching the handler args.
        name: "configure_environment",
        description: "Change the environment configuration settings",
        inputSchema: {
            type: "object",
            properties: {
                type: {
                    type: "string",
                    enum: ["conda", "venv", "venv-uv"],
                    description: "Type of Python environment"
                },
                conda_name: {
                    type: "string",
                    description: "Name of the conda environment (required if type is 'conda')"
                },
                venv_path: {
                    type: "string",
                    description: "Path to the virtualenv (required if type is 'venv')"
                },
                uv_venv_path: {
                    type: "string",
                    description: "Path to the UV virtualenv (required if type is 'venv-uv')"
                }
            },
            required: ["type"]
        }
    },
  • Helper function to validate the environment configuration arguments based on the selected type.
    function validateEnvironmentConfig(config: ConfigureEnvironmentArgs): string | null {
        if (config.type === 'conda' && !config.conda_name) {
            return "conda_name is required when type is 'conda'";
        } else if (config.type === 'venv' && !config.venv_path) {
            return "venv_path is required when type is 'venv'";
        } else if (config.type === 'venv-uv' && !config.uv_venv_path) {
            return "uv_venv_path is required when type is 'venv-uv'";
        }
        return null;
    }
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 'Change' implying a mutation, but doesn't specify permissions needed, whether changes are reversible, potential side effects, or error handling. This is inadequate for a configuration tool with zero annotation coverage.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 environment configuration, no annotations, and no output schema, the description is insufficient. It lacks details on behavioral traits, usage context, and expected outcomes, making it incomplete for effective tool invocation.

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 fully documents all parameters. The description adds no additional meaning beyond the schema's details about environment types and paths, meeting the baseline for high 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 'Change the environment configuration settings' clearly states the action ('Change') and resource ('environment configuration settings'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get_environment_config' (which likely reads rather than changes settings), leaving room for improvement in distinguishing 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 how it relates to sibling tools such as 'get_environment_config' or 'install_dependencies', leaving the agent without context for 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/bazinga012/mcp_code_executor'

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