@cyanheads/pubchem-mcp-server 1.0.1
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.
- package/LICENSE +201 -0
- package/README.md +236 -0
- package/dist/config/index.d.ts +98 -0
- package/dist/config/index.js +326 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +214 -0
- package/dist/mcp-server/server.d.ts +21 -0
- package/dist/mcp-server/server.js +124 -0
- package/dist/mcp-server/tools/fetchAssaySummary/index.d.ts +7 -0
- package/dist/mcp-server/tools/fetchAssaySummary/index.js +7 -0
- package/dist/mcp-server/tools/fetchAssaySummary/logic.d.ts +71 -0
- package/dist/mcp-server/tools/fetchAssaySummary/logic.js +96 -0
- package/dist/mcp-server/tools/fetchAssaySummary/registration.d.ts +12 -0
- package/dist/mcp-server/tools/fetchAssaySummary/registration.js +68 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/index.d.ts +7 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/index.js +7 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/logic.d.ts +131 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/logic.js +100 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/registration.d.ts +13 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/registration.js +52 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/index.d.ts +7 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/index.js +7 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/logic.d.ts +89 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/logic.js +145 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/registration.d.ts +13 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/registration.js +52 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/index.d.ts +7 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/index.js +7 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/logic.d.ts +69 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/logic.js +97 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/registration.d.ts +13 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/registration.js +79 -0
- package/dist/mcp-server/tools/getCompoundImage/index.d.ts +7 -0
- package/dist/mcp-server/tools/getCompoundImage/index.js +7 -0
- package/dist/mcp-server/tools/getCompoundImage/logic.d.ts +42 -0
- package/dist/mcp-server/tools/getCompoundImage/logic.js +68 -0
- package/dist/mcp-server/tools/getCompoundImage/registration.d.ts +12 -0
- package/dist/mcp-server/tools/getCompoundImage/registration.js +57 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/index.js +7 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/logic.d.ts +35 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/logic.js +64 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/registration.d.ts +12 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/registration.js +62 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/index.js +7 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/logic.d.ts +35 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/logic.js +59 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/registration.d.ts +12 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/registration.js +51 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/index.js +7 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/logic.d.ts +38 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/logic.js +75 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/registration.d.ts +12 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/registration.js +62 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/index.js +7 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/logic.d.ts +41 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/logic.js +82 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/registration.d.ts +12 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/registration.js +62 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/index.js +7 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/logic.d.ts +41 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/logic.js +78 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/registration.d.ts +13 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/registration.js +63 -0
- package/dist/mcp-server/transports/auth/core/authContext.d.ts +33 -0
- package/dist/mcp-server/transports/auth/core/authContext.js +24 -0
- package/dist/mcp-server/transports/auth/core/authTypes.d.ts +17 -0
- package/dist/mcp-server/transports/auth/core/authTypes.js +5 -0
- package/dist/mcp-server/transports/auth/core/authUtils.d.ts +18 -0
- package/dist/mcp-server/transports/auth/core/authUtils.js +45 -0
- package/dist/mcp-server/transports/auth/index.d.ts +10 -0
- package/dist/mcp-server/transports/auth/index.js +9 -0
- package/dist/mcp-server/transports/auth/strategies/jwt/jwtMiddleware.d.ts +27 -0
- package/dist/mcp-server/transports/auth/strategies/jwt/jwtMiddleware.js +149 -0
- package/dist/mcp-server/transports/auth/strategies/oauth/oauthMiddleware.d.ts +20 -0
- package/dist/mcp-server/transports/auth/strategies/oauth/oauthMiddleware.js +124 -0
- package/dist/mcp-server/transports/httpErrorHandler.d.ts +26 -0
- package/dist/mcp-server/transports/httpErrorHandler.js +73 -0
- package/dist/mcp-server/transports/httpTransport.d.ts +21 -0
- package/dist/mcp-server/transports/httpTransport.js +208 -0
- package/dist/mcp-server/transports/stdioTransport.d.ts +42 -0
- package/dist/mcp-server/transports/stdioTransport.js +63 -0
- package/dist/services/pubchem/pubchemApiClient.d.ts +52 -0
- package/dist/services/pubchem/pubchemApiClient.js +120 -0
- package/dist/types-global/errors.d.ts +127 -0
- package/dist/types-global/errors.js +126 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/internal/errorHandler.d.ts +176 -0
- package/dist/utils/internal/errorHandler.js +335 -0
- package/dist/utils/internal/index.d.ts +9 -0
- package/dist/utils/internal/index.js +9 -0
- package/dist/utils/internal/logger.d.ts +148 -0
- package/dist/utils/internal/logger.js +430 -0
- package/dist/utils/internal/requestContext.d.ts +83 -0
- package/dist/utils/internal/requestContext.js +72 -0
- package/dist/utils/metrics/index.d.ts +7 -0
- package/dist/utils/metrics/index.js +7 -0
- package/dist/utils/metrics/tokenCounter.d.ts +35 -0
- package/dist/utils/metrics/tokenCounter.js +110 -0
- package/dist/utils/network/fetchWithTimeout.d.ts +21 -0
- package/dist/utils/network/fetchWithTimeout.js +59 -0
- package/dist/utils/network/index.d.ts +6 -0
- package/dist/utils/network/index.js +5 -0
- package/dist/utils/parsing/dateParser.d.ts +73 -0
- package/dist/utils/parsing/dateParser.js +107 -0
- package/dist/utils/parsing/index.d.ts +8 -0
- package/dist/utils/parsing/index.js +8 -0
- package/dist/utils/parsing/jsonParser.d.ts +82 -0
- package/dist/utils/parsing/jsonParser.js +126 -0
- package/dist/utils/scheduling/index.d.ts +6 -0
- package/dist/utils/scheduling/index.js +6 -0
- package/dist/utils/scheduling/scheduler.d.ts +72 -0
- package/dist/utils/scheduling/scheduler.js +152 -0
- package/dist/utils/security/idGenerator.d.ts +137 -0
- package/dist/utils/security/idGenerator.js +215 -0
- package/dist/utils/security/index.d.ts +9 -0
- package/dist/utils/security/index.js +9 -0
- package/dist/utils/security/rateLimiter.d.ts +108 -0
- package/dist/utils/security/rateLimiter.js +179 -0
- package/dist/utils/security/sanitization.d.ts +184 -0
- package/dist/utils/security/sanitization.js +453 -0
- package/package.json +108 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://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 2025 Casey Hand @cyanheads
|
|
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
|
+
http://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.
|
package/README.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# PubChem MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://www.typescriptlang.org/)
|
|
4
|
+
[](https://modelcontextprotocol.io/)
|
|
5
|
+
[](./CHANGELOG.md)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
[](https://github.com/cyanheads/pubchem-mcp-server/issues)
|
|
8
|
+
[](https://github.com/cyanheads/pubchem-mcp-server)
|
|
9
|
+
|
|
10
|
+
**Empower your AI agents and scientific tools with seamless PubChem integration!**
|
|
11
|
+
|
|
12
|
+
An MCP (Model Context Protocol) server providing comprehensive access to PubChem's vast chemical information database. Enables LLMs and AI agents to search, retrieve, and analyze chemical compounds, substances, and bioassays through the PubChem PUG REST API.
|
|
13
|
+
|
|
14
|
+
Built on the [`cyanheads/mcp-ts-template`](https://github.com/cyanheads/mcp-ts-template), this server follows a modular architecture with robust error handling, logging, and security features.
|
|
15
|
+
|
|
16
|
+
## 🚀 Core Capabilities: PubChem Tools 🛠️
|
|
17
|
+
|
|
18
|
+
This server equips your AI with specialized tools to interact with PubChem:
|
|
19
|
+
|
|
20
|
+
| Tool Name | Description | Key Features |
|
|
21
|
+
| :---------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| [`pubchem_search_compound_by_identifier`](./src/mcp-server/tools/searchCompoundByIdentifier/) | Searches for PubChem Compound IDs (CIDs) using a list of chemical identifiers. | - Search by `name`, `smiles`, or `inchikey`.<br/>- Accepts multiple identifiers in a single call for bulk lookups. |
|
|
23
|
+
| [`pubchem_fetch_compound_properties`](./src/mcp-server/tools/fetchCompoundProperties/) | Fetches a list of specified physicochemical properties for one or more CIDs. | - Retrieve properties like `MolecularWeight`, `XLogP`, `IUPACName`, etc.<br/>- Essential for gathering detailed chemical data in bulk. |
|
|
24
|
+
| [`pubchem_get_compound_image`](./src/mcp-server/tools/getCompoundImage/) | Fetches a 2D image of a compound's structure for a given CID. | - Returns the raw image data as a binary blob.<br/>- Supports `small` (100x100) and `large` (300x300) image sizes. |
|
|
25
|
+
| [`pubchem_search_compounds_by_structure`](./src/mcp-server/tools/searchCompoundsByStructure/) | Performs a structural search using a SMILES string or a CID as the query. | - Supports `substructure`, `superstructure`, and `identity` search types.<br/>- Essential for finding structurally related compounds. |
|
|
26
|
+
| [`pubchem_search_compounds_by_similarity`](./src/mcp-server/tools/searchCompoundsBySimilarity/) | Finds compounds with a similar 2D structure to a query compound. | - Based on a Tanimoto similarity score.<br/>- Search by `smiles` or `cid`.<br/>- Configurable `threshold` and `maxRecords`. |
|
|
27
|
+
| [`pubchem_search_compounds_by_formula`](./src/mcp-server/tools/searchCompoundsByFormula/) | Finds PubChem Compound IDs (CIDs) that match a given molecular formula. | - Supports exact matches and formulas with additional elements.<br/>- Configurable `maxRecords`. |
|
|
28
|
+
| [`pubchem_fetch_substance_details`](./src/mcp-server/tools/fetchSubstanceDetails/) | Retrieves details for a given PubChem Substance ID (SID). | - Fetches synonyms, source, dates, related CIDs, and full compound data in one call. |
|
|
29
|
+
| [`pubchem_fetch_assay_summary`](./src/mcp-server/tools/fetchAssaySummary/) | Fetches detailed summaries for a list of up to 5 PubChem BioAssay IDs (AIDs). | - Includes name, description, source, and statistics.<br/>- Supports bulk fetching for multiple AIDs. |
|
|
30
|
+
| [`pubchem_search_assays_by_target`](./src/mcp-server/tools/searchAssaysByTarget/) | Finds PubChem BioAssay IDs (AIDs) associated with a specific biological target. | - Search by `genesymbol` or `proteinname`. |
|
|
31
|
+
| [`pubchem_fetch_compound_xrefs`](./src/mcp-server/tools/fetchCompoundXrefs/) | Fetches external cross-references (XRefs) for a given CID. | - Retrieve `RegistryID`, `PubMedID`, `PatentID`, etc.<br/>- Robustly handles large datasets with pagination. |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Table of Contents
|
|
36
|
+
|
|
37
|
+
| [Overview](#overview) | [Features](#features) | [Installation](#installation) |
|
|
38
|
+
| [Configuration](#configuration) | [Project Structure](#project-structure) |
|
|
39
|
+
| [Tools](#tools) | [Development](#development) | [License](#license) |
|
|
40
|
+
|
|
41
|
+
## Overview
|
|
42
|
+
|
|
43
|
+
The PubChem MCP Server acts as a bridge, allowing applications (MCP Clients) that understand the Model Context Protocol (MCP) – like advanced AI assistants (LLMs), IDE extensions, or custom research tools – to interact directly and efficiently with PubChem's vast chemical database.
|
|
44
|
+
|
|
45
|
+
Instead of complex API integration or manual searches, your tools can leverage this server to:
|
|
46
|
+
|
|
47
|
+
- **Automate chemical research**: Search for compounds, fetch detailed properties, find similar structures, and analyze bioassay results programmatically.
|
|
48
|
+
- **Gain chemical insights**: Access detailed compound data, substance information, and bioassay metadata without leaving the host application.
|
|
49
|
+
- **Integrate PubChem into AI-driven science**: Enable LLMs to conduct chemical research, analyze structure-activity relationships, and support evidence-based discovery.
|
|
50
|
+
|
|
51
|
+
Built on the robust `mcp-ts-template`, this server provides a standardized, secure, and efficient way to expose PubChem functionality via the MCP standard. It achieves this by integrating with the PubChem PUG REST API, ensuring compliance with rate limits and providing comprehensive error handling.
|
|
52
|
+
|
|
53
|
+
> **Developer Note**: This repository includes a [.clinerules](.clinerules) file that serves as a developer cheat sheet for your LLM coding agent with quick reference for the codebase patterns, file locations, and code snippets.
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
### Core Utilities
|
|
58
|
+
|
|
59
|
+
Leverages the robust utilities provided by the `mcp-ts-template`:
|
|
60
|
+
|
|
61
|
+
- **Logging**: Structured, configurable logging (file rotation, stdout JSON, MCP notifications) with sensitive data redaction.
|
|
62
|
+
- **Error Handling**: Centralized error processing, standardized error types (`McpError`), and automatic logging.
|
|
63
|
+
- **Configuration**: Environment variable loading (`dotenv`) with comprehensive validation.
|
|
64
|
+
- **Input Validation/Sanitization**: Uses `zod` for schema validation and custom sanitization logic.
|
|
65
|
+
- **Request Context**: Tracking and correlation of operations via unique request IDs using `AsyncLocalStorage`.
|
|
66
|
+
- **Type Safety**: Strong typing enforced by TypeScript and Zod schemas.
|
|
67
|
+
- **HTTP Transport**: High-performance HTTP server using **Hono**, featuring session management with garbage collection and CORS support.
|
|
68
|
+
- **Authentication**: Robust authentication layer supporting JWT and OAuth 2.1, with fine-grained scope enforcement.
|
|
69
|
+
- **Deployment**: Multi-stage `Dockerfile` for creating small, secure production images with native dependency support.
|
|
70
|
+
|
|
71
|
+
### PubChem Integration
|
|
72
|
+
|
|
73
|
+
- **PubChem PUG REST Integration**: Comprehensive access to the PubChem API via a dedicated, rate-limited client.
|
|
74
|
+
- **Advanced Search Capabilities**: Search by identifier, structure, similarity, and molecular formula.
|
|
75
|
+
- **Full Compound Data**: Retrieve complete compound properties, including physicochemical data, names, and identifiers.
|
|
76
|
+
- **Substance and Assay Information**: Fetch detailed records for substances (SIDs) and bioassays (AIDs).
|
|
77
|
+
- **Cross-Referencing**: Find links to other databases like PubMed, patent registries, and gene databases.
|
|
78
|
+
- **Image Generation**: Directly fetch 2D structural images of compounds.
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
### Prerequisites
|
|
83
|
+
|
|
84
|
+
- [Node.js (>=20.0.0)](https://nodejs.org/)
|
|
85
|
+
- [npm](https://www.npmjs.com/) (comes with Node.js)
|
|
86
|
+
- [Docker](https://www.docker.com/) (optional, for containerized deployment)
|
|
87
|
+
|
|
88
|
+
### Install via npm (recommended)
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install @cyanheads/pubchem-mcp-server
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Alternatively Install from Source
|
|
95
|
+
|
|
96
|
+
1. Clone the repository:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git clone https://github.com/cyanheads/pubchem-mcp-server.git
|
|
100
|
+
cd pubchem-mcp-server
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
2. Install dependencies:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm install
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
3. Build the project:
|
|
110
|
+
```bash
|
|
111
|
+
npm run build
|
|
112
|
+
*or npm run rebuild*
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
### Environment Variables
|
|
118
|
+
|
|
119
|
+
Configure the server using environment variables. These environmental variables are set within your MCP client config/settings (e.g. `cline_mcp_settings.json` for Cline).
|
|
120
|
+
|
|
121
|
+
| Variable | Description | Default |
|
|
122
|
+
| --------------------- | ---------------------------------------------------------------------------------------- | ----------- |
|
|
123
|
+
| `MCP_TRANSPORT_TYPE` | Transport mechanism: `stdio` or `http`. | `stdio` |
|
|
124
|
+
| `MCP_HTTP_PORT` | Port for the HTTP server (if `MCP_TRANSPORT_TYPE=http`). | `3010` |
|
|
125
|
+
| `MCP_HTTP_HOST` | Host address for the HTTP server (if `MCP_TRANSPORT_TYPE=http`). | `127.0.0.1` |
|
|
126
|
+
| `MCP_ALLOWED_ORIGINS` | Comma-separated list of allowed origins for CORS (if `MCP_TRANSPORT_TYPE=http`). | (none) |
|
|
127
|
+
| `MCP_LOG_LEVEL` | Logging level (`debug`, `info`, `notice`, `warning`, `error`, `crit`, `alert`, `emerg`). | `info` |
|
|
128
|
+
| `LOG_OUTPUT_MODE` | Logging output mode: `file` or `stdout`. | `file` |
|
|
129
|
+
| `MCP_AUTH_MODE` | Authentication mode for HTTP: `jwt` or `oauth`. | `jwt` |
|
|
130
|
+
| `MCP_AUTH_SECRET_KEY` | **Required for `jwt` auth.** Minimum 32-character secret key for JWT authentication. | (none) |
|
|
131
|
+
| `LOGS_DIR` | Directory for log file storage (if `LOG_OUTPUT_MODE=file`). | `logs/` |
|
|
132
|
+
|
|
133
|
+
**Note**: The PubChem API does not require an API key for basic use, so no key is needed in the environment configuration.
|
|
134
|
+
|
|
135
|
+
### MCP Client Settings
|
|
136
|
+
|
|
137
|
+
Add the following to your MCP client's configuration file (e.g., `cline_mcp_settings.json`). This configuration uses `npx` to run the server, which will automatically install the package if not already present:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"pubchem-mcp-server": {
|
|
143
|
+
"command": "npx",
|
|
144
|
+
"args": ["@cyanheads/pubchem-mcp-server"],
|
|
145
|
+
"env": {},
|
|
146
|
+
"disabled": false,
|
|
147
|
+
"autoApprove": []
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Project Structure
|
|
154
|
+
|
|
155
|
+
The codebase follows a modular structure within the `src/` directory:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
src/
|
|
159
|
+
├── index.ts # Entry point: Initializes and starts the server
|
|
160
|
+
├── config/ # Configuration loading (env vars, package info)
|
|
161
|
+
│ └── index.ts
|
|
162
|
+
├── mcp-server/ # Core MCP server logic and capability registration
|
|
163
|
+
│ ├── server.ts # Server setup, capability registration
|
|
164
|
+
│ ├── transports/ # Transport handling (stdio, http)
|
|
165
|
+
│ └── tools/ # MCP Tool implementations (subdirs per tool)
|
|
166
|
+
├── services/ # External service integrations
|
|
167
|
+
│ └── pubchem/ # PubChem API client
|
|
168
|
+
├── types-global/ # Shared TypeScript type definitions
|
|
169
|
+
└── utils/ # Common utility functions (logger, error handler, etc.)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
For a detailed file tree, run `npm run tree` or see [docs/tree.md](docs/tree.md).
|
|
173
|
+
|
|
174
|
+
## Tools
|
|
175
|
+
|
|
176
|
+
The PubChem MCP Server provides a comprehensive suite of tools for chemical information retrieval, callable via the Model Context Protocol.
|
|
177
|
+
|
|
178
|
+
| Tool Name | Description | Key Arguments |
|
|
179
|
+
| :--------------------------------------- | :---------------------------------------------------------------------- | :------------------------------------------------ |
|
|
180
|
+
| `pubchem_search_compound_by_identifier` | Searches for CIDs using a list of identifiers (name, SMILES, InChIKey). | `identifierType`, `identifiers` |
|
|
181
|
+
| `pubchem_fetch_compound_properties` | Fetches physicochemical properties for one or more CIDs. | `cids`, `properties` |
|
|
182
|
+
| `pubchem_get_compound_image` | Fetches a 2D structural image for a given CID. | `cid`, `size?` |
|
|
183
|
+
| `pubchem_search_compounds_by_structure` | Performs a structural search (substructure, superstructure, identity). | `searchType`, `query`, `queryType`, `maxRecords?` |
|
|
184
|
+
| `pubchem_search_compounds_by_similarity` | Finds compounds with a similar 2D structure to a query. | `query`, `queryType`, `threshold?`, `maxRecords?` |
|
|
185
|
+
| `pubchem_search_compounds_by_formula` | Finds CIDs that match a given molecular formula. | `formula`, `allowOtherElements?`, `maxRecords?` |
|
|
186
|
+
| `pubchem_fetch_substance_details` | Retrieves details for a given Substance ID (SID). | `sid` |
|
|
187
|
+
| `pubchem_fetch_assay_summary` | Fetches summaries for a list of up to 5 BioAssay IDs (AIDs). | `aids` |
|
|
188
|
+
| `pubchem_search_assays_by_target` | Finds BioAssay IDs (AIDs) associated with a biological target. | `targetType`, `targetQuery` |
|
|
189
|
+
| `pubchem_fetch_compound_xrefs` | Fetches external cross-references for a given CID. | `cid`, `xrefTypes`, `page?`, `pageSize?` |
|
|
190
|
+
|
|
191
|
+
_Note: All tools support comprehensive error handling and return structured JSON responses._
|
|
192
|
+
|
|
193
|
+
## Development
|
|
194
|
+
|
|
195
|
+
### Build and Test
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Build the project (compile TS to JS in dist/ and make executable)
|
|
199
|
+
npm run build
|
|
200
|
+
|
|
201
|
+
# Test the server locally using the MCP inspector tool (stdio transport)
|
|
202
|
+
npm run inspector
|
|
203
|
+
|
|
204
|
+
# Test the server locally using the MCP inspector tool (http transport)
|
|
205
|
+
npm run inspector:http
|
|
206
|
+
|
|
207
|
+
# Clean build artifacts
|
|
208
|
+
npm run clean
|
|
209
|
+
|
|
210
|
+
# Generate a file tree representation for documentation
|
|
211
|
+
npm run tree
|
|
212
|
+
|
|
213
|
+
# Clean build artifacts and then rebuild the project
|
|
214
|
+
npm run rebuild
|
|
215
|
+
|
|
216
|
+
# Format code with Prettier
|
|
217
|
+
npm run format
|
|
218
|
+
|
|
219
|
+
# Start the server using stdio (default)
|
|
220
|
+
npm start
|
|
221
|
+
# Or explicitly:
|
|
222
|
+
npm run start:stdio
|
|
223
|
+
|
|
224
|
+
# Start the server using HTTP transport
|
|
225
|
+
npm run start:http
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
<div align="center">
|
|
235
|
+
Built with the <a href="https://modelcontextprotocol.io/">Model Context Protocol</a>
|
|
236
|
+
</div>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Loads, validates, and exports application configuration.
|
|
3
|
+
* This module centralizes configuration management, sourcing values from
|
|
4
|
+
* environment variables and `package.json`. It uses Zod for schema validation
|
|
5
|
+
* to ensure type safety and correctness of configuration parameters.
|
|
6
|
+
*
|
|
7
|
+
* Key responsibilities:
|
|
8
|
+
* - Load environment variables from a `.env` file.
|
|
9
|
+
* - Read `package.json` for default server name and version.
|
|
10
|
+
* - Define a Zod schema for all expected environment variables.
|
|
11
|
+
* - Validate environment variables against the schema.
|
|
12
|
+
* - Construct and export a comprehensive `config` object.
|
|
13
|
+
* - Export individual configuration values like `logLevel` and `environment` for convenience.
|
|
14
|
+
*
|
|
15
|
+
* @module src/config/index
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Main application configuration object.
|
|
19
|
+
* Aggregates settings from validated environment variables and `package.json`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const config: {
|
|
22
|
+
/** Information from package.json. */
|
|
23
|
+
pkg: {
|
|
24
|
+
name: string;
|
|
25
|
+
version: string;
|
|
26
|
+
};
|
|
27
|
+
/** MCP server name. Env `MCP_SERVER_NAME` > `package.json` name > "mcp-ts-template". */
|
|
28
|
+
mcpServerName: string;
|
|
29
|
+
/** MCP server version. Env `MCP_SERVER_VERSION` > `package.json` version > "0.0.0". */
|
|
30
|
+
mcpServerVersion: string;
|
|
31
|
+
/** Logging level. From `MCP_LOG_LEVEL` env var. Default: "debug". */
|
|
32
|
+
logLevel: string;
|
|
33
|
+
/** Absolute path to the logs directory. From `LOGS_DIR` env var. */
|
|
34
|
+
logsPath: string;
|
|
35
|
+
/** Runtime environment. From `NODE_ENV` env var. Default: "development". */
|
|
36
|
+
environment: string;
|
|
37
|
+
/** MCP transport type ('stdio' or 'http'). From `MCP_TRANSPORT_TYPE` env var. Default: "stdio". */
|
|
38
|
+
mcpTransportType: "stdio" | "http";
|
|
39
|
+
/** HTTP server port (if http transport). From `MCP_HTTP_PORT` env var. Default: 3010. */
|
|
40
|
+
mcpHttpPort: number;
|
|
41
|
+
/** HTTP server host (if http transport). From `MCP_HTTP_HOST` env var. Default: "127.0.0.1". */
|
|
42
|
+
mcpHttpHost: string;
|
|
43
|
+
/** Array of allowed CORS origins (http transport). From `MCP_ALLOWED_ORIGINS` (comma-separated). */
|
|
44
|
+
mcpAllowedOrigins: string[] | undefined;
|
|
45
|
+
/** Auth secret key (JWTs, http transport). From `MCP_AUTH_SECRET_KEY`. CRITICAL. */
|
|
46
|
+
mcpAuthSecretKey: string | undefined;
|
|
47
|
+
/** The authentication mode ('jwt' or 'oauth'). From `MCP_AUTH_MODE`. */
|
|
48
|
+
mcpAuthMode: "jwt" | "oauth";
|
|
49
|
+
/** OAuth 2.1 Issuer URL. From `OAUTH_ISSUER_URL`. */
|
|
50
|
+
oauthIssuerUrl: string | undefined;
|
|
51
|
+
/** OAuth 2.1 JWKS URI. From `OAUTH_JWKS_URI`. */
|
|
52
|
+
oauthJwksUri: string | undefined;
|
|
53
|
+
/** OAuth 2.1 Audience. From `OAUTH_AUDIENCE`. */
|
|
54
|
+
oauthAudience: string | undefined;
|
|
55
|
+
/** OpenRouter App URL. From `OPENROUTER_APP_URL`. Default: "http://localhost:3000". */
|
|
56
|
+
openrouterAppUrl: string;
|
|
57
|
+
/** OpenRouter App Name. From `OPENROUTER_APP_NAME`. Defaults to `mcpServerName`. */
|
|
58
|
+
openrouterAppName: string;
|
|
59
|
+
/** OpenRouter API Key. From `OPENROUTER_API_KEY`. */
|
|
60
|
+
openrouterApiKey: string | undefined;
|
|
61
|
+
/** Default LLM model. From `LLM_DEFAULT_MODEL`. */
|
|
62
|
+
llmDefaultModel: string;
|
|
63
|
+
/** Default LLM temperature. From `LLM_DEFAULT_TEMPERATURE`. */
|
|
64
|
+
llmDefaultTemperature: number | undefined;
|
|
65
|
+
/** Default LLM top_p. From `LLM_DEFAULT_TOP_P`. */
|
|
66
|
+
llmDefaultTopP: number | undefined;
|
|
67
|
+
/** Default LLM max tokens. From `LLM_DEFAULT_MAX_TOKENS`. */
|
|
68
|
+
llmDefaultMaxTokens: number | undefined;
|
|
69
|
+
/** Default LLM top_k. From `LLM_DEFAULT_TOP_K`. */
|
|
70
|
+
llmDefaultTopK: number | undefined;
|
|
71
|
+
/** Default LLM min_p. From `LLM_DEFAULT_MIN_P`. */
|
|
72
|
+
llmDefaultMinP: number | undefined;
|
|
73
|
+
/** OAuth Proxy configurations. Undefined if no related env vars are set. */
|
|
74
|
+
oauthProxy: {
|
|
75
|
+
authorizationUrl: string | undefined;
|
|
76
|
+
tokenUrl: string | undefined;
|
|
77
|
+
revocationUrl: string | undefined;
|
|
78
|
+
issuerUrl: string | undefined;
|
|
79
|
+
serviceDocumentationUrl: string | undefined;
|
|
80
|
+
defaultClientRedirectUris: string[] | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
/** Supabase configuration. Undefined if no related env vars are set. */
|
|
83
|
+
supabase: {
|
|
84
|
+
url: string;
|
|
85
|
+
anonKey: string;
|
|
86
|
+
serviceRoleKey: string | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Configured logging level for the application.
|
|
91
|
+
* Exported for convenience.
|
|
92
|
+
*/
|
|
93
|
+
export declare const logLevel: string;
|
|
94
|
+
/**
|
|
95
|
+
* Configured runtime environment ("development", "production", etc.).
|
|
96
|
+
* Exported for convenience.
|
|
97
|
+
*/
|
|
98
|
+
export declare const environment: string;
|