Skip to main content
Glama
fair2wise

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.
ParametersJSON Schema
NameRequiredDescriptionDefault
formulaYes
max_recordsNo

TDQS

B3.2/5.0
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.

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.
ParametersJSON Schema
NameRequiredDescriptionDefault
material_idYes

TDQS

A4/5.0
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 states the tool retrieves information, implying a read-only operation, but lacks details on permissions, rate limits, error handling, or what specific information is included in the 'detailed information.' This is a significant gap for a tool with no annotation coverage.

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 appropriately sized and front-loaded, with a clear purpose statement followed by concise sections for Args and Returns. Every sentence adds value without redundancy, making it efficient and well-structured.

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 complexity (single parameter, no output schema, no annotations), the description is adequate but has clear gaps. It explains the parameter well and states the return type, but without annotations or output schema, it lacks details on behavioral aspects like error cases or the structure of the returned dictionary, leaving room for improvement.

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

Parameters5/5

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

The description adds substantial meaning beyond the input schema, which has 0% coverage. It explains that material_id is a 'Materials Project ID' and provides an example ('mp-149'), clarifying the parameter's purpose and format, which compensates fully for the schema's lack of description.

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

Purpose5/5

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

The description clearly states the verb ('Get detailed information') and resource ('about a specific material by its Materials Project ID'), distinguishing it from sibling tools like find_materials_by_formula and get_materials_with_elements, which search by formula or elements rather than retrieving details by ID.

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

Usage Guidelines4/5

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

The description implies usage context by specifying 'by its Materials Project ID,' suggesting this tool is for retrieving details when you have a specific ID. However, it does not explicitly state when not to use it or name alternatives, such as using sibling tools for search instead.

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

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.
ParametersJSON Schema
NameRequiredDescriptionDefault
elementsYes
exclude_elementsNo
max_recordsNo

TDQS

B3.1/5.0
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 states what the tool does (finds materials) and describes parameters, but lacks critical behavioral information: it doesn't mention whether this is a read-only operation, what data source it queries, potential rate limits, authentication requirements, or error conditions. The description is functional but incomplete for behavioral understanding.

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

Conciseness4/5

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

The description is well-structured and appropriately sized. It begins with a clear purpose statement, then lists parameters with brief explanations and examples, and concludes with return information. Every sentence adds value, though the 'Returns' section could be slightly more detailed given the lack of output schema.

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 (3 parameters, no annotations, no output schema), the description is adequate but has gaps. It covers parameters well and states the return type, but lacks behavioral context (e.g., data source, performance characteristics) and doesn't explain the format of returned materials. For a search tool with no structured metadata, more completeness 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 significant value beyond the input schema, which has 0% description coverage. It explains the meaning of all three parameters: 'elements' must be present, 'exclude_elements' must not be present, and 'max_records' limits results with a default. The examples (e.g., ["Fe", "O"]) and clarification of optionality are particularly helpful. Since schema coverage is low, the description effectively compensates.

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 containing specific elements.' This is a specific verb+resource combination that distinguishes it from sibling tools like 'find_materials_by_formula' (which presumably searches by chemical formula) and 'get_material_details' (which retrieves details for specific materials). However, it doesn't explicitly contrast with siblings beyond the inherent difference in function.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools, suggest scenarios where this tool is appropriate, or warn against misuse. The only contextual information is the parameter descriptions, which don't constitute usage guidelines.

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

TDQS

A3.5/5.0
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.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

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
    C
    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.
    3
    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.
    8
    MIT

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