Skip to main content
Glama
hdresearch

Python REPL MCP Server

by hdresearch

install_package

Install Python packages in a REPL environment using uv for code execution and variable management.

Instructions

Install a Python package using uv

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageYesPackage name to install (e.g., 'pandas')

Implementation Reference

  • Handler for the 'install_package' tool. Validates the package name, installs the package using 'uv pip install', attempts to import it into the shared global namespace, and returns appropriate text content responses for success or errors.
    elif name == "install_package":
        package = arguments.get("package")
        if not package:
            raise ValueError("Missing package name")
            
        # Basic package name validation
        if not re.match("^[A-Za-z0-9][A-Za-z0-9._-]*$", package):
            return [
                types.TextContent(
                    type="text",
                    text=f"Invalid package name: {package}"
                )
            ]
        
        try:
            # Install package using uv
            process = subprocess.run(
                ["uv", "pip", "install", package],
                capture_output=True,
                text=True,
                check=True
            )
    
            if process.returncode != 0:
                return [
                    types.TextContent(
                        type="text",
                        text=f"Failed to install package: {process.stderr}"
                    )
                ]
            
            # Import the package to make it available in the REPL
            try:
                exec(f"import {package.split('[')[0]}", self.global_namespace)
                return [
                    types.TextContent(
                        type="text",
                        text=f"Successfully installed and imported {package}"
                    )
                ]
            except ImportError as e:
                return [
                    types.TextContent(
                        type="text",
                        text=f"Package installed but import failed: {str(e)}"
                    )
                ]
                
        except subprocess.CalledProcessError as e:
            return [
                types.TextContent(
                    type="text",
                    text=f"Failed to install package:\n{e.stderr}"
                )
            ]
  • Registration of the 'install_package' tool in the list_tools handler, including its name, description, and input schema definition.
    types.Tool(
        name="install_package",
        description="Install a Python package using uv",
        inputSchema={
            "type": "object",
            "properties": {
                "package": {
                    "type": "string",
                    "description": "Package name to install (e.g., 'pandas')",
                }
            },
            "required": ["package"],
        },
    )
  • Input schema definition for the 'install_package' tool, specifying the required 'package' string parameter.
    inputSchema={
        "type": "object",
        "properties": {
            "package": {
                "type": "string",
                "description": "Package name to install (e.g., 'pandas')",
            }
        },
        "required": ["package"],
    },
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 doesn't describe what happens during installation (e.g., dependencies resolved, package added to environment), potential side effects (e.g., system changes, conflicts), or error conditions. 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 a single, efficient sentence that directly states the tool's purpose without any wasted words. It's appropriately sized for a simple tool and front-loaded with the core action. Every part of the sentence earns its place by specifying what, how, and the tool used.

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 tool's complexity (a mutation operation with no annotations and no output schema), the description is incomplete. It doesn't explain what the tool returns (e.g., success/failure, installation details), behavioral traits, or usage context. For a package installation tool that modifies the environment, more information is needed to guide the agent effectively.

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%, with the single parameter 'package' documented in the schema as 'Package name to install (e.g., 'pandas')'. The description adds no additional parameter information beyond what the schema provides. According to the rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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 the resource ('a Python package'), and specifies the tool used ('using uv'). It distinguishes from sibling tools like 'execute_python' and 'list_variables' by focusing on package installation rather than code execution or variable listing. However, it doesn't explicitly differentiate from hypothetical similar tools (e.g., 'install_package_with_pip'), so it's not a perfect 5.

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., Python environment setup), when not to use it (e.g., for system packages), or compare to other installation methods. The agent must infer usage from the purpose alone, which is insufficient for optimal tool 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/hdresearch/mcp-python'

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