-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathpymol_server.py
More file actions
37 lines (29 loc) · 904 Bytes
/
pymol_server.py
File metadata and controls
37 lines (29 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# server.py
from mcp.server.fastmcp import FastMCP, Image
from PIL import Image as PILImage
import chatmol as cm
# Create an MCP server
mcp = FastMCP("Pymol")
defaul_client = cm.ChatMol()
pymolserver = cm.PymolServer(defaul_client)
@mcp.tool()
def open_pymol():
"""open pymol"""
pymolserver.start_pymol()
return "Pymol opened"
@mcp.tool()
def run_pymol_command(command: str):
"""run pymol command"""
pymolserver.server.do(command)
return "Command executed"
@mcp.tool()
def save_imgae(file_path: str):
"""save current view of pymol session to a file, perferably .png"""
pymolserver.server.do(f"zoom; png ~/{file_path}, dpi=75")
return f"File saved at ~/{file_path}"
# return file_path
# Add a dynamic greeting resource
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
"""Get a personalized greeting"""
return f"Hello, {name}!"