Model Context Protocol (MCP) server for Crystal Structure Prediction, enabling AI assistants to generate crystal structures.
Note: Ensure that the LLM has the ability to follow instructions and give correct parameters for the tools.
python -m pip install fastmcp pandas python-dotenvCreate or edit ~/.cursor/mcp.json or ~/claude_desktop_config.json with the following configuration:
{
"mcpServers": {
"csp_mcp": {
"command": "python",
"args": ["/path/to/crystalformer/mcp/csp_mcp.py"],
}
}
}Edit the .env file with the following variables:
RESTORE_PATH=/path/to/model/checkpoint
MODEL_PATH=/path/to/mlff_model.ckpt
CONVEX_HULL_PATH=/path/to/convex_hull_pbe.json.bz2
SAVE_PATH=/path/to/output
Main tool for generating crystal structures with complete postprocessing pipeline.
Key Parameters:
formula(required): Chemical formula (e.g., 'H2O', 'TiO2')
Returns:
success: bool, True if the structure generation was successfuloutput: stdout/stderr from the postprocess.sh scriptformula: the chemical formula used for the structure generationoutput_path: the path to the output directorybest_cif: dictionary containing the best CIF structure and metadataerror: error message if the structure generation failed
After setting up the MCP server, you can use the following prompt in your LLM interface:
Generate H2O crystal structures
To add new tools or modify existing ones:
- Add the tool function with proper
@mcp.tooldecorator - Use
Annotatedtypes for parameter descriptions - Ensure the tool returns LLM-friendly output (paths and summaries)
- Test the tool with the MCP server
- Update this README with the new tool documentation