Skip to main content
Glama
fair2wise

Materials Project MCP

by fair2wise

get_material_details

Retrieve comprehensive material details using the Materials Project ID to access properties, structures, and compositions for research or analysis purposes.

Instructions

Get detailed information about a specific material by its Materials Project ID.

Args:
    material_id: The Materials Project ID (e.g., "mp-149").

Returns:
    Dictionary containing detailed information about the material.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
material_idYes

Implementation Reference

  • The core handler function 'get_material_details' that executes the tool logic: fetches material data via API wrapper and formats key properties into a structured dictionary.
    def get_material_details(material_id: str) -> Dict[str, Any]:
        """
        Get detailed information about a specific material by its Materials Project ID.
        
        Args:
            material_id: The Materials Project ID (e.g., "mp-149").
        
        Returns:
            Dictionary containing detailed information about the material.
        """
        properties = [
            "material_id", 
            "formula_pretty",
            "symmetry", 
            "formation_energy_per_atom",
            "band_gap",
            "density",
            "is_stable",
            "energy_above_hull",
            "theoretical",
            "nelements",
            "elements",
            "nsites",
            "volume",
            "deprecated",
            "deprecation_reasons"
        ]
        
        material = fetch_material_by_id(
            material_id=material_id,
            properties=properties
        )
        
        # Format the output to make it more readable
        result = {
            "material_id": material.get("material_id"),
            "formula": material.get("formula_pretty"),
            "elements": material.get("elements"),
            "number_of_elements": material.get("nelements"),
            "number_of_sites": material.get("nsites"),
            "volume": material.get("volume"),
            "density": material.get("density"),
            "band_gap": material.get("band_gap"),
            "formation_energy": material.get("formation_energy_per_atom"),
            "energy_above_hull": material.get("energy_above_hull"),
            "is_stable": material.get("is_stable", False),
            "is_theoretical": material.get("theoretical", True),
            "crystal_system": material.get("symmetry", {}).get("crystal_system"),
            "space_group": material.get("symmetry", {}).get("symbol"),
            "point_group": material.get("symmetry", {}).get("point_group"),
            "deprecated": material.get("deprecated", False),
            "deprecation_reasons": material.get("deprecation_reasons", [])
        }
        
        return result
  • Registers the 'get_material_details' tool (along with others) with the FastMCP server instance.
    mcp.tool(get_materials_with_elements)
    mcp.tool(get_material_details)
    mcp.tool(find_materials_by_formula)
  • Supporting API wrapper 'fetch_material_by_id' that queries the Materials Project MPRester client and retrieves raw material data, invoked by the handler.
    def fetch_material_by_id(
        material_id: str,
        properties: Optional[List[str]] = None,
    ) -> Dict[str, Any]:
        """
        Fetch a specific material by its Materials Project ID.
        
        Args:
            material_id: The Materials Project ID (e.g., "mp-149").
            properties: Optional list of properties to include in the results.
        
        Returns:
            Dictionary containing the material data.
        """
        if properties is None:
            properties = [
                "material_id", 
                "formula_pretty",
                "symmetry", 
                "formation_energy_per_atom",
                "band_gap",
                "theoretical",
                "density",
                "is_stable",
                "energy_above_hull",
                "elements",
                "nelements",
                "nsites",
                "volume"
            ]
        
        with get_mp_client() as mpr:
            # Search by material_id
            docs = mpr.materials.summary.search(
                material_ids=[material_id],
                fields=properties
            )
            
            if not docs:
                return {"error": f"Material {material_id} not found"}
            
            # Convert to dictionary
            material_dict = docs[0].dict()
            
        return material_dict

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related Tools

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/fair2wise/materials_project_mcp'

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