Query materials databases for structures and properties. Use when asked to get crystal structures, material properties, phase diagrams, or thermodynamic data. Primary source is Materials Project, with NIST, PubChem as secondary.
npx playbooks add skill fl-sean03/agentic-science-worker --skill materials-database
You are querying materials databases for structures and properties.
import os
from mp_api.client import MPRester
# Initialize with API key from environment
api_key = os.environ.get("MP_API_KEY")
with MPRester(api_key) as mpr:
# Get structure by formula
docs = mpr.materials.summary.search(formula="TiO2")
# Get by material ID
structure = mpr.get_structure_by_material_id("mp-2657")
# Search with properties
results = mpr.materials.summary.search(
band_gap=(1.0, 2.0),
is_stable=True
)
# Search for materials
curl -H "X-API-KEY: YOUR_KEY" \
"https://api.materialsproject.org/materials/summary/?formula=Fe2O3"
# Get specific material
curl -H "X-API-KEY: YOUR_KEY" \
"https://api.materialsproject.org/materials/mp-19770/"
Standard format for crystal structures:
data_TiO2
_cell_length_a 4.5937
_cell_length_b 4.5937
_cell_length_c 2.9587
_cell_angle_alpha 90.000
_cell_angle_beta 90.000
_cell_angle_gamma 90.000
_symmetry_space_group_name_H-M 'P 42/m n m'
...
TiO2 rutile
1.0
4.5937 0.0000 0.0000
0.0000 4.5937 0.0000
0.0000 0.0000 2.9587
Ti O
2 4
Direct
0.0000 0.0000 0.0000
0.5000 0.5000 0.5000
...
Simple atomic coordinates:
6
TiO2 unit cell
Ti 0.000 0.000 0.000
Ti 2.297 2.297 1.479
O 1.396 1.396 0.000
...
from ase.io import read, write
# Read CIF, write POSCAR
atoms = read('structure.cif')
write('POSCAR', atoms, format='vasp')
# Read CIF, write LAMMPS data
write('structure.data', atoms, format='lammps-data')
from pymatgen.core import Structure
from pymatgen.io.lammps.data import LammpsData
# Read CIF
struct = Structure.from_file('structure.cif')
# Write LAMMPS data file
lammps_data = LammpsData.from_structure(struct)
lammps_data.write_file('structure.data')
Save database queries to:
workspaces/project-name/
├── structures/
│ ├── mp-19770_Fe2O3.cif
│ ├── mp-19770_Fe2O3.vasp
│ └── mp-19770_Fe2O3.data
├── properties/
│ └── Fe2O3_properties.json
└── README.md # Document sources
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.