Skip to main content
Glama
Materials Project MCP

Materials Project MCP

by fair2wise

Materials Project MCP

A fastmcp-based tool for writing prompts against data in the Materials Project database.

Installation

You can install the package from source:

pip install -e .

Or using uv:

uv pip install -e .

Related MCP server: MCP Materials Server

Usage

You can use the CLI:

mp-mcp

Or import in your Python code:

from materials_project_mcp.main import create_mcp

mcp = create_mcp()
mcp.run()

API Key Setup

The Materials Project API requires an API key. You can set up your API key in several ways:

  1. Pass it directly to the MPRester:

    from mp_api.client import MPRester
    with MPRester("your_api_key_here") as mpr:
        # do stuff with mpr
  2. Set it as an environment variable:

    export MP_API_KEY="your_api_key_here"

Example

Here's a simple example that demonstrates how to use the MCP tools directly:

import os
import json
from materials_project_mcp.tools import (
    get_materials_with_elements,
    get_material_details,
    find_materials_by_formula
)

# Set your API key
os.environ["MP_API_KEY"] = "your_api_key_here"
# Or load it from a file
# with open("~/materials_project_api.key", "r") as f:
#     os.environ["MP_API_KEY"] = f.read().strip()

# Function to print JSON data in a readable format
def print_json(data):
    print(json.dumps(data, indent=2))

# Find materials containing Fe and O
print("\n=== Finding materials containing Fe and O ===")
materials = get_materials_with_elements(
    elements=["Fe", "O"],
    max_records=3
)
print_json(materials)

# Get details for a specific material
if materials:
    material_id = materials[0]["material_id"]
    print(f"\n=== Getting details for material {material_id} ===")
    details = get_material_details(material_id)
    print_json(details)

# Find materials with a specific formula
print("\n=== Finding materials with formula Fe2O3 ===")
formula_materials = find_materials_by_formula(
    formula="Fe2O3",
    max_records=3
)
print_json(formula_materials)

Development

Local Setup

# Clone the repository
git clone https://github.com/justaddcoffee/materials-project-mcp.git
cd materials-project-mcp

# Install development dependencies
uv pip install -e ".[dev]"

Running Tests

pytest

Available Tools

3 tools
find_materials_by_formulaB
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.

Inputs: formula (required), max_records.

get_material_detailsA
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.

Inputs: material_id (required).

get_materials_with_elementsB
Find materials containing specific elements.

Args:
    elements: List of elements that must be present in the material (e.g., ["Fe", "O"]).
    exclude_elements: Optional list of elements that must not be present.
    max_records: Maximum number of records to return (default: 10).

Returns:
    List of materials containing the specified elements.

Inputs: elements (required), exclude_elements, max_records.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: find_materials_by_formula searches by chemical formula, get_material_details retrieves detailed information by ID, and get_materials_with_elements searches by element composition. There is no overlap in functionality, making tool selection unambiguous for an agent.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case (e.g., find_materials_by_formula, get_material_details, get_materials_with_elements). The naming is predictable and readable throughout the set.

    Tool Count3/5

    With only 3 tools, the set feels thin for a materials science domain, which might involve more operations like filtering by properties, comparing materials, or updating data. While the tools cover basic search and retrieval, the count is borderline for comprehensive coverage.

    Completeness3/5

    The tools provide essential search and retrieval functions (by formula, ID, and elements), but there are notable gaps. For a materials database, operations like filtering by material properties (e.g., band gap, stability), sorting, or pagination are missing, which could limit agent workflows in more complex tasks.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      The Materials Project MCP Server is server that provides programmatic access to the Materials Project database. It enables LLMs, to search, analyze, and retrieve up to date materials science data.
      13
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides AI assistants with access to materials science databases, enabling search and analysis of material properties, crystal structures, phase diagrams, and elastic properties through the Materials Project API.
      10
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables natural language querying of OPTIMADE-compatible material databases like Materials Project and Materials Cloud via the Model Context Protocol. It provides tools for linting query filters, discovering database providers, and accessing full structured data results as MCP resources.
      4
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides computed (DFT) materials structures and thermodynamic properties through the Pipeworx MCP gateway, enabling AI agents to query materials data via natural language or tool calls.
      284 npm
      MIT