How vrtejus/pymol-mcp works
Project Type and Purpose
• This is an open‑source integration tool (a plugin + server) that bridges PyMOL and Claude AI.
High‑Level Architecture and Main Components
a. Claude Desktop (MCP client)
b. MCP Server Script (pymol_mcp_server.py running in your venv)
c. Socket Channel (TCP port 9876)
d. PyMOL Socket Plugin (pymol‑mcp‑socket‑plugin folder)
– UI definition (pymol_mcp_plugin.ui)
– Plugin entry point (__init__.py)
e. PyMOL Application (core)
f. Python Virtual Environment & Dependencies (mcp library, Python 3.10+)
Relationships and Data Flow
1. User types a query in Claude Desktop →
2. Claude’s MCP client spawns/uses pymol_mcp_server.py →
3. Server script establishes a socket client connection to the PyMOL plugin (listening on port 9876) →
5. PyMOL executes the commands and returns outputs (success/failure, images, measurement values) →
6. Plugin sends responses back over the socket →
7. pymol_mcp_server.py forwards MCP responses back to Claude Desktop →
8. Claude displays results to the user.
Architectural Patterns and Design Principles
• Plugin‑based extensibility in PyMOL (Qt UI + Python hook)
• Socket‑based IPC (decouples server logic from PyMOL process)
• Model‑Context Protocol (MCP) for standardizing message format between Claude and the Python server
• Separation of concerns:
– UI layer (plugin)
– Server layer (command parsing, MCP handling)
– Domain layer (PyMOL API calls)
Key Technologies and Frameworks
• PyMOL (molecular visualization)
• Python 3.10+
• mcp Python package (MCP protocol implementation)
• uv (package manager, locked in uv.lock)
• Qt (via pymol_mcp_plugin.ui)
– Claude Desktop (MCP client)
– pymol_mcp_server.py (MCP server, command parser)
– Socket (port 9876)
– pymol‑mcp‑socket‑plugin:
• pymol_mcp_plugin.ui (UI layout)
• __init__.py (plugin logic)
– PyMOL application (API runtime)
– Python Virtual Environment & mcp dependency