# MolAgent
**Repository Path**: chenwenlong1233/MolAgent
## Basic Information
- **Project Name**: MolAgent
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: GPL-3.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-02-01
- **Last Updated**: 2026-02-01
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# MolAgent
automol_model_server.py
Main Modeling Engine
- Regression & Classification
- Feature selection
- Model Selection & Validation
automol_data_server.py
Data retrieval & preprocessing
- TDC Integration
- 3D Structure Processing
ML Pipeline
Robust predictive modelling
- Nested Cross-Validation
- Ensemble Methods
- Advanced Feature Generators
AI Agents
Claude, ChatGPT, Custom Agents
- Autonomous Decision Making
- Multi-Agent Orchestration
- Dynamic Workflow Management
Table 1. Performance of MolAgent under “cheap” computational budget across ADMET tasks from the Therapeutics Data Commons (TDC) benchmark. Results are reported as mean ± standard deviation over 5 independent runs (different seeds). The “MolAgent” column denotes MolAgent’s performance, whereas “Best” corresponds to the best result achieved by existing human-fine-tuned models. “Ranking” indicates MolAgent’s position relative to all evaluated baselines in TDC leaderboard. The “Metric” column specifies the evaluation criterion: mean absolute error (MAE; lower values are better) for regression tasks, area under the receiver operating characteristic curve (AUROC; higher values are better), area under the precision-recall curve (AUPRC; higher values are better), and Spearman correlation coefficient (higher values are better). MolAgent attains competitive accuracy compared to human-fine- tuned models while operating with substantially lower computational overhead.
> 📈 **Results obtained with "cheap" computational budget** - demonstrating efficiency with competitive accuracy! --- ## 🚀 Quick Start ### Install package Throughout the README, we assume that the terminal commands start from the root directory of the repository. #### Linux To use MolAgent, include the git submodule of AutoMol by cloning the repository with submodules ```bash git clone --recurse-submodules https://github.com/openanalytics/MolAgent ``` We've included an install script for your convenience ```bash chmod +x install.sh ./install.sh ``` All the required packages can also be installed directly using the following commands. For automated pdf generation [wkhtmltopdf](https://wkhtmltopdf.org/) is used. On linux install with ```bash sudo apt-get install wkhtmltopdf ``` We recommend using an uv environment for this package. The MCP server uses AutoMol which is cloned from the repository. Now, you can use the requirements file: ```bash pip install uv uv venv molagent_env --python 3.12 source molagent_env/bin/activate uv pip install -r requirements.txt uv pip install pytdc uv pip install rdkit==2024.3.5 ``` #### Windows There is an installation script for Windows, make sure to have python installed. Note that all tests and experiments were done in Linux. ```cmd install.bat ``` --- ### Starting MCP servers locally Using the molagent_env environment, you can start the servers locally, by running the following commands in different terminals. We advise to run the servers from the notebook directory, since the mcp servers will save files only starting from the directory they are run from. Start data training server locally on port 8000: ```bash source molagent_env/bin/activate cd MCP/ uv run mcp_server/automol_data_server.py ``` Start model training server locally on port 8001: ```bash source molagent_env/bin/activate cd MCP/ uv run mcp_server/automol_model_server.py ``` In the terminal of the model server, you can follow the progress of the model training. ### Adding functionality to the MCP servers The MCP model training server is based on [AutoMol](https://github.com/openanalytics/AutoMol/tree/main/), but this server does not have all the flexibility from the different AutoMol [Tutorials](https://github.com/openanalytics/AutoMol/tree/main/Tutorials). In order to adjust or add functionality supported by AutoMol but not yet present, one can easily adopt the server and the functions ([src](MCP/mcp_server/automol_model_server.py) and [automol_functions](MCP/Tools/training_tools.py)). --- ### Claude Desktop integration ```bash claude mcp add --transport sse automoldata https://localhost:8000/sse claude mcp add --transport sse automolmodelling https://localhost:8001/sse ``` --- ### Tool Inspector You can start the MCP tool inspector by running: ```bash npx @modelcontextprotocol/inspector ``` Make sure to copy the session token and set it as Proxy Session Token (under configuration) in the inspector GUI. Then set transport type as SSE with either ``` http://localhost:8001/sse ``` or ``` http://localhost:8000/sse ``` as URL. --- # Examples In this section, we show how to use the MCP servers within the SmolAgents framework or call them directly using aiohttp. ## Integration with SmolAgents The notebook [gradio](MCP/Lipophilicity_AstraZeneca.ipynb) shows the integration using SmolAgents and the gradio interface. A list of examples for the multi-agentic framework is provided in the notebook: [examples](MCP/MolAgent_multiagent.ipynb). Figure 2 Depicts the structure of the agents used in these examples, see [MCP server architecture](#primary-server-automol_model_serverpy) for more details on the different tools.
Figure 2. The Hierarchy of Agents in the examples.
To use LLMs, create a credential file .env with the following content adapted using your personal keys:
```bash
ANTHROPIC_API_KEY = xxxx
HF_TOKEN=xxxx
HF_HOME=hf_home/
TOKENIZERS_PARALLELISM=false
OPENROUTER_API_KEY = xxxx
TAVILY_API_KEY = xxx
OPENROUTER_API_BASE=https://openrouter.ai/api/v1
MODEL_ID = openrouter/meta-llama/llama-4-maverick
#MODEL_ID = openrouter/z-ai/glm-4.5
#MODEL_ID = openrouter/anthropic/claude-sonnet-4
#MODEL_ID = openrouter/anthropic/claude-3.5-haiku
#haiku directly
#MODEL_ID = claude-3-5-haiku-20241022
```
You can add any key you want in the .env file. Only in the file [GradioMolagent.py](MCP/GradioMolAgent.py), the environment variable MODEL_ID is used in a LiteLLMModel. This chatbot also uses the tavily search tool. Note that Tavily search tool has a free but limited research option.
You can run jupyter-lab within the uv environment using the following command:
```bash
uv run --with jupyter jupyter lab
```
### Gradio chatclient
After starting the MCP servers as shown, you can start a smolagents chatbot powered by Gradio ([GradioMolagent](MCP/GradioMolAgent.py)).
```bash
source molagent_env/bin/activate
cd MCP
uv run GradioMolAgent.py
```
The app is by default hosted at [http://127.0.0.1:7860
](http://127.0.0.1:7860). You can use the app from your browser.
The following gif shows how you can interact with MolAgent.

We've stopped the video after the MCP server started training a model. Note that you can see that model started training from the terminal where the model training MCP server is started. The following video shows the results after the model was trained.

In the end, we asked to created a scatterplot using the predicted values.

### Notebooks
The notebooks are located in the folder MCP/.
* The notebook [Lipophilicity_AstraZeneca](MCP/Lipophilicity_AstraZeneca.ipynb) uses the default gradio app from smolagents. The propmpt to train a model for the data set Lipophilicity_AstraZeneca from TDC is provided.
* The notebook [MolAgent_multiagent](MCP/MolAgent_multiagent.ipynb) uses MolAgent directly without a chatbot, this notebook contains multiple questions to MolAgent, including the tyrosine-protein kinase ABL1 example from the paper.
## Using FastMCP Client
You can call the tools directly using the client functionality of FastMCP. We'll show some basic examples of how to call the tools available in the MCP servers.
#### Check health of the modelling server
```python
import asyncio
from fastmcp import Client
# HTTP server
client = Client("http://127.0.0.1:8001/sse")
async def main():
async with client:
# Basic server interaction
await client.ping()
# List available operations
tools = await client.list_tools()
print(tools)
resources = await client.list_resources()
print(resources)
prompts = await client.list_prompts()
print(prompts)
# Execute operations
server_health = await client.call_tool("get_server_status")
print(server_health)
asyncio.run(main())
```
#### Regression example using CHEMBL data samples
After unzipping the archived file in the folder Data, you can train a regression model using the following code.
```python
import asyncio
from fastmcp import Client
# HTTP server
client = Client("http://127.0.0.1:8001/sse",timeout=1e10)
async def main():
async with client:
# Basic server interaction
await client.ping()
model_test = await client.call_tool("automol_regression_model",
arguments={
'data_file': '../Data/manuscript_data/ChEMBL_SMILES.csv',
'smiles_column': 'smiles',
'property': 'prop1',
'feature_keys': ['Bottleneck', 'rdkit'],
'computational_load': 'cheap',
'json_dict_file_nm': 'out.json',
})
asyncio.run(main())
```
#### Lipophilicity example from the Therapeutics Data Commons
This example first download the model using the data MCP server and next use the model MCP server to fit a predictive model.
```python
import asyncio
from fastmcp import Client
# HTTP server
data_client = Client("http://127.0.0.1:8000/sse",timeout=1e10)
model_client = Client("http://127.0.0.1:8001/sse",timeout=1e10)
async def main():
async with data_client:
# Basic server interaction
await data_client.ping()
data_return_statement = await data_client.call_tool("retrieve_tdc_data",
arguments={
'save_dir': 'tdc_data',
'dataset_name': 'Lipophilicity_AstraZeneca',
'data_dir': '.',
'file_nm': 'lipo.csv',
'group': 'ADME'
})
print(data_return_statement)
async with model_client:
# Basic server interaction
await model_client.ping()
model_return_statement = await model_client.call_tool("automol_regression_model",
arguments={
'data_file': 'lipo.csv',
'smiles_column': 'Drug',
'property': 'Y',
'feature_keys': ['Bottleneck'],
'computational_load': 'cheap',
'json_dict_file_nm': 'lipo.json',
})
print(model_return_statement)
asyncio.run(main())
```
### License
[](LICENSE) See the [LICENSE](LICENSE) file for details.
---
## References
MolAgent relies on the following open-source projects and tools:
1. [scikit-learn](https://scikit-learn.org/stable/): Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., ... & Duchesnay, É. (2011). Scikit-learn: Machine learning in Python. the Journal of machine Learning research, 12, 2825-2830.
2. [Therapeutic Data commons](https://tdcommons.ai/): Huang, K., Fu, T., Gao, W. et al. Artificial intelligence foundation for therapeutic science. Nat Chem Biol 18, 1033–1036 (2022). https://doi.org/10.1038/s41589-022-01131-2
3. [molfeat](https://molfeat.datamol.io/): Emmanuel Noutahi, Cas Wognum, Hadrien Mary, Honoré Hounwanou, Kyle M. Kovary, Desmond Gilmour, thibaultvarin-r, Jackson Burns, Julien St-Laurent, t, DomInvivo, Saurav Maheshkar, & rbyrne-momatx. (2023). datamol-io/molfeat: 0.9.4 (0.9.4). Zenodo. https://doi.org/10.5281/zenodo.8373019
4. [Pytorch](https://pytorch.org/)
5. [FastMCP](https://github.com/jlowin/fastmcp)
6. [Prolif](https://prolif.readthedocs.io/en/stable/index.html): Bouysset, C., Fiorucci, S. ProLIF: a library to encode molecular interactions as fingerprints.
J Cheminform 13, 72 (2021). https://doi.org/10.1186/s13321-021-00548-6
## Contacts
* **Developers**: Joris Tavernier and Marvin Steijaert and Gómez-Tamayo, Jose Carlos and Mazen Ahmad
* **maintainers**: joris.tavernier@openanalytics.eu, Marvin.Steijaert@openanalytics.eu