A comprehensive Python virtual environment inspector for Cursor IDE using the Model Context Protocol (MCP).
- 🔍 Virtual Environment Detection - Automatically find and analyze Python virtual environments
- 📦 Package Management - List, check, and compare installed packages
- 📋 Requirements Analysis - Compare installed packages with requirements files
- 🐍 Python Version Detection - Get Python version information from virtual environments
- 🔧 Multi-Format Support - Support for requirements.txt, pyproject.toml, Pipfile, and more
- ⚡ UV Support - Full support for uv-managed environments
- 🎯 Flexible Configuration - Choose between pip and uv via environment variables
✅ Fully Supported:
- pip - Python package manager
- uv - Fast Python package manager (recommended)
- pipenv - Python dependency management
❌ Not Supported:
- PDM - Python Dependency Manager (not yet implemented)
- Poetry - Limited support (detection only, no package operations)
npm install -g @pceuropa/mcp-server-python-venv
For better control, specify the package manager explicitly:
{
"mcpServers": {
"python-venv": {
"command": "npx",
"args": ["@pceuropa/mcp-server-python-venv"],
"transport": "stdio",
"env": {
"PYTHON_PATH": "${workspaceFolder}/.venv/bin/python",
"VIRTUAL_ENV": "${workspaceFolder}/.venv",
"UV_PATH": "/path/to/uv"
}
}
}
}
Alternative for pip-managed projects:
{
"mcpServers": {
"python-venv": {
"command": "npx",
"args": ["@pceuropa/mcp-server-python-venv"],
"transport": "stdio",
"env": {
"PYTHON_PATH": "${workspaceFolder}/.venv/bin/python",
"VIRTUAL_ENV": "${workspaceFolder}/.venv",
"PIP_PATH": "${workspaceFolder}/.venv/bin/pip"
}
}
}
}
Test server connectivity.
Find virtual environment in the current project.
- Input:
projectPath
(optional) - Project path to search - Output: Virtual environment information
Get Python version from the virtual environment.
- Output: Python version and path
List all installed packages in the virtual environment.
- Input:
sortBy
(optional) - Sort by "name" or "version" - Output: List of installed packages
Check if a specific package is installed and matches version requirements.
- Input:
packageName
(required) - Name of the packageversion
(optional) - Version requirement (e.g., ">=1.0.0", "==2.1.0")
- Output: Package installation status and version info
Compare installed packages with requirements files.
- Input:
file
(optional) - Specific requirements file to check - Output: Missing, extra, and mismatched packages with install command
Check for outdated packages in the virtual environment.
- Output: List of outdated packages with upgrade commands
Get suggestions for setting up a virtual environment.
- Output: Setup commands and tool recommendations
Get a comprehensive summary of the virtual environment.
- Output: Python version, package count, size, requirements status, and outdated count
Get dependency tree visualization for packages.
- Input:
package
(optional) - Specific package to analyzedepth
(optional) - Maximum depth of dependency tree (default: 3)
- Output: Dependency tree with circular dependencies and unused packages
Detect which Python environment manager is being used.
- Input:
projectPath
(optional) - Project path to analyze - Output: Detected manager (venv, poetry, pipenv, conda, uv) with config files
Get Poetry project information and dependencies.
- Input:
projectPath
(optional) - Project path - Output: Poetry project details, dependencies, and environment info
- Note: Limited support - detection only, package operations may not work
Get Pipenv project information and dependencies.
- Input:
projectPath
(optional) - Project path - Output: Pipenv project details, dependencies, and environment info
Get Conda environment information and packages.
- Input:
projectPath
(optional) - Project path - Output: Conda environment details, packages, and configuration
- Note: Basic support - may have limited functionality
Check for security vulnerabilities in installed packages.
- Output: List of vulnerabilities with severity and fix recommendations
Check licenses of installed packages and identify potential issues.
- Output: License information with warnings for problematic licenses
Search for packages on PyPI.
- Input:
query
(required) - Search querylimit
(optional) - Maximum results (default: 10)
- Output: Search results with package information
Export current environment to various formats.
- Input:
format
(required) - Export format: "requirements", "pyproject", or "conda" - Output: Formatted environment specification
The server supports the following environment variables for configuration:
Variable | Description | Priority |
---|---|---|
UV_PATH |
Path to uv executable (forces uv usage) | Highest |
PIP_PATH |
Path to pip executable (forces pip usage) | High |
PYTHON_PATH |
Path to Python executable | Medium |
VIRTUAL_ENV |
Path to virtual environment | Medium |
Priority Order:
UV_PATH
- If set, usesuv pip
for all operationsPIP_PATH
- If set, uses specified pip executable- Auto-detection - Detects package manager from project files
- PDM (Python Dependency Manager) - Not yet implemented
- Poetry - Limited support (detection only, no package operations)
- Poetry environments - Can detect but cannot list packages
- PDM environments - Not detected or supported
- Mixed environments - May not work correctly if using multiple package managers
-
Check environment variables:
echo $VIRTUAL_ENV echo $PYTHON_PATH
-
Use explicit paths in MCP configuration:
{ "env": { "VIRTUAL_ENV": "/absolute/path/to/your/venv", "PYTHON_PATH": "/absolute/path/to/your/venv/bin/python" } }
-
Restart Cursor IDE after configuration changes
- For UV projects: Ensure
UV_PATH
is set - For pip projects: Ensure
PIP_PATH
is set - Check package manager detection:
npx @pceuropa/mcp-server-python-venv # Then call detect_environment_manager tool
# Test the server directly
npx @pceuropa/mcp-server-python-venv
# Test with a specific command
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | npx @pceuropa/mcp-server-python-venv
- Add the configuration to your
.cursor/settings.json
- Restart Cursor IDE
- Open Command Palette (
Ctrl+Shift+P
/Cmd+Shift+P
) - Type "MCP" and select "MCP: Show Servers"
- Verify that "python-venv" server is connected
- Node.js 18+
- Python 3.8+
- npm or yarn
git clone https://github.com/pceuropa/mcp-server-python-venv.git
cd mcp-server-python-venv
npm install
npm run build
npm run dev
npm test
npm run lint
npm run format
- venv - Standard Python venv
- virtualenv - Virtualenv package
- uv - UV package manager (recommended)
- pipenv - Pipenv environments
- conda - Conda environments
- poetry - Poetry environments (detection only)
requirements.txt
requirements-dev.txt
requirements-test.txt
pyproject.toml
(project dependencies)pyproject.toml
(poetry dependencies - limited support)Pipfile
setup.py
(basic support)
MIT License - see LICENSE file for details.
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.
- NPM: Package
- Discussions: GitHub Discussions
- Email: info@pceuropa.net
See CHANGELOG.md for version history and updates.