Skip to main content
Glama
HeshamFS

MCP Materials Server

by HeshamFS

search_by_elastic_properties

Find materials by specifying bulk and shear modulus ranges to identify substances with desired mechanical properties for engineering applications.

Instructions

Search for materials by elastic/mechanical properties.

Args:
    min_bulk_modulus: Minimum bulk modulus in GPa
    max_bulk_modulus: Maximum bulk modulus in GPa
    min_shear_modulus: Minimum shear modulus in GPa
    max_shear_modulus: Maximum shear modulus in GPa
    max_results: Maximum number of results (default: 10)

Returns:
    JSON with materials matching the elastic property criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
min_bulk_modulusNo
max_bulk_modulusNo
min_shear_modulusNo
max_shear_modulusNo
max_resultsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'search_by_elastic_properties' tool. Decorated with @mcp.tool() for automatic registration and schema inference from type hints and docstring. Implements search on Materials Project elasticity data using bulk and shear modulus ranges.
    @mcp.tool()
    def search_by_elastic_properties(
        min_bulk_modulus: float | None = None,
        max_bulk_modulus: float | None = None,
        min_shear_modulus: float | None = None,
        max_shear_modulus: float | None = None,
        max_results: int = 10,
    ) -> str:
        """
        Search for materials by elastic/mechanical properties.
    
        Args:
            min_bulk_modulus: Minimum bulk modulus in GPa
            max_bulk_modulus: Maximum bulk modulus in GPa
            min_shear_modulus: Minimum shear modulus in GPa
            max_shear_modulus: Maximum shear modulus in GPa
            max_results: Maximum number of results (default: 10)
    
        Returns:
            JSON with materials matching the elastic property criteria
        """
        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
    
            with MPRester(key_or_error) as mpr:
                search_kwargs: dict[str, Any] = {
                    "num_chunks": 1,
                    "chunk_size": max_results * 2,
                }
    
                # Add bulk modulus filter
                if min_bulk_modulus is not None or max_bulk_modulus is not None:
                    bulk_range = (
                        min_bulk_modulus if min_bulk_modulus else 0,
                        max_bulk_modulus if max_bulk_modulus else 1000,
                    )
                    search_kwargs["bulk_modulus"] = bulk_range
    
                # Add shear modulus filter
                if min_shear_modulus is not None or max_shear_modulus is not None:
                    shear_range = (
                        min_shear_modulus if min_shear_modulus else 0,
                        max_shear_modulus if max_shear_modulus else 1000,
                    )
                    search_kwargs["shear_modulus"] = shear_range
    
                docs = mpr.materials.elasticity.search(**search_kwargs)
    
                results = []
                for doc in docs[:max_results]:
                    results.append({
                        "material_id": str(doc.material_id),
                        "formula": doc.formula_pretty if hasattr(doc, 'formula_pretty') else None,
                        "bulk_modulus_GPa": doc.bulk_modulus.vrh if doc.bulk_modulus else None,
                        "shear_modulus_GPa": doc.shear_modulus.vrh if doc.shear_modulus else None,
                        "universal_anisotropy": doc.universal_anisotropy if hasattr(doc, 'universal_anisotropy') else None,
                    })
    
                return json.dumps({
                    "query": {
                        "bulk_modulus_range_GPa": [min_bulk_modulus, max_bulk_modulus],
                        "shear_modulus_range_GPa": [min_shear_modulus, max_shear_modulus],
                    },
                    "count": len(results),
                    "materials": results,
                }, indent=2)
    
        except Exception as e:
            return json.dumps({"error": str(e)})
  • Initialization of the FastMCP server instance where all @mcp.tool() decorated functions are automatically registered as tools.
    mcp = FastMCP("materials-science")
  • Input schema defined by function parameters with type hints (float | None, int) and comprehensive docstring describing arguments and return format (JSON). Output is standardized JSON with query summary and results.
    def search_by_elastic_properties(
        min_bulk_modulus: float | None = None,
        max_bulk_modulus: float | None = None,
        min_shear_modulus: float | None = None,
        max_shear_modulus: float | None = None,
        max_results: int = 10,
    ) -> str:
        """
        Search for materials by elastic/mechanical properties.
    
        Args:
            min_bulk_modulus: Minimum bulk modulus in GPa
            max_bulk_modulus: Maximum bulk modulus in GPa
            min_shear_modulus: Minimum shear modulus in GPa
            max_shear_modulus: Maximum shear modulus in GPa
            max_results: Maximum number of results (default: 10)
    
        Returns:
            JSON with materials matching the elastic property criteria
        """
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 JSON with matching materials, which is helpful, but doesn't describe important behaviors like pagination (only mentions max_results default), error conditions, rate limits, authentication requirements, or whether this is a read-only operation. The description is minimal beyond basic functionality.

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 perfectly structured and concise. It starts with a clear purpose statement, then provides a well-organized 'Args' section with bullet-point explanations, followed by a 'Returns' section. Every sentence earns its place with no wasted words or redundancy.

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 has 5 parameters with 0% schema description coverage but an output schema exists, the description does a good job explaining parameters but is incomplete behaviorally. It adequately covers the search functionality and parameters but lacks context about when to use it versus siblings, behavioral constraints, and doesn't need to explain return values since an output schema exists.

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 provides excellent parameter semantics despite 0% schema description coverage. It clearly explains what each parameter represents (minimum/maximum bulk/shear modulus in GPa, maximum results with default), adding crucial meaning beyond the schema's generic titles. This fully compensates for the lack of schema descriptions, though it doesn't explain the nullability indicated in the schema.

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 searches for materials by elastic/mechanical properties, providing a specific verb ('search') and resource ('materials'). It distinguishes from some siblings like 'get_elastic_properties' (which likely retrieves properties for specific materials) but doesn't explicitly differentiate from other search tools like 'search_by_band_gap' or 'search_by_elements'.

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 about when to use this tool versus alternatives. While the purpose implies it's for searching by elastic properties, there's no mention of when to choose this over other search tools (like 'search_by_band_gap' or 'search_by_elements') or when to use it versus 'get_elastic_properties' (which might retrieve properties for known materials).

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

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