Skip to main content
Glama

Materials Project MCP

by fair2wise
BSD 3-Clause
1

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 .

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
Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

A tool for querying and analyzing materials data from the Materials Project database using natural language prompts, enabling materials scientists to explore properties, structures, and compositions of materials through conversational interfaces.

  1. Installation
    1. Usage
      1. API Key Setup
        1. Example
          1. Development
            1. Local Setup
            2. Running Tests

          Related MCP Servers

          • A
            security
            F
            license
            A
            quality
            Enables interaction with the Metal Framework by providing documentation search and code generation capabilities using natural language queries.
            Last updated -
            2
            2
            TypeScript
          • A
            security
            F
            license
            A
            quality
            Enables querying WolframAlpha's LLM API for natural language questions, providing structured and simplified answers optimized for LLM consumption.
            Last updated -
            3
            25
            TypeScript
          • A
            security
            A
            license
            A
            quality
            Enables extracting data from websites using natural language prompts, allowing users to specify exactly what content they want in plain English and returning structured JSON data.
            Last updated -
            1
            1,379
            4
            TypeScript
            MIT License
            • Apple
            • Linux
          • -
            security
            F
            license
            -
            quality
            Enables querying log data stored in SQLite databases through the Model Context Protocol, allowing natural language interactions with log analysis.
            Last updated -
            Python

          View all related MCP servers

          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