MCPymol is a Model Context Protocol (MCP) server that provides a conversational interface for viewing and analyzing protein structures using PyMOL. It exposes PyMOL's powerful molecular visualization capabilities to AI assistants (like Claude), allowing you to seamlessly load structures, manipulate views, and explore proteins using natural language. For example, I made the image above by typing this prompt into Claude Code, "Show me a nucleosome". Literally, that was it.
A few words... Let's face it. Pymol is great, but it's terrible to use. The syntax is extremely obscure, and while it's got python in the name, it's not exacly python. This is for people who just want to look at structures and have fun with proteins in a simple, conversational way.
This code was developed from scratch using a combination of Antigravity, Gemini Pro 3.1 (until I ran out of tokens) and then Claude Code (Sonnet 4.6 thinking). Claude gave itself credit. Gemini did not. Read into that what you will. All the development was done on macos, with testing using the open source pymol available through homebrew. It's been tested with both Claude Code and Gemini CLI. No plans to test on other models/assistants.
the name My best friend in high school once shared an apartment with MC Chris, who voiced MC Pee Pants in Aqua Teen Hunger force. I'm not saying that this was the inspiration for the name of this project, but I'm also not denying it.
MCPymol acts as a bridge between an AI assistant and a running PyMOL desktop instance. It provides:
- 50+ Auto-Generated PyMOL Commands: Claude has direct access to PyMOL primitives like
show,hide,color,distance,get_chains,select, and many more. - Smart Multimer & Solvent Heuristics: When fetching or loading structures, MCPymol automatically attempts to fetch the biological assembly (the functional multimer) and applies an iterative Breadth-First Search (BFS) style heuristic to isolate the primary multimer. Starting with the first chain, it recursively adds all neighboring chains within a customizable radius (default 5.0Å) until the selection stabilizes. This ensures that large circular or sprawling assemblies like the CRP pentamer or Ferritin cage are kept whole, while removing distant crystallographic copies from the unit cell. It also automatically hides waters, solvents, and non-standard crystallization additives for a clean, relevant view.
- Dual-Process Architecture: To circumvent PyMOL's internal Python dependency limitations, MCPymol runs via a two-part bridge. A native PyMOL script runs a lightweight background socket listener inside your PyMOL App, while a standalone FastMCP server handles communication with the AI assistant.
MCPymol is designed for structural biologists, bioinformaticians, and anyone interested in protein structures who wants a natural language conversational partner for PyMOL. You can ask Claude to:
- "Fetch ubiquitin (1ubq) and show it as a cartoon."
- "Color the alpha helices red and the beta sheets blue."
- "Measure the distance between residue 10 and residue 20."
- "Highlight the active site."
Because PyMOL requires its own isolated Python environment to run its GUI and rendering loops, using MCPymol requires starting both the PyMOL plugin and configuring the external MCP server for your AI assistant.
- Open your standard PyMOL desktop application.
- In the PyMOL command line, manually initialize the background listener script. Adjust the path to where you cloned the repository:
You should see a message in the PyMOL console indicating the plugin is listening on
run /path/to/MCPymol/src/mcpymol/plugin.py127.0.0.1:9876.
💡 Pro Tip: Auto-Start the Plugin
The standard way to run initialization scripts in PyMOL is through its pymolrc resource file. To automatically run this plugin every time you launch PyMOL, add the following to ~/.pymolrc.py:
import os, pymol
pymol.cmd.do("run /absolute/path/to/MCPymol/src/mcpymol/plugin.py")🔌 Changing the Port
The default port is 9876. If you need to run multiple MCP servers simultaneously, override it with the MCPYMOL_PORT environment variable before launching PyMOL and the bridge:
# PyMOL (macOS example)
MCPYMOL_PORT=9867 open -a PyMOL
# MCP bridge/server
MCPYMOL_PORT=9867 uv run mcpymolChoose ONE of the following three setups based on your environment and preferred AI assistant. All instructions assume you have cloned the repository to your machine.
git clone https://github.com/yourusername/MCPymol.git
cd MCPymolThis is the standard, unrestricted setup for Claude users using uv for dependency management.
- Install dependencies:
uv sync
- Configure Claude Desktop: Add the following to your
claude_desktop_config.jsonfile:{ "mcpServers": { "mcpymol": { "command": "uv", "args": [ "--directory", "/absolute/path/to/MCPymol", "run", "mcpymol" ] } } } - Restart Claude Desktop. Ensure the PyMOL plugin is running, and you're ready to start asking conversational questions about protein structures!
This is the standard, unrestricted setup for Gemini CLI users using uv.
- Install dependencies:
uv sync
- Configure Gemini CLI: Run the following commands in your terminal:
gemini mcp add mcpymol uv --directory /absolute/path/to/MCPymol run mcpymol gemini mcp refresh
If you are running on a managed machine where tools like uv are restricted or blocked by security policies, you must use a standard Python virtual environment instead. If you're working in an environment where package repos are managed, you might have to tweak some of the addresses in the uv.lock to work with your organization's rules.
- Create and activate a virtual environment using a modern Python version (3.10+):
(Note: macOS users may need to specify a newer python binary like
python3 -m venv .venv source .venv/bin/activatepython3.11if the system default is older than 3.10). - Install the package: Upgrade
pipto support pyproject.toml installs, then install natively from within.venv:pip install --upgrade pip pip install -e . - Configure Gemini CLI: Add the server to Gemini CLI, pointing directly to the generated script inside the virtual environment:
(Note: If configuring Claude Code in a restricted environment, ensure the
gemini mcp add mcpymol /absolute/path/to/MCPymol/.venv/bin/mcpymol
claude_desktop_config.jsoncommandpoints to the.venv/bin/pythonexecutable and uses arguments["-m", "mcpymol"]).
If you are running on a managed Linux workstation where standard python environments are strictly managed, you will need to create a venv to bypass those restrictions. If you're working in an environment where package repos are managed, you might have to tweak some of the addresses in the uv.lock to work with your organization's rules.
- Verify your PyMOL installation: Ensure you have PyMOL installed and accessible via your GUI.
sudo apt-get install pymol
- Create and activate a virtual environment:
(Note: If you get an error that the
cd MCPymol python3 -m venv .venv source .venv/bin/activate
venvmodule is missing on Debian/gLinux, you may need to runsudo apt-get install python3-venvfirst). - Install the package dependencies natively into the virtual environment:
pip install --upgrade pip pip install -e . - Configure Gemini CLI: Add the server to Gemini CLI, pointing directly to the generated script inside the virtual environment:
(Note: Ensure that you've run the
gemini mcp add mcpymol /absolute/path/to/MCPymol/.venv/bin/mcpymol
plugin.pynative script inside your PyMOL GUI window as instructed in Step 1 before testing the server).
The repository includes a rigorous, "Google Engineer" grade pytest suite testing both the socket payload generation and simulated PyMOL API execution boundaries.
To run the automated tests:
PYTHONPATH=src uv run pytest tests/MCPymol includes a set of high-level visualization tools that go beyond raw PyMOL commands. Each view is designed for a specific analytical task and can be invoked with a single natural language request.
Demo: cAMP-dependent protein kinase (1ATP) with ATP
Shows the binding pocket around a ligand: pocket residues as element-colored sticks with labeled CA atoms, ligand as yellow sticks, H-bonds as yellow dashes, and the protein as a semi-transparent cartoon.
Show me the ATP binding site in 1ATP
Demo: Barnase–barstar complex (1BRS), chains A and D
Colors chain A marine blue and chain B salmon. Interface residues (within 4Å of the partner) are shown as solid surface patches with sidechain sticks and CA labels. Cross-chain H-bonds drawn as yellow dashes.
Show the interface between chain A and chain D in 1BRS
Demo: Ubiquitin (1UBQ)
Tube radius and color scale with B-factor: blue = rigid/ordered, red = flexible/disordered. A 70%-transparent surface provides shape context.
Show the B-factor flexibility of 1UBQ as a putty view
Demo: Candida antarctica Lipase B (CalB, 1TCA)
Colors the molecular surface by amino acid chemical character: orange = hydrophobic, white = polar, skyblue = positive, salmon = negative. Useful for identifying hydrophobic patches, membrane-interacting belts, and charge complementarity. CalB is widely used by synthetic chemists for enantioselective transesterifications.
Show the hydrophobic surface of 1TCA
Demo: Hen egg-white lysozyme (1LYZ)
Colors the molecular surface by residue-level electrostatic character using pKa-weighted partial charges: red = negative, white = neutral, blue = positive. Fast approximation — no external tools required.
Show the electrostatic surface of 1LYZ
Demo: Hen egg-white lysozyme (1LYZ)
Computes a full Poisson-Boltzmann electrostatic potential using APBS and PDB2PQR, mapped onto the molecular surface at ±20 kT/e. Produces physically accurate charge distributions accounting for solvent screening and ionic strength.
Prerequisites: both tools must be installed and on your
PATHbefore using this view.# APBS (macOS via Homebrew) brew install brewsci/bio/apbs # PDB2PQR (via pip) pip install pdb2pqr
Run a Poisson-Boltzmann electrostatics calculation on 1LYZ
Demo: Cellulase (1CEL)
Highlights structural crosslinks: CYS sidechains and disulfide bonds in yellow, metal coordination bonds in orange. The rest of the protein is shown as a thin grey cartoon.
Show the disulfide bonds in 1CEL
Demo: HIV-1 protease with inhibitor MK1 (1HSG)
Shows the binding cavity as a surface colored by chemical character: orange = hydrophobic, white = polar, skyblue = positive, salmon = negative. Pocket sidechain sticks are shown with CA labels. Ligand rendered as yellow sticks. H-bonds between ligand and pocket drawn as cyan dashes.
Show the binding pocket around MK1 in 1HSG
Demo: HIV-1 protease with inhibitor MK1 (1HSG)
Colors the ligand by pharmacophore feature type: violet = ring/aromatic carbon, yellow = aliphatic carbon, skyblue = nitrogen (H-bond donor/acceptor), salmon = oxygen (H-bond acceptor), gold = sulfur, palegreen = halogen. Interacting residue sidechains shown as element-colored sticks with CA labels. H-bonds to protein shown as cyan dashes.
Show the pharmacophore features of MK1 in 1HSG
Demo: Human hemoglobin (4HHB) with sickle cell and related mutations E6V, K16E, V67F
Renders the protein as a grey cartoon. Mutated residue sidechains are shown as magenta sticks with white CA labels. Nearby residues (within 4Å) are shown as thin element-colored sticks for packing context. Accepts standard mutation notation (e.g. A123G).
Highlight mutations E6V, K16E, and V67F in hemoglobin (4HHB)










