Materials Project MCP server

Provides direct access to the Materials Project database for querying crystal structures, electronic properties, phonon data, magnetic properties, and thermodynamic stability through 23 specialized tools designed for materials science research.
Back to servers
Setup instructions
Provider
Benedict Debrah
Release date
Aug 02, 2025
Stats
4 stars

The Materials Project MCP is a server that allows you to query the Materials Project database directly from AI assistants like Claude using the Model Context Protocol. It provides a convenient way to access materials science data without leaving your assistant's interface.

Installation Requirements

  • Materials Project API Key (obtain from Materials Project)
  • Docker Desktop (must be running)
  • Python 3.12+ with uv (for local installation)

Getting Your Materials Project API Key

  1. Visit Materials Project
  2. Create a free account or log in
  3. Go to your dashboard
  4. Navigate to API settings
  5. Generate or copy your API key

Installation Options

Docker Installation (Recommended)

Using Docker Run

docker pull benedict2002/materials-project-mcp
docker run --rm -i -e MP_API_KEY="your-api-key" benedict2002/materials-project-mcp

Using Docker Compose

  1. Clone the repository and navigate to the directory
  2. Create a .env file with your API key:
    echo "MP_API_KEY=your-materials-project-api-key" > .env
    
  3. Run the service:
    docker-compose up
    
    For background running:
    docker-compose up -d
    
  4. To stop the service:
    docker-compose down
    

Local Python Installation

  1. Install uv:
    curl -Ls https://astral.sh/uv/install.sh | sh
    
  2. Clone the repository and navigate to the directory
  3. Create and activate virtual environment:
    uv venv
    source .venv/bin/activate  # Linux/macOS
    # or
    .venv\Scripts\activate     # Windows
    
  4. Install dependencies:
    uv pip install -r requirements.txt
    
  5. Set your API key:
    export MP_API_KEY="your-api-key"  # Linux/macOS
    # or
    set MP_API_KEY=your-api-key       # Windows
    
  6. Run the server:
    python server.py
    

Setup with Claude Desktop

  1. Locate your Claude configuration file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Add this configuration (using Docker):

    {
      "mcpServers": {
        "Materials Project MCP": {
          "command": "docker",
          "args": [
            "run", "--rm", "-i",
            "-e", "MP_API_KEY=your-materials-project-api-key",
            "benedict2002/materials-project-mcp"
          ]
        }
      }
    }
    
  3. Replace your-materials-project-api-key with your actual API key

  4. Ensure Docker Desktop is running

  5. Restart Claude Desktop

  6. Test by asking Claude to search for materials

Setup with VS Code Copilot

  1. Open VS Code Settings (JSON) by pressing Ctrl+Shift+P or Cmd+Shift+P and searching for "Preferences: Open User Settings (JSON)"

  2. Add this configuration (using Docker):

    {
      "mcp": {
        "inputs": [],
        "servers": {
          "Materials Project MCP": {
            "command": "docker",
            "args": [
              "run", "--rm", "-i",
              "-e", "MP_API_KEY=your-api-key",
              "benedict2002/materials-project-mcp"
            ]
          }
        }
      },
      "chat.mcp.discovery.enabled": true,
      "workbench.secondarySideBar.showLabels": false
    }
    
  3. For local Python setup:

    {
      "mcp": {
        "inputs": [],
        "servers": {
          "Materials Project MCP": {
            "command": "/usr/local/bin/uv",
            "args": [
              "run",
              "--with",
              "mcp[cli],aiohttp,pydantic,mp_api,pymatgen,emmet-core",
              "/path/to/your/server.py"
            ],
            "env": {
              "MP_API_KEY": "your-api-key"
            }
          }
        }
      },
      "chat.mcp.discovery.enabled": true
    }
    
  4. Replace placeholders with your actual values

  5. Restart VS Code

  6. Test by asking about materials from the Materials Project

Available Tools & Features

  • search_materials - Search by elements, band gap range, stability
  • get_structure_by_id - Get crystal structures and lattice parameters
  • get_electronic_bandstructure - Plot electronic band structures
  • get_electronic_dos_by_id - Get electronic density of states
  • get_phonon_bandstructure - Plot phonon band structures
  • get_phonon_dos_by_id - Get phonon density of states
  • get_ion_reference_data_for_chemsys - Download aqueous ion reference data
  • get_cohesive_energy - Calculate cohesive energies
  • get_atom_reference_data - Retrieve reference energies of isolated atoms
  • get_magnetic_data_by_id - Magnetic properties and ordering
  • get_charge_density_by_id - Charge density data
  • get_dielectric_data_by_id - Dielectric constants and properties
  • get_diffraction_patterns - X-ray and neutron diffraction
  • get_xRay_absorption_spectra - XAFS, XANES, EXAFS spectra
  • get_elastic_constants - Mechanical properties
  • get_suggested_substrates - Find substrates for thin films
  • get_thermo_stability - Thermodynamic stability analysis
  • get_surface_properties - Surface energies and work functions
  • get_grain_boundaries - Computed grain boundaries
  • get_insertion_electrodes - Battery data
  • get_oxidation_states - Element oxidation states

Troubleshooting

Common Issues

  1. "Invalid API key" error:

    • Verify your API key is correct
    • Check environment variable setup
    • Ensure your Materials Project account is active
  2. Docker connection issues:

    • Make sure Docker Desktop is running
    • Check Docker installation with docker --version
    • On Linux, start Docker with sudo systemctl start docker
  3. Container startup issues:

    • Containers start automatically when requests are made
    • No manual startup needed
  4. Docker Compose issues:

    • Verify Docker Compose installation
    • Check your .env file exists with the correct API key
    • Ensure Docker Desktop is running
  5. MCP server not recognized in Claude:

    • Check configuration file path and syntax
    • Restart Claude Desktop after changes
    • Ensure Docker Desktop is running

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "Materials-Project-MCP" '{"command":"docker","args":["run","--rm","-i","-e","MP_API_KEY=your-materials-project-api-key","benedict2002/materials-project-mcp"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "Materials Project MCP": {
            "command": "docker",
            "args": [
                "run",
                "--rm",
                "-i",
                "-e",
                "MP_API_KEY=your-materials-project-api-key",
                "benedict2002/materials-project-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "Materials Project MCP": {
            "command": "docker",
            "args": [
                "run",
                "--rm",
                "-i",
                "-e",
                "MP_API_KEY=your-materials-project-api-key",
                "benedict2002/materials-project-mcp"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later