matrouter 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. matrouter-0.1.0/LICENSE +201 -0
  2. matrouter-0.1.0/NOTICE +14 -0
  3. matrouter-0.1.0/PKG-INFO +257 -0
  4. matrouter-0.1.0/README.md +233 -0
  5. matrouter-0.1.0/pyproject.toml +41 -0
  6. matrouter-0.1.0/setup.cfg +4 -0
  7. matrouter-0.1.0/src/matrouter/__init__.py +7 -0
  8. matrouter-0.1.0/src/matrouter/__main__.py +10 -0
  9. matrouter-0.1.0/src/matrouter/adapters/__init__.py +5 -0
  10. matrouter-0.1.0/src/matrouter/adapters/aflow.py +701 -0
  11. matrouter-0.1.0/src/matrouter/adapters/alexandria.py +256 -0
  12. matrouter-0.1.0/src/matrouter/adapters/c2db.py +2084 -0
  13. matrouter-0.1.0/src/matrouter/adapters/cod.py +251 -0
  14. matrouter-0.1.0/src/matrouter/adapters/jarvis_dft.py +3268 -0
  15. matrouter-0.1.0/src/matrouter/adapters/materials_cloud_archive.py +214 -0
  16. matrouter-0.1.0/src/matrouter/adapters/materials_project.py +1054 -0
  17. matrouter-0.1.0/src/matrouter/adapters/materialsgalaxy.py +464 -0
  18. matrouter-0.1.0/src/matrouter/adapters/mpds.py +293 -0
  19. matrouter-0.1.0/src/matrouter/adapters/nomad.py +827 -0
  20. matrouter-0.1.0/src/matrouter/adapters/optimade.py +245 -0
  21. matrouter-0.1.0/src/matrouter/adapters/oqmd.py +214 -0
  22. matrouter-0.1.0/src/matrouter/adapters/pcod.py +276 -0
  23. matrouter-0.1.0/src/matrouter/adapters/tcod.py +59 -0
  24. matrouter-0.1.0/src/matrouter/artifact_manifest.py +275 -0
  25. matrouter-0.1.0/src/matrouter/band_structure.py +419 -0
  26. matrouter-0.1.0/src/matrouter/batch_screening.py +729 -0
  27. matrouter-0.1.0/src/matrouter/cli.py +162 -0
  28. matrouter-0.1.0/src/matrouter/config.py +135 -0
  29. matrouter-0.1.0/src/matrouter/density_of_states.py +223 -0
  30. matrouter-0.1.0/src/matrouter/evidence_assessment.py +293 -0
  31. matrouter-0.1.0/src/matrouter/http.py +86 -0
  32. matrouter-0.1.0/src/matrouter/jarvis_artifacts.py +821 -0
  33. matrouter-0.1.0/src/matrouter/live_smoke.py +120 -0
  34. matrouter-0.1.0/src/matrouter/materials_project_client_objects.py +103 -0
  35. matrouter-0.1.0/src/matrouter/mcp_server.py +1009 -0
  36. matrouter-0.1.0/src/matrouter/normalize.py +963 -0
  37. matrouter-0.1.0/src/matrouter/optimade_cache.py +102 -0
  38. matrouter-0.1.0/src/matrouter/optimade_discovery.py +84 -0
  39. matrouter-0.1.0/src/matrouter/optimade_health.py +87 -0
  40. matrouter-0.1.0/src/matrouter/optimade_urls.py +50 -0
  41. matrouter-0.1.0/src/matrouter/phase_diagram.py +305 -0
  42. matrouter-0.1.0/src/matrouter/phase_matching.py +214 -0
  43. matrouter-0.1.0/src/matrouter/phase_stability_package.py +1034 -0
  44. matrouter-0.1.0/src/matrouter/plot_curves.py +60 -0
  45. matrouter-0.1.0/src/matrouter/plotting.py +546 -0
  46. matrouter-0.1.0/src/matrouter/report_package.py +918 -0
  47. matrouter-0.1.0/src/matrouter/report_rendering.py +546 -0
  48. matrouter-0.1.0/src/matrouter/router.py +1502 -0
  49. matrouter-0.1.0/src/matrouter/structure_downloads.py +81 -0
  50. matrouter-0.1.0/src/matrouter/structure_formats.py +586 -0
  51. matrouter-0.1.0/src/matrouter/structure_matching.py +545 -0
  52. matrouter-0.1.0/src/matrouter.egg-info/PKG-INFO +257 -0
  53. matrouter-0.1.0/src/matrouter.egg-info/SOURCES.txt +73 -0
  54. matrouter-0.1.0/src/matrouter.egg-info/dependency_links.txt +1 -0
  55. matrouter-0.1.0/src/matrouter.egg-info/entry_points.txt +2 -0
  56. matrouter-0.1.0/src/matrouter.egg-info/requires.txt +5 -0
  57. matrouter-0.1.0/src/matrouter.egg-info/top_level.txt +1 -0
  58. matrouter-0.1.0/tests/test_adapters.py +4120 -0
  59. matrouter-0.1.0/tests/test_batch_screening.py +304 -0
  60. matrouter-0.1.0/tests/test_cli.py +225 -0
  61. matrouter-0.1.0/tests/test_config.py +287 -0
  62. matrouter-0.1.0/tests/test_http.py +81 -0
  63. matrouter-0.1.0/tests/test_live_smoke.py +83 -0
  64. matrouter-0.1.0/tests/test_mcp_client_compat.py +58 -0
  65. matrouter-0.1.0/tests/test_mcp_server.py +805 -0
  66. matrouter-0.1.0/tests/test_normalize.py +472 -0
  67. matrouter-0.1.0/tests/test_optimade_cache.py +132 -0
  68. matrouter-0.1.0/tests/test_optimade_discovery.py +150 -0
  69. matrouter-0.1.0/tests/test_optimade_health.py +44 -0
  70. matrouter-0.1.0/tests/test_optimade_urls.py +19 -0
  71. matrouter-0.1.0/tests/test_phase_diagram.py +85 -0
  72. matrouter-0.1.0/tests/test_plotting.py +200 -0
  73. matrouter-0.1.0/tests/test_report_rendering.py +221 -0
  74. matrouter-0.1.0/tests/test_router.py +2860 -0
  75. matrouter-0.1.0/tests/test_structure_matching.py +323 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ https://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
