Skip to main content
Glama
HeshamFS

MCP Materials Server

by HeshamFS

compare_materials

Compare properties of multiple materials side by side to analyze differences and make informed material selection decisions.

Instructions

Compare properties of multiple materials side by side. Args: material_ids: List of Materials Project IDs (e.g., ["mp-149", "mp-66"]) Returns: JSON table comparing key properties across materials

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
material_idsYes

Implementation Reference

  • The main handler function for the 'compare_materials' tool, decorated with @mcp.tool() for automatic registration. Compares properties of multiple materials from Materials Project API.
    @mcp.tool() def compare_materials( material_ids: list[str], ) -> str: """ Compare properties of multiple materials side by side. Args: material_ids: List of Materials Project IDs (e.g., ["mp-149", "mp-66"]) Returns: JSON table comparing key properties across materials """ has_key, key_or_error = check_api_key() if not has_key: return json.dumps({"error": key_or_error}) try: from mp_api.client import MPRester comparison = [] with MPRester(key_or_error) as mpr: for mid in material_ids: try: doc = mpr.materials.summary.get_data_by_id(mid) crystal_system = None if doc.symmetry and doc.symmetry.crystal_system: crystal_system = str(doc.symmetry.crystal_system.value) if hasattr(doc.symmetry.crystal_system, 'value') else str(doc.symmetry.crystal_system) comparison.append({ "material_id": str(doc.material_id), "formula": doc.formula_pretty, "band_gap_eV": doc.band_gap, "formation_energy_eV": doc.formation_energy_per_atom, "energy_above_hull_eV": doc.energy_above_hull, "density_g_cm3": doc.density, "is_stable": doc.is_stable, "is_metal": doc.is_metal, "crystal_system": crystal_system, }) except Exception as e: comparison.append({ "material_id": mid, "error": str(e), }) return json.dumps({ "count": len(comparison), "comparison": comparison, }, indent=2) except Exception as e: return json.dumps({"error": str(e)})

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HeshamFS/mcp-materials-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server