Skip to main content
Glama

install_package

Install Python packages in a persistent REPL environment using the MCP protocol. Specify the package name to enable Python runtime customization and execution.

Instructions

Install a Python package using uv

Input Schema

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

Implementation Reference

  • Handler logic for the 'install_package' tool. Validates the package name, installs it using 'uv pip install', imports it into the global namespace, and returns success or error messages.
    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}" ) ] elif name == "list_variables":
  • Registers the 'install_package' tool in the list_tools handler, including its name, description, and input schema requiring a 'package' string.
    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 an object with a required 'package' property of type string.
    inputSchema={ "type": "object", "properties": { "package": { "type": "string", "description": "Package name to install (e.g., 'pandas')", } }, "required": ["package"], },

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

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