Skip to main content
Glama
yzfly

MCP Python Interpreter

by yzfly

install_package

Install Python packages in specified environments to add functionality, with options to upgrade existing packages and set execution time limits.

Instructions

Install a Python package in the specified environment.

Args:
    package_name: Name of the package to install
    environment: Name of the Python environment
    upgrade: Whether to upgrade if already installed
    timeout: Maximum execution time in seconds

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
package_nameYes
environmentNodefault
upgradeNo
timeoutNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function implementing the 'install_package' MCP tool. It uses pip to install or upgrade the specified package in the chosen Python environment via subprocess execution. Includes input validation for environments and error handling.
    @mcp.tool()
    async def install_package(
        package_name: str,
        environment: str = "default",
        upgrade: bool = False,
        timeout: int = 300
    ) -> str:
        """
        Install a Python package in the specified environment.
        
        Args:
            package_name: Name of the package to install
            environment: Name of the Python environment
            upgrade: Whether to upgrade if already installed
            timeout: Maximum execution time in seconds
        """
        environments = get_python_environments()
        
        if environment == "default" and not any(e["name"] == "default" for e in environments):
            environment = "system"
            
        env = next((e for e in environments if e["name"] == environment), None)
        if not env:
            return f"Environment '{environment}' not found. Available: {', '.join(e['name'] for e in environments)}"
        
        cmd = [env["path"], "-m", "pip", "install"]
        if upgrade:
            cmd.append("--upgrade")
        cmd.append(package_name)
        
        result = await run_subprocess_async(cmd, timeout=timeout)
        
        if result["status"] == 0:
            return f"Successfully {'upgraded' if upgrade else 'installed'} {package_name} in {environment}."
        else:
            return f"Error installing {package_name}:\n{result['stderr']}"
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 of behavioral disclosure. It states the action ('install') but lacks details on permissions required, side effects (e.g., modifies environment state), error handling (e.g., what happens if package not found), or output format. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 well-structured and concise: a clear purpose statement followed by a bullet-point list of parameters. Every sentence earns its place by directly explaining the tool or its inputs, with no redundant or vague language. It's front-loaded with the core action, making it easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a mutation tool with 4 parameters) and no annotations, the description is moderately complete. It covers the purpose and parameters but lacks behavioral details (e.g., side effects, errors) and usage context. The presence of an output schema (not detailed here) might help with return values, but overall, it's adequate with clear gaps for safe 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?

The description lists all four parameters with brief explanations, but schema description coverage is 0%, meaning the schema provides no descriptions. The description adds basic semantics (e.g., 'Name of the package to install'), but it doesn't elaborate on constraints (e.g., package naming conventions) or dependencies (e.g., environment must be valid). This compensates partially but not fully for the schema gap.

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 tool's purpose: 'Install a Python package in the specified environment.' It specifies the verb ('install') and resource ('Python package'), making the action unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_installed_packages' or 'run_python_code', which would require more specific context about when to use installation versus other package-related operations.

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 (e.g., environment must exist), exclusions (e.g., not for system-wide installation), or comparisons to siblings like 'run_python_code' for testing packages. Without such context, an agent might misuse it in scenarios better handled by other tools.

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/yzfly/mcp-python-interpreter'

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