Skip to main content
Glama
fair2wise

Materials Project MCP

by fair2wise

find_materials_by_formula

Search for materials in the Materials Project database by entering a specific chemical formula. Returns a list of matching materials to aid in materials research and discovery.

Instructions

Find materials with a specific chemical formula.

Args:
    formula: Chemical formula to search for (e.g., "Fe2O3").
    max_records: Maximum number of records to return (default: 10).

Returns:
    List of materials matching the specified formula.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formulaYes
max_recordsNo

Implementation Reference

  • The handler function implementing the 'find_materials_by_formula' tool. It calls the underlying API wrapper and simplifies the results for the tool response.
    def find_materials_by_formula(
        formula: str,
        max_records: int = 10
    ) -> List[Dict[str, Any]]:
        """
        Find materials with a specific chemical formula.
        
        Args:
            formula: Chemical formula to search for (e.g., "Fe2O3").
            max_records: Maximum number of records to return (default: 10).
        
        Returns:
            List of materials matching the specified formula.
        """
        properties = [
            "material_id", 
            "formula_pretty",
            "symmetry", 
            "formation_energy_per_atom",
            "band_gap",
            "density",
            "is_stable"
        ]
        
        materials = fetch_materials_by_formula(
            formula=formula,
            max_records=max_records,
            properties=properties
        )
        
        # Extract key properties for each material
        simplified_results = []
        for material in materials:
            simplified_material = {
                "material_id": material.get("material_id"),
                "formula": material.get("formula_pretty"),
                "band_gap": material.get("band_gap"),
                "formation_energy": material.get("formation_energy_per_atom"),
                "crystal_system": material.get("symmetry", {}).get("crystal_system"),
                "space_group": material.get("symmetry", {}).get("symbol"),
                "density": material.get("density"),
                "is_stable": material.get("is_stable", False)
            }
            simplified_results.append(simplified_material)
        
        return simplified_results
  • Registers the 'find_materials_by_formula' tool with the FastMCP instance.
    mcp.tool(find_materials_by_formula)
  • Underlying API helper function that performs the actual Materials Project API search for materials by formula.
    def fetch_materials_by_formula(
        formula: str,
        max_records: int = 10,
        properties: Optional[List[str]] = None,
    ) -> List[Dict[str, Any]]:
        """
        Fetch materials matching a specific formula from the Materials Project API.
        
        Args:
            formula: Chemical formula to search for (e.g., "Fe2O3").
            max_records: Maximum number of records to return (default: 10).
            properties: Optional list of properties to include in the results.
        
        Returns:
            List of materials data dictionaries.
        """
        if properties is None:
            properties = [
                "material_id", 
                "formula_pretty",
                "symmetry", 
                "formation_energy_per_atom",
                "band_gap",
                "theoretical",
                "density",
                "is_stable"
            ]
        
        with get_mp_client() as mpr:
            # Search by formula
            results = mpr.materials.summary.search(
                formula=formula,
                fields=properties
            )
            
            # Limit the number of results and convert to dictionaries
            materials = [doc.dict() for doc in results[:max_records]]
            
        return materials
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool returns a list of materials but lacks details on permissions, rate limits, error handling, or whether the search is exact or fuzzy. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with the purpose, followed by clear sections for Args and Returns. Every sentence earns its place, with no redundant information, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and parameters but lacks behavioral details and usage guidelines. Without annotations or output schema, more context on return format or errors would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context beyond the input schema, which has 0% description coverage. It explains that 'formula' is a chemical formula with an example ('Fe2O3') and clarifies 'max_records' as the maximum number to return with a default value. This compensates well for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Find materials with a specific chemical formula.' It specifies the verb ('Find') and resource ('materials'), making the action explicit. However, it doesn't differentiate from sibling tools like 'get_materials_with_elements' which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'get_materials_with_elements' or 'get_material_details.' The description only states what the tool does without indicating appropriate contexts, prerequisites, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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