@cyanheads/pubchem-mcp-server 0.1.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.
Files changed (51) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +198 -0
  3. package/dist/index.d.ts +8 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +16 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/mcp-server/tools/definitions/get-bioactivity.tool.d.ts +33 -0
  8. package/dist/mcp-server/tools/definitions/get-bioactivity.tool.d.ts.map +1 -0
  9. package/dist/mcp-server/tools/definitions/get-bioactivity.tool.js +115 -0
  10. package/dist/mcp-server/tools/definitions/get-bioactivity.tool.js.map +1 -0
  11. package/dist/mcp-server/tools/definitions/get-compound-details.tool.d.ts +22 -0
  12. package/dist/mcp-server/tools/definitions/get-compound-details.tool.d.ts.map +1 -0
  13. package/dist/mcp-server/tools/definitions/get-compound-details.tool.js +190 -0
  14. package/dist/mcp-server/tools/definitions/get-compound-details.tool.js.map +1 -0
  15. package/dist/mcp-server/tools/definitions/get-compound-image.tool.d.ts +19 -0
  16. package/dist/mcp-server/tools/definitions/get-compound-image.tool.d.ts.map +1 -0
  17. package/dist/mcp-server/tools/definitions/get-compound-image.tool.js +57 -0
  18. package/dist/mcp-server/tools/definitions/get-compound-image.tool.js.map +1 -0
  19. package/dist/mcp-server/tools/definitions/get-compound-safety.tool.d.ts +25 -0
  20. package/dist/mcp-server/tools/definitions/get-compound-safety.tool.d.ts.map +1 -0
  21. package/dist/mcp-server/tools/definitions/get-compound-safety.tool.js +94 -0
  22. package/dist/mcp-server/tools/definitions/get-compound-safety.tool.js.map +1 -0
  23. package/dist/mcp-server/tools/definitions/get-compound-xrefs.tool.d.ts +21 -0
  24. package/dist/mcp-server/tools/definitions/get-compound-xrefs.tool.d.ts.map +1 -0
  25. package/dist/mcp-server/tools/definitions/get-compound-xrefs.tool.js +90 -0
  26. package/dist/mcp-server/tools/definitions/get-compound-xrefs.tool.js.map +1 -0
  27. package/dist/mcp-server/tools/definitions/get-summary.tool.d.ts +23 -0
  28. package/dist/mcp-server/tools/definitions/get-summary.tool.d.ts.map +1 -0
  29. package/dist/mcp-server/tools/definitions/get-summary.tool.js +143 -0
  30. package/dist/mcp-server/tools/definitions/get-summary.tool.js.map +1 -0
  31. package/dist/mcp-server/tools/definitions/index.d.ts +152 -0
  32. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  33. package/dist/mcp-server/tools/definitions/index.js +23 -0
  34. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  35. package/dist/mcp-server/tools/definitions/search-assays.tool.d.ts +22 -0
  36. package/dist/mcp-server/tools/definitions/search-assays.tool.d.ts.map +1 -0
  37. package/dist/mcp-server/tools/definitions/search-assays.tool.js +76 -0
  38. package/dist/mcp-server/tools/definitions/search-assays.tool.js.map +1 -0
  39. package/dist/mcp-server/tools/definitions/search-compounds.tool.d.ts +42 -0
  40. package/dist/mcp-server/tools/definitions/search-compounds.tool.d.ts.map +1 -0
  41. package/dist/mcp-server/tools/definitions/search-compounds.tool.js +204 -0
  42. package/dist/mcp-server/tools/definitions/search-compounds.tool.js.map +1 -0
  43. package/dist/services/pubchem/pubchem-client.d.ts +37 -0
  44. package/dist/services/pubchem/pubchem-client.d.ts.map +1 -0
  45. package/dist/services/pubchem/pubchem-client.js +546 -0
  46. package/dist/services/pubchem/pubchem-client.js.map +1 -0
  47. package/dist/services/pubchem/types.d.ts +133 -0
  48. package/dist/services/pubchem/types.d.ts.map +1 -0
  49. package/dist/services/pubchem/types.js +68 -0
  50. package/dist/services/pubchem/types.js.map +1 -0
  51. package/package.json +67 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
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 the 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 the 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 any 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
+ Copyright 2025 Casey Hand (cyanheads)
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,198 @@
1
+ <div align="center">
2
+ <h1>pubchem-mcp-server</h1>
3
+ <p><b>MCP server for the PubChem chemical database. Search compounds, fetch properties, safety data, bioactivity, cross-references, and entity summaries. Runs over stdio or HTTP.</b></p>
4
+ </div>
5
+
6
+ <div align="center">
7
+
8
+ [![Version](https://img.shields.io/badge/Version-0.1.1-blue.svg?style=flat-square)](./CHANGELOG.md) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.27.1-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![TypeScript](https://img.shields.io/badge/TypeScript-^5.9.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-^1.2.0-f472b6.svg?style=flat-square)](https://bun.sh/)
9
+
10
+ </div>
11
+
12
+ ---
13
+
14
+ ## Tools
15
+
16
+ Eight tools for querying PubChem's chemical information database:
17
+
18
+ | Tool Name | Description |
19
+ |:----------|:------------|
20
+ | `pubchem_search_compounds` | Search for compounds by name, SMILES, InChIKey, formula, substructure, superstructure, or 2D similarity. |
21
+ | `pubchem_get_compound_details` | Get physicochemical properties, descriptions, and synonyms for compounds by CID. |
22
+ | `pubchem_get_compound_image` | Fetch a 2D structure diagram (PNG) for a compound by CID. |
23
+ | `pubchem_get_compound_safety` | Get GHS hazard classification and safety data for a compound. |
24
+ | `pubchem_get_compound_xrefs` | Get external database cross-references (PubMed, patents, genes, proteins, etc.). |
25
+ | `pubchem_get_bioactivity` | Get a compound's bioactivity profile: assay results, targets, and activity values. |
26
+ | `pubchem_search_assays` | Find bioassays by biological target (gene symbol, protein, Gene ID, UniProt accession). |
27
+ | `pubchem_get_summary` | Get summaries for PubChem entities: assays, genes, proteins, taxonomy. |
28
+
29
+ ### `pubchem_search_compounds`
30
+
31
+ Search PubChem for chemical compounds across five search modes.
32
+
33
+ - **Identifier lookup** — resolve compound names, SMILES, or InChIKeys to CIDs (batch up to 25)
34
+ - **Formula search** — find compounds by molecular formula in Hill notation
35
+ - **Substructure/superstructure** — find compounds containing or contained within a query structure
36
+ - **2D similarity** — find structurally similar compounds by Tanimoto similarity (configurable threshold)
37
+ - Optionally hydrate results with properties to avoid a follow-up details call
38
+
39
+ ---
40
+
41
+ ### `pubchem_get_compound_details`
42
+
43
+ Get detailed compound information by CID.
44
+
45
+ - Batches up to 100 CIDs in a single request
46
+ - 24 available properties: molecular weight, SMILES, InChIKey, XLogP, TPSA, complexity, stereo counts, and more
47
+ - Optionally includes textual descriptions (pharmacology, mechanism, therapeutic use) from PUG View
48
+ - Optionally includes all known synonyms (trade names, systematic names, registry numbers)
49
+
50
+ ---
51
+
52
+ ### `pubchem_get_bioactivity`
53
+
54
+ Get a compound's bioactivity profile from PubChem BioAssay.
55
+
56
+ - Returns assay outcomes (Active/Inactive/Inconclusive), target info (protein accessions, NCBI Gene IDs), and quantitative values (IC50, EC50, Ki)
57
+ - Filter by outcome to focus on active results
58
+ - Caps at 100 results per request (well-studied compounds may have thousands)
59
+
60
+ ---
61
+
62
+ ### `pubchem_get_summary`
63
+
64
+ Get descriptive summaries for four PubChem entity types.
65
+
66
+ - Assays (AID), genes (Gene ID), proteins (UniProt accession), taxonomy (Tax ID)
67
+ - Up to 10 entities per call
68
+ - Type-specific field extraction for clean, structured output
69
+
70
+ ## Features
71
+
72
+ Built on [`@cyanheads/mcp-ts-core`](https://github.com/cyanheads/mcp-ts-core):
73
+
74
+ - Declarative tool definitions — single file per tool, framework handles registration and validation
75
+ - Unified error handling across all tools
76
+ - Pluggable auth (`none`, `jwt`, `oauth`)
77
+ - Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`
78
+ - Structured logging with optional OpenTelemetry tracing
79
+ - Runs locally (stdio/HTTP) or containerized via Docker
80
+
81
+ PubChem-specific:
82
+
83
+ - Rate-limited client for PUG REST and PUG View APIs (5 req/s with automatic queuing)
84
+ - Retry with exponential backoff on 5xx errors and network failures
85
+ - All tools are read-only and idempotent — no API keys required
86
+
87
+ ## Getting Started
88
+
89
+ ### MCP Client Configuration
90
+
91
+ Add to your MCP client config (e.g., `claude_desktop_config.json`):
92
+
93
+ ```json
94
+ {
95
+ "mcpServers": {
96
+ "pubchem": {
97
+ "type": "stdio",
98
+ "command": "bunx",
99
+ "args": ["@cyanheads/pubchem-mcp-server@latest"],
100
+ "env": {
101
+ "MCP_TRANSPORT_TYPE": "stdio"
102
+ }
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ ### Prerequisites
109
+
110
+ - [Bun v1.2.0](https://bun.sh/) or higher (or Node.js v22+)
111
+
112
+ ### Installation
113
+
114
+ 1. **Clone the repository:**
115
+ ```sh
116
+ git clone https://github.com/cyanheads/pubchem-mcp-server.git
117
+ ```
118
+
119
+ 2. **Navigate into the directory:**
120
+ ```sh
121
+ cd pubchem-mcp-server
122
+ ```
123
+
124
+ 3. **Install dependencies:**
125
+ ```sh
126
+ bun install
127
+ ```
128
+
129
+ ## Configuration
130
+
131
+ No API keys are required — PubChem's API is freely accessible.
132
+
133
+ | Variable | Description | Default |
134
+ |:---------|:------------|:--------|
135
+ | `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
136
+ | `MCP_HTTP_PORT` | Port for HTTP server. | `3010` |
137
+ | `MCP_HTTP_HOST` | Host for HTTP server. | `localhost` |
138
+ | `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |
139
+ | `MCP_LOG_LEVEL` | Log level (RFC 5424). | `info` |
140
+ | `STORAGE_PROVIDER_TYPE` | Storage backend. | `in-memory` |
141
+ | `OTEL_ENABLED` | Enable OpenTelemetry. | `false` |
142
+
143
+ ## Running the Server
144
+
145
+ ### Local Development
146
+
147
+ - **Build and run the production version:**
148
+ ```sh
149
+ bun run build
150
+ bun run start:http # or start:stdio
151
+ ```
152
+
153
+ - **Run in dev mode (auto-reload):**
154
+ ```sh
155
+ bun run dev:stdio # or dev:http
156
+ ```
157
+
158
+ - **Run checks and tests:**
159
+ ```sh
160
+ bun run devcheck # Lints, formats, type-checks
161
+ bun run test # Runs test suite
162
+ ```
163
+
164
+ ### Docker
165
+
166
+ ```sh
167
+ docker build -t pubchem-mcp-server .
168
+ docker run -p 3010:3010 pubchem-mcp-server
169
+ ```
170
+
171
+ ## Project Structure
172
+
173
+ | Directory | Purpose |
174
+ |:----------|:--------|
175
+ | `src/mcp-server/tools/definitions/` | Tool definitions (`*.tool.ts`). |
176
+ | `src/services/pubchem/` | PubChem API client with rate limiting and response parsing. |
177
+ | `scripts/` | Build, clean, devcheck, and tree generation scripts. |
178
+
179
+ ## Development Guide
180
+
181
+ See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:
182
+
183
+ - Handlers throw, framework catches — no `try/catch` in tool logic
184
+ - Use `ctx.log` for domain-specific logging
185
+ - Register new tools in the `index.ts` barrel file
186
+
187
+ ## Contributing
188
+
189
+ Issues and pull requests are welcome. Run checks before submitting:
190
+
191
+ ```sh
192
+ bun run devcheck
193
+ bun run test
194
+ ```
195
+
196
+ ## License
197
+
198
+ Apache-2.0 — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview PubChem MCP server entry point. Provides read-only access to
4
+ * PubChem's chemical information database via PUG REST and PUG View APIs.
5
+ * @module index
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG"}
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview PubChem MCP server entry point. Provides read-only access to
4
+ * PubChem's chemical information database via PUG REST and PUG View APIs.
5
+ * @module index
6
+ */
7
+ import { createApp } from '@cyanheads/mcp-ts-core';
8
+ import { allToolDefinitions } from './mcp-server/tools/definitions/index.js';
9
+ import { initPubChemClient } from './services/pubchem/pubchem-client.js';
10
+ await createApp({
11
+ tools: allToolDefinitions,
12
+ setup() {
13
+ initPubChemClient();
14
+ },
15
+ });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,MAAM,SAAS,CAAC;IACd,KAAK,EAAE,kBAAkB;IACzB,KAAK;QACH,iBAAiB,EAAE,CAAC;IACtB,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @fileoverview Get a compound's bioactivity profile — which assays tested it,
3
+ * activity outcomes, target information, and quantitative values.
4
+ * @module mcp-server/tools/definitions/get-bioactivity
5
+ */
6
+ import { z } from '@cyanheads/mcp-ts-core';
7
+ export declare const getBioactivity: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
8
+ cid: z.ZodNumber;
9
+ outcomeFilter: z.ZodDefault<z.ZodEnum<{
10
+ active: "active";
11
+ inactive: "inactive";
12
+ all: "all";
13
+ }>>;
14
+ maxResults: z.ZodDefault<z.ZodNumber>;
15
+ }, z.core.$strip>, z.ZodObject<{
16
+ cid: z.ZodNumber;
17
+ totalAssays: z.ZodNumber;
18
+ activeCount: z.ZodNumber;
19
+ inactiveCount: z.ZodNumber;
20
+ results: z.ZodArray<z.ZodObject<{
21
+ aid: z.ZodNumber;
22
+ assayName: z.ZodString;
23
+ outcome: z.ZodString;
24
+ targetAccession: z.ZodOptional<z.ZodString>;
25
+ targetGeneId: z.ZodOptional<z.ZodNumber>;
26
+ activityValues: z.ZodArray<z.ZodObject<{
27
+ name: z.ZodString;
28
+ value: z.ZodNumber;
29
+ unit: z.ZodString;
30
+ }, z.core.$strip>>;
31
+ }, z.core.$strip>>;
32
+ }, z.core.$strip>>;
33
+ //# sourceMappingURL=get-bioactivity.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-bioactivity.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-bioactivity.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAGjD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;kBA2HzB,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @fileoverview Get a compound's bioactivity profile — which assays tested it,
3
+ * activity outcomes, target information, and quantitative values.
4
+ * @module mcp-server/tools/definitions/get-bioactivity
5
+ */
6
+ import { tool, z } from '@cyanheads/mcp-ts-core';
7
+ import { getPubChemClient } from '../../../services/pubchem/pubchem-client.js';
8
+ export const getBioactivity = tool('pubchem_get_bioactivity', {
9
+ title: 'Get Bioactivity',
10
+ description: "Get a compound's bioactivity profile: which assays tested it, activity outcomes " +
11
+ '(Active/Inactive/Inconclusive), target information (gene symbols, protein names), ' +
12
+ 'and quantitative values (IC50, EC50, Ki, etc.). Filter by outcome to focus on active results.',
13
+ annotations: {
14
+ readOnlyHint: true,
15
+ destructiveHint: false,
16
+ idempotentHint: true,
17
+ openWorldHint: true,
18
+ },
19
+ input: z.object({
20
+ cid: z.number().int().positive().describe('PubChem Compound ID.'),
21
+ outcomeFilter: z
22
+ .enum(['active', 'inactive', 'all'])
23
+ .default('all')
24
+ .describe('Filter by activity outcome. "active" shows only assays where the compound showed activity — ' +
25
+ 'most useful for understanding biological profile. Default: "all".'),
26
+ maxResults: z
27
+ .number()
28
+ .min(1)
29
+ .max(100)
30
+ .default(20)
31
+ .describe('Max assay results to return (1-100). Well-studied compounds have thousands of records. Default: 20.'),
32
+ }),
33
+ output: z.object({
34
+ cid: z.number().describe('PubChem Compound ID.'),
35
+ totalAssays: z.number().describe('Total unique assays for this compound.'),
36
+ activeCount: z.number().describe('Assays with "Active" outcome.'),
37
+ inactiveCount: z.number().describe('Assays with "Inactive" outcome.'),
38
+ results: z
39
+ .array(z.object({
40
+ aid: z.number().describe('PubChem Assay ID.'),
41
+ assayName: z.string().describe('Assay name/title.'),
42
+ outcome: z
43
+ .string()
44
+ .describe('Activity outcome: Active, Inactive, Inconclusive, Unspecified.'),
45
+ targetAccession: z
46
+ .string()
47
+ .optional()
48
+ .describe('Target protein accession (UniProt/GenBank).'),
49
+ targetGeneId: z.number().optional().describe('Target NCBI Gene ID.'),
50
+ activityValues: z
51
+ .array(z.object({
52
+ name: z.string().describe('Measurement name (e.g. IC50, EC50, Ki).'),
53
+ value: z.number().describe('Measured value.'),
54
+ unit: z.string().describe('Unit of measurement (e.g. uM, nM).'),
55
+ }))
56
+ .describe('Quantitative activity measurements.'),
57
+ }))
58
+ .describe('Assay results matching the filter.'),
59
+ }),
60
+ async handler(input, ctx) {
61
+ const client = getPubChemClient();
62
+ const allRows = await client.getAssaySummary(input.cid);
63
+ const activeCount = allRows.filter((r) => r.outcome === 'Active').length;
64
+ const inactiveCount = allRows.filter((r) => r.outcome === 'Inactive').length;
65
+ // Filter by outcome
66
+ let filtered = allRows;
67
+ if (input.outcomeFilter === 'active') {
68
+ filtered = allRows.filter((r) => r.outcome === 'Active');
69
+ }
70
+ else if (input.outcomeFilter === 'inactive') {
71
+ filtered = allRows.filter((r) => r.outcome === 'Inactive');
72
+ }
73
+ const results = filtered.slice(0, input.maxResults);
74
+ ctx.log.info('Bioactivity fetched', {
75
+ cid: input.cid,
76
+ total: allRows.length,
77
+ active: activeCount,
78
+ returned: results.length,
79
+ });
80
+ return {
81
+ cid: input.cid,
82
+ totalAssays: allRows.length,
83
+ activeCount,
84
+ inactiveCount,
85
+ results,
86
+ };
87
+ },
88
+ format(result) {
89
+ const lines = [
90
+ `## Bioactivity — CID ${result.cid}`,
91
+ `Total assays: ${result.totalAssays} | Active: ${result.activeCount} | Inactive: ${result.inactiveCount}`,
92
+ '',
93
+ ];
94
+ if (result.results.length === 0) {
95
+ lines.push('No matching assay results.');
96
+ return [{ type: 'text', text: lines.join('\n') }];
97
+ }
98
+ for (const r of result.results) {
99
+ const target = [r.targetGeneId ? `GeneID:${r.targetGeneId}` : undefined, r.targetAccession]
100
+ .filter(Boolean)
101
+ .join(' — ');
102
+ lines.push(`**AID ${r.aid}** — ${r.assayName} (${r.outcome})`);
103
+ if (target)
104
+ lines.push(` Target: ${target}`);
105
+ if (r.activityValues.length > 0) {
106
+ for (const av of r.activityValues) {
107
+ lines.push(` ${av.name}: ${av.value} ${av.unit}`);
108
+ }
109
+ }
110
+ lines.push('');
111
+ }
112
+ return [{ type: 'text', text: lines.join('\n') }];
113
+ },
114
+ });
115
+ //# sourceMappingURL=get-bioactivity.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-bioactivity.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-bioactivity.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,yBAAyB,EAAE;IAC5D,KAAK,EAAE,iBAAiB;IACxB,WAAW,EACT,kFAAkF;QAClF,oFAAoF;QACpF,+FAA+F;IACjG,WAAW,EAAE;QACX,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACjE,aAAa,EAAE,CAAC;aACb,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;aACnC,OAAO,CAAC,KAAK,CAAC;aACd,QAAQ,CACP,8FAA8F;YAC5F,mEAAmE,CACtE;QACH,UAAU,EAAE,CAAC;aACV,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,GAAG,CAAC;aACR,OAAO,CAAC,EAAE,CAAC;aACX,QAAQ,CACP,qGAAqG,CACtG;KACJ,C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EAAE,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;QAED,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @fileoverview Get detailed compound information: physicochemical properties,
3
+ * textual descriptions, and/or synonyms for one or more CIDs.
4
+ * @module mcp-server/tools/definitions/get-compound-details
5
+ */
6
+ import { z } from '@cyanheads/mcp-ts-core';
7
+ export declare const getCompoundDetails: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
8
+ cids: z.ZodArray<z.ZodNumber>;
9
+ properties: z.ZodOptional<z.ZodArray<z.ZodEnum<{
10
+ [x: string]: string;
11
+ }>>>;
12
+ includeDescription: z.ZodDefault<z.ZodBoolean>;
13
+ includeSynonyms: z.ZodDefault<z.ZodBoolean>;
14
+ }, z.core.$strip>, z.ZodObject<{
15
+ compounds: z.ZodArray<z.ZodObject<{
16
+ cid: z.ZodNumber;
17
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
18
+ description: z.ZodOptional<z.ZodString>;
19
+ synonyms: z.ZodOptional<z.ZodArray<z.ZodString>>;
20
+ }, z.core.$strip>>;
21
+ }, z.core.$strip>>;
22
+ //# sourceMappingURL=get-compound-details.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-compound-details.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-compound-details.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAMjD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;kBA2M7B,CAAC"}