matrouter-0.1.0/NOTICE ADDED
@@ -0,0 +1,14 @@
1
+ MatRouter
2
+ Copyright 2026 Quansheng Wu
3
+
4
+ Developer contact:
5
+ Quansheng Wu
6
+ quansheng.wu@iphy.ac.cn
7
+ wuquansheng@gmail.com
8
+
9
+ This product is licensed under the Apache License, Version 2.0.
10
+
11
+ MatRouter is software for accessing third-party materials databases.
12
+ Third-party database content retrieved through MatRouter is not licensed
13
+ by this NOTICE file and remains subject to the upstream provider's terms,
14
+ licenses, API policies, attribution requirements, and access restrictions.
@@ -0,0 +1,257 @@
1
+ Metadata-Version: 2.4
2
+ Name: matrouter
3
+ Version: 0.1.0
4
+ Summary: Local-first MCP server for agentic materials data routing.
5
+ Author-email: Quansheng Wu <quansheng.wu@iphy.ac.cn>
6
+ Maintainer-email: Quansheng Wu <quansheng.wu@iphy.ac.cn>, Quansheng Wu <wuquansheng@gmail.com>
7
+ License-Expression: Apache-2.0
8
+ Keywords: materials-science,mcp,optimade,materials-project,aflow,c2db,mpds,agent
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
13
+ Classifier: Topic :: Scientific/Engineering :: Physics
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ License-File: NOTICE
18
+ Requires-Dist: matplotlib>=3.8
19
+ Requires-Dist: materialsgalaxy-api>=0.1.2
20
+ Requires-Dist: mp-api>=0.46.1
21
+ Requires-Dist: pymatgen>=2025.10.7
22
+ Requires-Dist: spglib>=2.5
23
+ Dynamic: license-file
24
+
25
+ # MatRouter
26
+
27
+ <p align="center">
28
+ <img src="logo.png" alt="MatRouter logo" width="220">
29
+ </p>
30
+
31
+ [English](README.md) | [简体中文](README.zh-CN.md)
32
+
33
+ MatRouter is a local-first MCP server for agentic materials research. It gives AI agents structured access to materials databases through normalized tools, provenance-aware responses, and lightweight analysis utilities.
34
+
35
+ ## Status
36
+
37
+ `v0.1.0` is an offline-testable first version focused on local use by researchers.
38
+
39
+ ## Documentation
40
+
41
+ - User guide: [docs/usage.md](docs/usage.md)
42
+ - Development guide: [docs/development.md](docs/development.md)
43
+ - Validation report: [docs/test-report.md](docs/test-report.md)
44
+ - Configure MatRouter in Codex, Claude Code, OpenCode, and other agents: upload the `SKILL.md` file from this repository to the agent, then ask:
45
+ "Configure MatRouter in my current Codex, Claude Code, or OpenCode environment."
46
+ - Example agent prompt:
47
+ "Use MatRouter to find the band structure of diamond and generate a plot."
48
+
49
+ ## Contact
50
+
51
+ Author and maintainer: Quansheng Wu
52
+
53
+ - quansheng.wu@iphy.ac.cn
54
+ - wuquansheng@gmail.com
55
+
56
+ ## License
57
+
58
+ MatRouter source code is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
59
+
60
+ MatRouter does not grant rights to third-party database content. Data retrieved through MatRouter remains subject to the terms, licenses, API policies, attribution requirements, and access restrictions of the respective upstream data providers.
61
+
62
+ ## Install From PyPI
63
+
64
+ MatRouter requires Python 3.10 or newer.
65
+
66
+ ```bash
67
+ python3 -m pip install matrouter
68
+ ```
69
+
70
+ ## Install From Source
71
+
72
+ ```bash
73
+ git clone https://github.com/MatRouter/matrouter.git
74
+ cd matrouter
75
+ python3 -m pip install -e .
76
+ ```
77
+
78
+ The default install includes lightweight plotting, Materials Project `mp-api` access, `pymatgen` VASP parsing, phase-diagram helpers, and `spglib`-backed structure matching. Normal users do not need separate extras for band structures, structure matching, or phase diagrams.
79
+
80
+ ## Configuration
81
+
82
+ Most starter workflows should use public sources first: AFLOW, OQMD, JARVIS-DFT, Alexandria, NOMAD public data, COD, C2DB, Materials Cloud Archive, MaterialsGalaxy public summaries, and manually configured public OPTIMADE providers do not require MatRouter-specific credentials.
83
+
84
+ Credentialed sources:
85
+
86
+ - Materials Project (`MP_API_KEY`): create or sign in to a Materials Project account at <https://materialsproject.org/>. The official API guide says the key is available on the profile dashboard after login: <https://docs.materialsproject.org/downloading-data/using-the-api/getting-started>.
87
+ - MaterialsGalaxy (`MATERIALSGALAXY_API_KEY`): use the MaterialsGalaxy portal and API guide at <https://materialsgalaxy.iphy.ac.cn/> and <https://materialsgalaxy.iphy.ac.cn/guides/api>. Public summary search works without a key; detailed structure and property endpoints require a user API key.
88
+ - MPDS / PAULING FILE (`MPDS_API_KEY` or `MPDS_KEY`): MPDS API access requires an MPDS account/subscription; see <https://mpds.io/developer/>. Because this is license/account controlled, MPDS is not used as the default README smoke-test example.
89
+
90
+ Keep real keys in environment variables or local MCP client config. Do not commit them to the repository.
91
+
92
+ Materials Project uses `MP_API_KEY`:
93
+
94
+ ```bash
95
+ export MP_API_KEY="your-materials-project-api-key"
96
+ ```
97
+
98
+ OQMD is enabled by default and does not require credentials. It uses the public formation-energy REST endpoint for formula, formation energy, hull stability, band gap when available, space group, and prototype metadata:
99
+
100
+ ```bash
101
+ export MATROUTER_OQMD_BASE_URL="https://oqmd.org/oqmdapi"
102
+ ```
103
+
104
+ AFLOW is enabled by default and does not require credentials. It uses the public AFLUX API for chemical-system search, optional `exact_formula` reduced-formula filtering, documented `aflow_filter` AFLUX templates, and per-entry AFLOW REST fields for normalized material records, CIF/POSCAR structure export, raw artifact listing/download, band-structure plotting from `*_bandsdata.json.xz` with `EIGENVAL.bands.xz` fallback, DOS/PDOS plotting from `*_dosdata.json.xz`, and report-ready artifact collection:
105
+
106
+ ```bash
107
+ export MATROUTER_AFLOW_BASE_URL="https://aflow.org/API/aflux"
108
+ ```
109
+
110
+ JARVIS-DFT is enabled by default and does not require credentials. It uses the public NIST JARVIS-DFT `dft_3d` snapshot for local formula/chemical-system search, material records, stability, band gaps, deep property metadata, CIF/POSCAR structure export, virtual JSON data products (`data/material.json`, `data/source-metadata.json`, `data/raw-record.json`), Figshare raw archive listing/download from each record's `raw_files` metadata, official JARVIS dataset/API manifests for 2D/FF/ML/WannierTB/Solar/STM/external-database surfaces, explicit global dataset archive downloads under `datasets/<dataset>/<filename>.zip` with structured JSON previews when possible, and optional archive parsing for band structures, DOS, optical spectra, phonon DOS/DFPT normal modes, BoltzTraP-style transport tables, LOCPOT electrostatic-potential profiles, and work-function values when those files/fields are present. JARVIS manifests are property-first: structures, scalar properties, tensors, spectra, and curves are marked as recommended, while heavy intermediate/model artifacts such as WANN/WAVECAR/WannierTB payloads remain explicit-download-only. The `dft_3d` snapshot is downloaded and cached on first JARVIS query, not at MCP startup:
111
+
112
+ ```bash
113
+ export MATROUTER_JARVIS_DFT_DATA_URL="https://ndownloader.figshare.com/files/38521619"
114
+ export MATROUTER_JARVIS_DFT_CACHE_PATH="$HOME/.cache/matrouter/jarvis-dft-3d.json"
115
+ ```
116
+
117
+ Alexandria is enabled by default and does not require credentials. It uses Alexandria's public OPTIMADE PBE and PBEsol endpoints for structures, band gaps, formation energies, and hull distances:
118
+
119
+ ```bash
120
+ export MATROUTER_ALEXANDRIA_URLS="https://alexandria.icams.rub.de/pbe,https://alexandria.icams.rub.de/pbesol"
121
+ ```
122
+
123
+ NOMAD is enabled by default and does not require credentials for public entries. It uses the public NOMAD v1 `entries/query` metadata API, per-entry archive queries for structure export and source-specific property bundles, and raw file endpoints for explicit file listing/download. NOMAD band gaps are normalized when NOMAD exposes them in processed electronic properties; when public rawdir exposes VASP `vasprun.xml`, MatRouter can reuse its VASP parser path for band/DOS plots. Archive total energies can be returned in calculation summaries but are not mapped to formation energy or hull stability:
124
+
125
+ ```bash
126
+ export MATROUTER_NOMAD_BASE_URL="https://nomad-lab.eu/prod/v1/api/v1"
127
+ ```
128
+
129
+ COD is enabled by default and does not require credentials. It uses the public Crystallography Open Database REST search endpoint for experimental crystal metadata and downloads raw CIF files by COD ID:
130
+
131
+ ```bash
132
+ export MATROUTER_COD_BASE_URL="https://www.crystallography.net/cod"
133
+ ```
134
+
135
+ C2DB is enabled by default and does not require credentials. It uses the public Computational 2D Materials Database browse/material pages and structure download endpoints for 2D-material band gaps, formation energies, hull distance, layer group, magnetism, dynamic stability, official key-value filters, richer material-page scalar metadata, and structure JSON/CIF/XYZ/POSCAR export. Add `{"include_details": true}` to `c2db_filter` when search results should be hydrated from per-material detail pages. C2DB material pages are also exposed as auditable report artifacts: page HTML, all parsed HTML tables, structured webpage-derived elasticity/piezo/deformation/phonon/Raman/Born/Bader/effective-mass/optical/miscellaneous JSON bundles when present, Plotly JSON for PBE/HSE/GW band and PDOS plots, extracted Plotly curve JSON, MatRouter-rendered PNG plots generated from those curve JSON artifacts, and page PNG figures when no curve data is exposed. These webpage-derived artifacts are not advertised as stable official C2DB curve/property APIs:
136
+
137
+ ```bash
138
+ export MATROUTER_C2DB_BASE_URL="https://c2db.fysik.dtu.dk"
139
+ ```
140
+
141
+ MaterialsGalaxy public summary search does not require credentials. Detailed structure, electronic-structure, topology, topological-phonon, ferroelectric, nonlinear-optical, and single-crystal-growth endpoints require `MATERIALSGALAXY_API_KEY`:
142
+
143
+ ```bash
144
+ export MATERIALSGALAXY_API_KEY="your-materialsgalaxy-api-key"
145
+ export MATROUTER_MATERIALSGALAXY_BASE_URL="https://materialsgalaxy.iphy.ac.cn/api/v1"
146
+ ```
147
+
148
+ MPDS / PAULING FILE requires an MPDS API key. It uses the MPDS `download/facet` endpoint for experimental inorganic structures, physical-property entries, phase-linked records, and raw CIF export:
149
+
150
+ ```bash
151
+ export MPDS_API_KEY="your-mpds-api-key"
152
+ export MATROUTER_MPDS_BASE_URL="https://api.mpds.io/v0"
153
+ ```
154
+
155
+ OPTIMADE sources can be configured as comma-separated base URLs:
156
+
157
+ ```bash
158
+ export MATROUTER_OPTIMADE_URLS="https://example.org/optimade"
159
+ ```
160
+
161
+ OPTIMADE provider discovery is opt-in so the server does not make network calls at startup by default:
162
+
163
+ ```bash
164
+ export MATROUTER_OPTIMADE_DISCOVER=1
165
+ ```
166
+
167
+ Discovery reads the official provider registry, follows provider index `/v1/links` endpoints, and adds queryable child database base URLs. For testing mirrors or private registries:
168
+
169
+ ```bash
170
+ export MATROUTER_OPTIMADE_PROVIDER_REGISTRY_URL="https://providers.optimade.org/providers.json"
171
+ ```
172
+
173
+ Discovery results are cached under the MatRouter cache directory so repeated MCP starts do not need to re-scan the public registry:
174
+
175
+ ```bash
176
+ export MATROUTER_CACHE_DIR="$HOME/.cache/matrouter"
177
+ export MATROUTER_OPTIMADE_CACHE_TTL_SECONDS=86400
178
+ export MATROUTER_OPTIMADE_DISCOVERY_REFRESH=1
179
+ ```
180
+
181
+ OPTIMADE search is failure-tolerant across configured providers: if one provider times out or returns an error, MatRouter keeps querying the remaining providers and reports the failed provider in `warnings`. The `limit` argument is applied across the whole OPTIMADE search, not once per provider.
182
+
183
+ To avoid repeatedly querying providers that recently failed, enable the persistent health skip window:
184
+
185
+ ```bash
186
+ export MATROUTER_OPTIMADE_SKIP_UNHEALTHY=1
187
+ export MATROUTER_OPTIMADE_FAILURE_COOLDOWN_SECONDS=3600
188
+ ```
189
+
190
+ `explain_sources` reports per-provider status, capabilities, base URL, and database-qualified source keys such as `optimade:optimade.materialscloud.org/main/mc3d-pbesol-v2`.
191
+
192
+ ## Run
193
+
194
+ ```bash
195
+ matrouter
196
+ ```
197
+
198
+ For a quick local configuration check:
199
+
200
+ ```bash
201
+ matrouter --explain-sources
202
+ ```
203
+
204
+ ## MCP Tools
205
+
206
+ - `search_materials`
207
+ - `get_material`
208
+ - `get_structure` (`json`, `cif`, and `poscar` when lattice/site data is available)
209
+ - `get_band_structure`
210
+ - `get_density_of_states` (Materials Project with `MP_API_KEY`; AFLOW processed DOS artifacts with lightweight MatRouter plotting; JARVIS-DFT via listed VASP raw archives; NOMAD via public rawdir VASP `vasprun.xml` when present)
211
+ - `get_source_property` (source-specific structured property bundles; JARVIS-DFT supports `all_properties`, elasticity, dielectric, optical metadata and spectra, phonon metadata, `edos_pdos`, `phonon_dos`, `phonon_dispersion`, transport coefficients, `transport_curves`, magnetism, superconductivity, exfoliation, electrostatic potential, work function, computational settings, database links, XRD/RDF plot-ready curves, stability semantics, raw archive manifests, external dataset manifests, `jarvis_dataset_manifest`, and `jarvis_api_manifest`; NOMAD supports `available_properties`, `calculation_summary`, `method`, `electronic`, and `raw_archive_manifest`)
212
+ - `get_materials_project_property` (official Materials Project property document endpoints such as dielectric, elasticity, phonon, XAS, battery, surface, tasks/provenance, electronic structure, synthesis, molecules, and defect tasks)
213
+ - `collect_report_artifacts` (AFLOW report-ready images/CIF/metadata; C2DB material-page HTML, parsed property-table JSON, Plotly JSON including PBE/HSE/GW band and PDOS plots, extracted curve JSON, MatRouter-rendered PNG plots generated from the curve JSON where available, page PNG figures where C2DB only exposes images, and generated structures)
214
+ - `list_source_files`
215
+ - `download_source_file` (generated structures, C2DB material-page Plotly JSON with sibling rendered PNG output, C2DB extracted curve JSON, parsed property-table JSON, rendered/page PNG artifacts, source data products such as JARVIS JSON records, Materials Project REST property JSON snapshots and explicit Open Data parsed-bucket objects, optionally `decompress=true` for AFLOW `.xz` or JARVIS `.zip` raw artifacts; AFLOW/NOMAD raw VASP files return `pymatgen` post-processing guidance, and NOMAD `vasprun.xml` can feed the built-in band/DOS plotting path)
216
+ - `screen_materials`
217
+ - `batch_screen_materials` (project-scale screening over many search queries or normalized candidates with async batching, retry, rate limiting, lock-protected project JSON cache, progress, resumable result state, failure reports, stable CSV/Parquet export schema, and optional CSV/Parquet export; default cache path is `.matrouter/cache/batch-screen-cache.json`, override with `MATROUTER_PROJECT_CACHE_DIR`, `MATROUTER_BATCH_SCREEN_CACHE_PATH`, or `cache_path`)
218
+ - `compare_materials`
219
+ - `plan_retrieval` (source/tool routing with per-need capability summary)
220
+ - `build_material_report_package` (cross-source evidence package with embedded database capability context, `report_preset` shortcuts, `analysis_tasks` for AI answer planning, phase matches, optional structure-level matching, phase-stability evidence with optional MP phase-diagram computation, artifact manifest, evidence assessment for agreement/conflict/next-evidence analysis, property inventory, profile-controlled property comparison, ranked candidates, coverage, trust notes, missing data, and follow-up tool suggestions)
221
+ - `render_material_report` (renders an existing or newly built material report package to Markdown or printer-friendly HTML with tables, artifact references, data sources, citations/DOIs when present, warnings, missing-data notes, and explicit "do not over-interpret" cautions)
222
+ - `build_phase_stability_package` (phase-stability evidence package with formation energy, hull distance, stable flags, phase-separation/dynamic-stability metadata, optional Materials Project thermo entries as phase-diagram inputs, `pymatgen` hull/decomposition/plot post-processing when requested, source support for phase-diagram work, limitations, and next-step guidance)
223
+ - `build_phase_diagram_package` (one-click Materials Project phase-diagram package with thermo entries, optional plot, target hull distance, decomposition, and chemical-potential/Pourbaix/defect workflow entrypoints where available)
224
+ - `get_database_capability_matrix` (lightweight source capability table for key requirements, structures, stability, band structures, DOS, raw files, and report artifacts)
225
+ - `get_database_data_catalog` (categorized per-database data inventory: identity, structure, thermodynamics, electronic, optical/spectroscopy, phonon, mechanical, transport, magnetic/superconducting, surfaces/batteries, calculation metadata, database-specific documents, and files)
226
+ - `get_material_data_inventory` (for one source/material id, report the database's supported data categories plus normalized fields observed in that material record)
227
+ - `locate_property_sources` (given a property need such as `band_gap`, `bands`, `elasticity`, or `files`, list databases that can provide it, credential blockers, and follow-up tools)
228
+ - `explain_sources`
229
+
230
+ Public smoke check, no API key required:
231
+
232
+ ```bash
233
+ matrouter --live-smoke aflow
234
+ matrouter --live-smoke aflow --live-smoke-run
235
+ ```
236
+
237
+ Configured-source checks remain available when needed:
238
+
239
+ ```bash
240
+ matrouter --live-smoke optimade
241
+ matrouter --live-smoke mpds
242
+ ```
243
+
244
+ Dry-run mode reports source configuration without network access; `--live-smoke-run` executes a tiny one-record probe only for sources that are enabled. Use MPDS smoke only when the user has a valid MPDS account/subscription key.
245
+
246
+ ## Testing
247
+
248
+ ```bash
249
+ PYTHONPATH=src python3 -m unittest discover -s tests -v
250
+ ```
251
+
252
+ Render a saved report package for human readers:
253
+
254
+ ```bash
255
+ matrouter --render-report package.json --output report.md
256
+ matrouter --render-report package.json --report-format html --output report.html
257
+ ```