Optimade MCP Server for Real-Time Materials Queries
Query real-time materials data with an MCP server using the Optimade database for elemental composition, crystal structure, and other materials insights.
npx -y @dianfengxiaobo/optimade-mcp-serverOverview
This MCP (Model Context Protocol) server bridges large language models and real-time materials data by exposing an MCP-compatible HTTP interface backed by an Optimade-compliant materials database. It translates LLM context requests into Optimade queries (composition, crystal structure, properties) and returns structured context blocks that LLMs can use to ground reasoning, retrieval-augmented generation, or downstream tooling.
By running this server you get a lightweight, developer-friendly service to fetch up-to-date materials information (elemental composition, lattice parameters, prototypes, calculated properties) in a format suitable for model consumption. This is useful for building ML agents, interactive notebooks, or tooling that needs deterministic, machine-readable materials context.
Features
- Proxy to any Optimade-compliant database for real-time query results
- Returns MCP-compatible context payloads for LLMs and agents
- Query by chemical formula, element set, space group, or property filters
- Supports pagination and basic caching for repeated queries
- Simple authentication and rate-limiting hooks (configurable)
- Docker and local development modes
- OpenAPI/Swagger for interactive exploration (if enabled)
Installation / Configuration
Prerequisites: Python 3.8+, Docker (optional)
- Clone the repo and install dependencies (virtualenv recommended)
- Minimal environment variables (example)
Create a .env file or export variables in your shell. Typical options:
OPTIMADE_BASE_URL=https://materials.example.org/optimade/v1
MCP_HOST=0.0.0.0
MCP_PORT=8080
API_KEY=changeme
CACHE_TTL=300 # seconds
ENABLE_SWAGGER=true
- Run locally
# with virtualenv active
- Run with Docker
Configuration file (YAML) example:
optimade:
base_url: "https://materials.example.org/optimade/v1"
server:
host: "0.0.0.0"
port: 8080
security:
api_key: "changeme"
cache:
enabled: true
ttl_seconds: 300
Available Tools / Resources
- OpenAPI/Swagger UI — interactive API docs at /docs or /swagger (if enabled in config)
- Example queries — JSON request/response examples in the repo’s examples/ directory
- Postman collection — importable collection for testing endpoints
- Unit tests — tests/ folder with automated test cases
- Readme and CONTRIBUTING — basic developer guidance, issue templates, and how to extend adapters
If the repo is hosted on GitHub (link: https://github.com/dianfengxiaobo/optimade-mcp-server), check the repository for up-to-date docs and the example requests.
API Examples
- Request MCP context for a chemical formula via curl:
Example simplified response (MCP payload):
- Python client example using requests:
=
Use Cases
- LLM-augmented materials discovery: provide a language model with factual context (composition, crystal prototypes, computed properties) to generate hypotheses or suggest candidate materials.
- Automated literature/ELN enrichment: resolve formulas and structures stored in an electronic lab notebook to canonical identifiers and attach structured MCP context.
- Interactive research notebooks: fetch up-to-date Optimade entries for visualization or analysis inside Jupyter, then feed the same structured data into an LLM for interpretation.
- QA pipelines for computed databases: query entries by property thresholds (e.g., formation energy < X) and create concise MCP summaries for reviewers or downstream agents.
Tips for Developers
- Point OPTIMADE_BASE_URL to any Optimade-compliant service (Materials Project, NOMAD, local instances) to reuse existing datasets.
- Use caching for expensive structural queries (e.g., CIF downloads) and tune CACHE_TTL to balance freshness vs latency.
- Extend the server by adding custom transformers that convert Optimade responses into richer, domain-specific MCP blocks (e.g., include structure images, CIF snippets, or computed-property provenance).
For more details and the latest updates visit the project repository: https://github.com/dianfengxiaobo/optimade-mcp-server.