@cyanheads/pubchem-mcp-server 0.1.23 → 0.2.0

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 (65) hide show
  1. package/README.md +43 -8
  2. package/dist/index.js +3 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/mcp-server/resources/definitions/assay.resource.d.ts +9 -0
  5. package/dist/mcp-server/resources/definitions/assay.resource.d.ts.map +1 -0
  6. package/dist/mcp-server/resources/definitions/assay.resource.js +24 -0
  7. package/dist/mcp-server/resources/definitions/assay.resource.js.map +1 -0
  8. package/dist/mcp-server/resources/definitions/compound-bioactivity.resource.d.ts +9 -0
  9. package/dist/mcp-server/resources/definitions/compound-bioactivity.resource.d.ts.map +1 -0
  10. package/dist/mcp-server/resources/definitions/compound-bioactivity.resource.js +28 -0
  11. package/dist/mcp-server/resources/definitions/compound-bioactivity.resource.js.map +1 -0
  12. package/dist/mcp-server/resources/definitions/compound-image.resource.d.ts +11 -0
  13. package/dist/mcp-server/resources/definitions/compound-image.resource.d.ts.map +1 -0
  14. package/dist/mcp-server/resources/definitions/compound-image.resource.js +28 -0
  15. package/dist/mcp-server/resources/definitions/compound-image.resource.js.map +1 -0
  16. package/dist/mcp-server/resources/definitions/compound-safety.resource.d.ts +9 -0
  17. package/dist/mcp-server/resources/definitions/compound-safety.resource.d.ts.map +1 -0
  18. package/dist/mcp-server/resources/definitions/compound-safety.resource.js +32 -0
  19. package/dist/mcp-server/resources/definitions/compound-safety.resource.js.map +1 -0
  20. package/dist/mcp-server/resources/definitions/compound-xrefs.resource.d.ts +9 -0
  21. package/dist/mcp-server/resources/definitions/compound-xrefs.resource.d.ts.map +1 -0
  22. package/dist/mcp-server/resources/definitions/compound-xrefs.resource.js +29 -0
  23. package/dist/mcp-server/resources/definitions/compound-xrefs.resource.js.map +1 -0
  24. package/dist/mcp-server/resources/definitions/compound.resource.d.ts +9 -0
  25. package/dist/mcp-server/resources/definitions/compound.resource.d.ts.map +1 -0
  26. package/dist/mcp-server/resources/definitions/compound.resource.js +28 -0
  27. package/dist/mcp-server/resources/definitions/compound.resource.js.map +1 -0
  28. package/dist/mcp-server/resources/definitions/index.d.ts +14 -0
  29. package/dist/mcp-server/resources/definitions/index.d.ts.map +1 -0
  30. package/dist/mcp-server/resources/definitions/index.js +19 -0
  31. package/dist/mcp-server/resources/definitions/index.js.map +1 -0
  32. package/dist/mcp-server/tools/definitions/get-bioactivity.tool.d.ts +3 -0
  33. package/dist/mcp-server/tools/definitions/get-bioactivity.tool.d.ts.map +1 -1
  34. package/dist/mcp-server/tools/definitions/get-bioactivity.tool.js +38 -6
  35. package/dist/mcp-server/tools/definitions/get-bioactivity.tool.js.map +1 -1
  36. package/dist/mcp-server/tools/definitions/get-compound-3d-structure.tool.d.ts +38 -0
  37. package/dist/mcp-server/tools/definitions/get-compound-3d-structure.tool.d.ts.map +1 -0
  38. package/dist/mcp-server/tools/definitions/get-compound-3d-structure.tool.js +133 -0
  39. package/dist/mcp-server/tools/definitions/get-compound-3d-structure.tool.js.map +1 -0
  40. package/dist/mcp-server/tools/definitions/get-compound-interactions.tool.d.ts +32 -0
  41. package/dist/mcp-server/tools/definitions/get-compound-interactions.tool.d.ts.map +1 -0
  42. package/dist/mcp-server/tools/definitions/get-compound-interactions.tool.js +92 -0
  43. package/dist/mcp-server/tools/definitions/get-compound-interactions.tool.js.map +1 -0
  44. package/dist/mcp-server/tools/definitions/get-compound-safety.tool.d.ts +19 -15
  45. package/dist/mcp-server/tools/definitions/get-compound-safety.tool.d.ts.map +1 -1
  46. package/dist/mcp-server/tools/definitions/get-compound-safety.tool.js +106 -73
  47. package/dist/mcp-server/tools/definitions/get-compound-safety.tool.js.map +1 -1
  48. package/dist/mcp-server/tools/definitions/index.d.ts +74 -12
  49. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  50. package/dist/mcp-server/tools/definitions/index.js +4 -0
  51. package/dist/mcp-server/tools/definitions/index.js.map +1 -1
  52. package/dist/services/pubchem/pubchem-client.d.ts +20 -1
  53. package/dist/services/pubchem/pubchem-client.d.ts.map +1 -1
  54. package/dist/services/pubchem/pubchem-client.js +158 -0
  55. package/dist/services/pubchem/pubchem-client.js.map +1 -1
  56. package/dist/services/pubchem/sdf-parser.d.ts +20 -0
  57. package/dist/services/pubchem/sdf-parser.d.ts.map +1 -0
  58. package/dist/services/pubchem/sdf-parser.js +55 -0
  59. package/dist/services/pubchem/sdf-parser.js.map +1 -0
  60. package/dist/services/pubchem/types.d.ts +44 -0
  61. package/dist/services/pubchem/types.d.ts.map +1 -1
  62. package/dist/services/pubchem/types.js.map +1 -1
  63. package/manifest.json +1 -1
  64. package/package.json +1 -1
  65. package/server.json +3 -3
@@ -1 +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,6QAA6Q;IAC/Q,WAAW,EAAE;QACX,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,CAAC;aACH,MAAM,EAAE;aACR,GAAG,EAAE;aACL,QAAQ,EAAE;aACV,QAAQ,CAAC,8EAA8E,CAAC;QAC3F,aAAa,EAAE,CAAC;aACb,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;aACnC,OAAO,CAAC,KAAK,CAAC;aACd,QAAQ,CACP,+JAA+J,CAChK;QACH,UAAU,EAAE,CAAC;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C,EAAE,EAAE,CAAC,CAAC;YACjE,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"}
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,kYAAkY;IACpY,WAAW,EAAE;QACX,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,CAAC;aACH,MAAM,EAAE;aACR,GAAG,EAAE;aACL,QAAQ,EAAE;aACV,QAAQ,CAAC,8EAA8E,CAAC;QAC3F,aAAa,EAAE,CAAC;aACb,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;aACnC,OAAO,CAAC,KAAK,CAAC;aACd,QAAQ,CACP,+JAA+J,CAChK;QACH,YAAY,EAAE,CAAC;aACZ,MAAM,EAAE;aACR,GAAG,EAAE;aACL,QAAQ,EAAE;aACV,QAAQ,EAAE;aACV,QAAQ,CACP,2OAA2O,CAC5O;QACH,eAAe,EAAE,CAAC;aACf,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,kMAAkM,CACnM;QACH,UAAU,EAAE,CAAC;aACV,MA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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,38 @@
1
+ /**
2
+ * @fileoverview Fetch the 3D conformer (atomic coordinates + bonds) for a PubChem compound.
3
+ * @module mcp-server/tools/definitions/get-compound-3d-structure
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ export declare const getCompound3dStructure: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
8
+ cid: z.ZodNumber;
9
+ format: z.ZodDefault<z.ZodEnum<{
10
+ sdf: "sdf";
11
+ json: "json";
12
+ }>>;
13
+ includeAlternateConformerIds: z.ZodDefault<z.ZodBoolean>;
14
+ }, z.core.$strip>, z.ZodObject<{
15
+ cid: z.ZodNumber;
16
+ conformerId: z.ZodOptional<z.ZodString>;
17
+ atomCount: z.ZodNumber;
18
+ bondCount: z.ZodNumber;
19
+ atoms: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
+ element: z.ZodString;
21
+ x: z.ZodNumber;
22
+ y: z.ZodNumber;
23
+ z: z.ZodNumber;
24
+ }, z.core.$strip>>>;
25
+ bonds: z.ZodOptional<z.ZodArray<z.ZodObject<{
26
+ a1: z.ZodNumber;
27
+ a2: z.ZodNumber;
28
+ order: z.ZodNumber;
29
+ }, z.core.$strip>>>;
30
+ sdf: z.ZodOptional<z.ZodString>;
31
+ alternateConformerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
32
+ }, z.core.$strip>, readonly [{
33
+ readonly reason: "no_3d_structure";
34
+ readonly code: JsonRpcErrorCode.NotFound;
35
+ readonly when: "PubChem has no computed 3D conformer for the requested CID";
36
+ readonly recovery: "Use pubchem_get_compound_image for the 2D structure, or verify the CID with pubchem_search_compounds.";
37
+ }], undefined>;
38
+ //# sourceMappingURL=get-compound-3d-structure.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-compound-3d-structure.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-compound-3d-structure.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAIjE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4JjC,CAAC"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @fileoverview Fetch the 3D conformer (atomic coordinates + bonds) for a PubChem compound.
3
+ * @module mcp-server/tools/definitions/get-compound-3d-structure
4
+ */
5
+ import { tool, z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ import { getPubChemClient } from '../../../services/pubchem/pubchem-client.js';
8
+ import { parseSdfV2000 } from '../../../services/pubchem/sdf-parser.js';
9
+ export const getCompound3dStructure = tool('pubchem_get_compound_3d_structure', {
10
+ title: 'Get Compound 3D Structure',
11
+ description: 'Get a compound\'s default 3D conformer — atomic coordinates and bonds — for one CID. format="json" (default) returns parsed atoms and bonds the model can reason over directly; format="sdf" returns the raw V2000 SDF text for passthrough to docking, rendering, or conformer tools. Optionally lists alternate conformer IDs. Not every compound has computed 3D coordinates (large molecules, mixtures, and some salts do not).',
12
+ annotations: {
13
+ readOnlyHint: true,
14
+ idempotentHint: true,
15
+ openWorldHint: true,
16
+ },
17
+ input: z.object({
18
+ cid: z
19
+ .number()
20
+ .int()
21
+ .positive()
22
+ .describe('PubChem Compound ID. Resolve from name/SMILES with pubchem_search_compounds.'),
23
+ format: z
24
+ .enum(['sdf', 'json'])
25
+ .default('json')
26
+ .describe('Output format. "json" (default) returns parsed atoms and bonds. "sdf" returns the raw V2000 SDF text for passthrough to other tools.'),
27
+ includeAlternateConformerIds: z
28
+ .boolean()
29
+ .default(false)
30
+ .describe('List the IDs of additional computed conformers beyond the default. Adds one extra API call. Default: false.'),
31
+ }),
32
+ output: z.object({
33
+ cid: z.number().describe('PubChem Compound ID.'),
34
+ conformerId: z
35
+ .string()
36
+ .optional()
37
+ .describe('Default (primary) conformer ID. Present when includeAlternateConformerIds is set.'),
38
+ atomCount: z.number().describe('Number of atoms in the conformer.'),
39
+ bondCount: z.number().describe('Number of bonds in the conformer.'),
40
+ atoms: z
41
+ .array(z
42
+ .object({
43
+ element: z.string().describe('Element symbol (e.g. "C", "O", "N").'),
44
+ x: z.number().describe('X coordinate (Angstroms).'),
45
+ y: z.number().describe('Y coordinate (Angstroms).'),
46
+ z: z.number().describe('Z coordinate (Angstroms).'),
47
+ })
48
+ .describe('Atom with 3D Cartesian coordinates.'))
49
+ .optional()
50
+ .describe('Parsed atoms. Populated when format="json".'),
51
+ bonds: z
52
+ .array(z
53
+ .object({
54
+ a1: z.number().describe('First atom index (1-based).'),
55
+ a2: z.number().describe('Second atom index (1-based).'),
56
+ order: z.number().describe('Bond order (1=single, 2=double, 3=triple, 4=aromatic).'),
57
+ })
58
+ .describe('Bond between two atoms.'))
59
+ .optional()
60
+ .describe('Parsed bonds. Populated when format="json".'),
61
+ sdf: z.string().optional().describe('Raw V2000 SDF text. Populated when format="sdf".'),
62
+ alternateConformerIds: z
63
+ .array(z.string())
64
+ .optional()
65
+ .describe('Conformer IDs beyond the default. Present when includeAlternateConformerIds is set and alternates exist.'),
66
+ }),
67
+ errors: [
68
+ {
69
+ reason: 'no_3d_structure',
70
+ code: JsonRpcErrorCode.NotFound,
71
+ when: 'PubChem has no computed 3D conformer for the requested CID',
72
+ recovery: 'Use pubchem_get_compound_image for the 2D structure, or verify the CID with pubchem_search_compounds.',
73
+ },
74
+ ],
75
+ async handler(input, ctx) {
76
+ const client = getPubChemClient();
77
+ // getSdf3d throws a typed no_3d_structure not-found when PubChem has no 3D record.
78
+ const sdf = await client.getSdf3d(input.cid);
79
+ const parsed = parseSdfV2000(sdf);
80
+ const out = { cid: input.cid, atomCount: parsed.atomCount, bondCount: parsed.bondCount };
81
+ if (input.format === 'json') {
82
+ out.atoms = parsed.atoms;
83
+ out.bonds = parsed.bonds;
84
+ }
85
+ else {
86
+ out.sdf = sdf;
87
+ }
88
+ if (input.includeAlternateConformerIds) {
89
+ const ids = await client.getConformerIds(input.cid);
90
+ if (ids[0]) {
91
+ out.conformerId = ids[0];
92
+ const alternates = ids.slice(1);
93
+ if (alternates.length > 0)
94
+ out.alternateConformerIds = alternates;
95
+ }
96
+ }
97
+ ctx.log.info('3D structure fetched', {
98
+ cid: input.cid,
99
+ format: input.format,
100
+ atoms: parsed.atomCount,
101
+ bonds: parsed.bondCount,
102
+ });
103
+ return out;
104
+ },
105
+ format(result) {
106
+ const lines = [
107
+ `## 3D Structure — CID ${result.cid}`,
108
+ `Atoms: ${result.atomCount} | Bonds: ${result.bondCount}`,
109
+ ];
110
+ if (result.conformerId)
111
+ lines.push(`Default conformer: ${result.conformerId}`);
112
+ if (result.alternateConformerIds && result.alternateConformerIds.length > 0) {
113
+ lines.push(`Alternate conformers: ${result.alternateConformerIds.join(', ')}`);
114
+ }
115
+ if (result.atoms && result.atoms.length > 0) {
116
+ lines.push('', '**Atoms** (element: x, y, z):');
117
+ for (const a of result.atoms) {
118
+ lines.push(` ${a.element}: ${a.x}, ${a.y}, ${a.z}`);
119
+ }
120
+ }
121
+ if (result.bonds && result.bonds.length > 0) {
122
+ lines.push('', '**Bonds** (a1–a2, order):');
123
+ for (const b of result.bonds) {
124
+ lines.push(` ${b.a1}–${b.a2}, order ${b.order}`);
125
+ }
126
+ }
127
+ if (result.sdf) {
128
+ lines.push('', '**SDF (V2000):**', '```', result.sdf.trimEnd(), '```');
129
+ }
130
+ return [{ type: 'text', text: lines.join('\n') }];
131
+ },
132
+ });
133
+ //# sourceMappingURL=get-compound-3d-structure.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-compound-3d-structure.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-compound-3d-structure.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,mCAAmC,EAAE;IAC9E,KAAK,EAAE,2BAA2B;IAClC,WAAW,EACT,qaAAqa;IACva,WAAW,EAAE;QACX,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,CAAC;aACH,MAAM,EAAE;aACR,GAAG,EAAE;aACL,QAAQ,EAAE;aACV,QAAQ,CAAC,8EAA8E,CAAC;QAC3F,MAAM,EAAE,CAAC;aACN,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;aACrB,OAAO,CAAC,MAAM,CAAC;aACf,QAAQ,CACP,sIAAsI,CACvI;QACH,4BAA4B,EAAE,CAAC;aAC5B,OAAO,EAAE;aACT,OAAO,CAAC,KAAK,CAAC;aACd,QAAQ,CACP,6GAA6G,CAC9G;KACJ,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QAChD,WAAW,EAAE,CAAC;aACX,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,mFAAmF,CACpF;QACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;QACnE,SAAS,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AK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;QACzE,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,32 @@
1
+ /**
2
+ * @fileoverview Get drug-drug, drug-food, and chemical-target interactions for a compound.
3
+ * @module mcp-server/tools/definitions/get-compound-interactions
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ export declare const getCompoundInteractions: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
7
+ cid: z.ZodNumber;
8
+ kinds: z.ZodDefault<z.ZodArray<z.ZodEnum<{
9
+ "drug-drug": "drug-drug";
10
+ "drug-food": "drug-food";
11
+ target: "target";
12
+ }>>>;
13
+ maxEntries: z.ZodDefault<z.ZodNumber>;
14
+ }, z.core.$strip>, z.ZodObject<{
15
+ cid: z.ZodNumber;
16
+ entries: z.ZodArray<z.ZodObject<{
17
+ kind: z.ZodEnum<{
18
+ "drug-drug": "drug-drug";
19
+ "drug-food": "drug-food";
20
+ target: "target";
21
+ }>;
22
+ partner: z.ZodOptional<z.ZodString>;
23
+ source: z.ZodString;
24
+ severity: z.ZodOptional<z.ZodString>;
25
+ text: z.ZodString;
26
+ }, z.core.$strip>>;
27
+ }, z.core.$strip>, undefined, {
28
+ readonly requestedKinds: z.ZodString;
29
+ readonly returnedCount: z.ZodNumber;
30
+ readonly notice: z.ZodOptional<z.ZodString>;
31
+ }>;
32
+ //# sourceMappingURL=get-compound-interactions.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-compound-interactions.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-compound-interactions.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAGjD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;EAuGlC,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @fileoverview Get drug-drug, drug-food, and chemical-target interactions for a compound.
3
+ * @module mcp-server/tools/definitions/get-compound-interactions
4
+ */
5
+ import { tool, z } from '@cyanheads/mcp-ts-core';
6
+ import { getPubChemClient } from '../../../services/pubchem/pubchem-client.js';
7
+ export const getCompoundInteractions = tool('pubchem_get_compound_interactions', {
8
+ title: 'Get Compound Interactions',
9
+ description: "Get a compound's interaction data: drug-drug interactions (DrugBank), drug-food interactions, and chemical-target interactions (binding/activity from BindingDB, ChEMBL, and others). Each entry carries its originating source. Richest for approved drugs; many compounds have no deposited interaction records.",
10
+ annotations: {
11
+ readOnlyHint: true,
12
+ idempotentHint: true,
13
+ openWorldHint: true,
14
+ },
15
+ input: z.object({
16
+ cid: z
17
+ .number()
18
+ .int()
19
+ .positive()
20
+ .describe('PubChem Compound ID. Resolve from name/SMILES with pubchem_search_compounds.'),
21
+ kinds: z
22
+ .array(z.enum(['drug-drug', 'drug-food', 'target']))
23
+ .min(1)
24
+ .default(['drug-drug'])
25
+ .describe('Interaction kinds to fetch. "drug-drug" (interactions with other drugs), "drug-food" (dietary interactions), "target" (binding/activity against molecular targets). Default: ["drug-drug"].'),
26
+ maxEntries: z
27
+ .number()
28
+ .int()
29
+ .min(1)
30
+ .max(50)
31
+ .default(10)
32
+ .describe('Max entries per kind (1-50). Well-studied drugs have a long tail of interactions. Default: 10.'),
33
+ }),
34
+ output: z.object({
35
+ cid: z.number().describe('PubChem Compound ID.'),
36
+ entries: z
37
+ .array(z
38
+ .object({
39
+ kind: z.enum(['drug-drug', 'drug-food', 'target']).describe('Interaction category.'),
40
+ partner: z
41
+ .string()
42
+ .optional()
43
+ .describe('Interacting compound, food, or target name as the source reports it.'),
44
+ source: z.string().describe('Originating source (e.g. "DrugBank", "BindingDB").'),
45
+ severity: z
46
+ .string()
47
+ .optional()
48
+ .describe('Raw severity as the source reports it — not normalized across sources, and frequently unset (most sources embed severity in the statement text).'),
49
+ text: z.string().describe('The interaction statement.'),
50
+ })
51
+ .describe('A single interaction entry.'))
52
+ .describe('Interaction entries across the requested kinds.'),
53
+ }),
54
+ // Agent-facing context — kind echo, total returned, and an empty-result notice.
55
+ // Reaches structuredContent and content[]; keys disjoint from output (cid/entries).
56
+ enrichment: {
57
+ requestedKinds: z.string().describe('Interaction kinds requested (comma-separated).'),
58
+ returnedCount: z.number().describe('Total interaction entries returned across all kinds.'),
59
+ notice: z
60
+ .string()
61
+ .optional()
62
+ .describe('Guidance when no interaction data was found for the requested kinds.'),
63
+ },
64
+ async handler(input, ctx) {
65
+ const client = getPubChemClient();
66
+ const entries = await client.getInteractions(input.cid, input.kinds, input.maxEntries);
67
+ ctx.log.info('Interactions fetched', {
68
+ cid: input.cid,
69
+ kinds: input.kinds,
70
+ returned: entries.length,
71
+ });
72
+ ctx.enrich({ requestedKinds: input.kinds.join(', '), returnedCount: entries.length });
73
+ if (entries.length === 0) {
74
+ ctx.enrich.notice(`No ${input.kinds.join('/')} interaction data found for CID ${input.cid}. PubChem has no deposited interaction records for this compound — coverage is richest for approved drugs.`);
75
+ }
76
+ return { cid: input.cid, entries };
77
+ },
78
+ format(result) {
79
+ const lines = [`## Interactions — CID ${result.cid}`, ''];
80
+ if (result.entries.length === 0) {
81
+ lines.push('No interaction data found.');
82
+ return [{ type: 'text', text: lines.join('\n') }];
83
+ }
84
+ for (const e of result.entries) {
85
+ const partner = e.partner ? ` **${e.partner}**` : '';
86
+ const severity = e.severity ? ` [severity: ${e.severity}]` : '';
87
+ lines.push(`- (${e.kind})${partner}${severity} ${e.text} _(source: ${e.source})_`);
88
+ }
89
+ return [{ type: 'text', text: lines.join('\n') }];
90
+ },
91
+ });
92
+ //# sourceMappingURL=get-compound-interactions.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-compound-interactions.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-compound-interactions.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC,mCAAmC,EAAE;IAC/E,KAAK,EAAE,2BAA2B;IAClC,WAAW,EACT,oTAAoT;IACtT,WAAW,EAAE;QACX,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,CAAC;aACH,MAAM,EAAE;aACR,GAAG,EAAE;aACL,QAAQ,EAAE;aACV,QAAQ,CAAC,8EAA8E,CAAC;QAC3F,KAAK,EAAE,CAAC;aACL,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;aACnD,GAAG,CAAC,CAAC,CAAC;aACN,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;aACtB,QAAQ,CACP,6LAA6L,CAC9L;QACH,UAAU,EAAE,CAAC;aACV,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,EAAE,CAAC;aACP,OAAO,CAAC,EAAE,CAAC;aACX,QAAQ,CACP,gGAAgG,CACjG;KACJ,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,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C,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,IAAI,OAAO,GAAG,QAAQ,IAAI,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;QACrF,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"}
@@ -1,27 +1,31 @@
1
1
  /**
2
- * @fileoverview Get GHS hazard classification and safety data for a PubChem compound.
2
+ * @fileoverview Get GHS hazard classification and safety data for PubChem compounds (batched).
3
3
  * @module mcp-server/tools/definitions/get-compound-safety
4
4
  */
5
5
  import { z } from '@cyanheads/mcp-ts-core';
6
6
  export declare const getCompoundSafety: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
7
- cid: z.ZodNumber;
7
+ cids: z.ZodArray<z.ZodNumber>;
8
8
  }, z.core.$strip>, z.ZodObject<{
9
- cid: z.ZodNumber;
10
- hasData: z.ZodBoolean;
11
- ghs: z.ZodOptional<z.ZodObject<{
12
- signalWord: z.ZodOptional<z.ZodString>;
13
- pictograms: z.ZodArray<z.ZodString>;
14
- hazardStatements: z.ZodArray<z.ZodObject<{
15
- code: z.ZodString;
16
- statement: z.ZodString;
17
- }, z.core.$strip>>;
18
- precautionaryStatements: z.ZodArray<z.ZodObject<{
19
- code: z.ZodString;
20
- statement: z.ZodString;
9
+ results: z.ZodArray<z.ZodObject<{
10
+ cid: z.ZodNumber;
11
+ hasData: z.ZodBoolean;
12
+ ghs: z.ZodOptional<z.ZodObject<{
13
+ signalWord: z.ZodOptional<z.ZodString>;
14
+ pictograms: z.ZodArray<z.ZodString>;
15
+ hazardStatements: z.ZodArray<z.ZodObject<{
16
+ code: z.ZodString;
17
+ statement: z.ZodString;
18
+ }, z.core.$strip>>;
19
+ precautionaryStatements: z.ZodArray<z.ZodObject<{
20
+ code: z.ZodString;
21
+ statement: z.ZodString;
22
+ }, z.core.$strip>>;
21
23
  }, z.core.$strip>>;
24
+ source: z.ZodOptional<z.ZodString>;
22
25
  }, z.core.$strip>>;
23
- source: z.ZodOptional<z.ZodString>;
24
26
  }, z.core.$strip>, undefined, {
27
+ readonly requestedCount: z.ZodNumber;
28
+ readonly withDataCount: z.ZodNumber;
25
29
  readonly notice: z.ZodOptional<z.ZodString>;
26
30
  }>;
27
31
  //# sourceMappingURL=get-compound-safety.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-compound-safety.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-compound-safety.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAGjD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;EAsH5B,CAAC"}
1
+ {"version":3,"file":"get-compound-safety.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-compound-safety.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAkCjD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;EAiI5B,CAAC"}
@@ -1,108 +1,141 @@
1
1
  /**
2
- * @fileoverview Get GHS hazard classification and safety data for a PubChem compound.
2
+ * @fileoverview Get GHS hazard classification and safety data for PubChem compounds (batched).
3
3
  * @module mcp-server/tools/definitions/get-compound-safety
4
4
  */
5
5
  import { tool, z } from '@cyanheads/mcp-ts-core';
6
6
  import { getPubChemClient } from '../../../services/pubchem/pubchem-client.js';
7
+ const ghsSchema = z
8
+ .object({
9
+ signalWord: z.string().optional().describe('GHS signal word: "Danger" or "Warning".'),
10
+ pictograms: z.array(z.string()).describe('GHS pictogram labels (e.g. "Flammable", "Toxic").'),
11
+ hazardStatements: z
12
+ .array(z
13
+ .object({
14
+ code: z.string().describe('H-code (e.g. "H225").'),
15
+ statement: z.string().describe('Hazard statement text.'),
16
+ })
17
+ .describe('GHS hazard statement entry.'))
18
+ .describe('GHS hazard statements.'),
19
+ precautionaryStatements: z
20
+ .array(z
21
+ .object({
22
+ code: z.string().describe('P-code (e.g. "P210").'),
23
+ statement: z.string().describe('Precautionary statement text.'),
24
+ })
25
+ .describe('GHS precautionary statement entry.'))
26
+ .describe('GHS precautionary statements.'),
27
+ })
28
+ .describe('GHS classification data.');
29
+ /** Fan-out cap: at most this many PUG View calls in flight at once (mirrors get_compound_details). */
30
+ const MAX_IN_FLIGHT = 10;
7
31
  export const getCompoundSafety = tool('pubchem_get_compound_safety', {
8
32
  title: 'Get Compound Safety',
9
- description: 'Get GHS (Globally Harmonized System) hazard classification and safety data for a compound. Returns signal word, pictograms, hazard statements (H-codes), and precautionary statements (P-codes). Data sourced from PubChem depositors — source attribution included.',
33
+ description: 'Get GHS (Globally Harmonized System) hazard classification and safety data for one or more compounds by CID. Returns signal word, pictograms, hazard statements (H-codes), and precautionary statements (P-codes) per compound. Data sourced from PubChem depositors — source attribution included.',
10
34
  annotations: {
11
35
  readOnlyHint: true,
12
36
  idempotentHint: true,
13
37
  openWorldHint: true,
14
38
  },
15
39
  input: z.object({
16
- cid: z
17
- .number()
18
- .int()
19
- .positive()
20
- .describe('PubChem Compound ID. Resolve from name/SMILES with pubchem_search_compounds.'),
40
+ cids: z
41
+ .array(z.number().int().positive())
42
+ .min(1)
43
+ .max(25)
44
+ .describe('PubChem Compound IDs to fetch safety data for (1-25). Resolve from names/SMILES with pubchem_search_compounds.'),
21
45
  }),
22
46
  output: z.object({
23
- cid: z.number().describe('PubChem Compound ID.'),
24
- hasData: z.boolean().describe('Whether GHS safety data is available for this compound.'),
25
- ghs: z
47
+ results: z
48
+ .array(z
26
49
  .object({
27
- signalWord: z.string().optional().describe('GHS signal word: "Danger" or "Warning".'),
28
- pictograms: z
29
- .array(z.string())
30
- .describe('GHS pictogram labels (e.g. "Flammable", "Toxic").'),
31
- hazardStatements: z
32
- .array(z
33
- .object({
34
- code: z.string().describe('H-code (e.g. "H225").'),
35
- statement: z.string().describe('Hazard statement text.'),
36
- })
37
- .describe('GHS hazard statement entry.'))
38
- .describe('GHS hazard statements.'),
39
- precautionaryStatements: z
40
- .array(z
41
- .object({
42
- code: z.string().describe('P-code (e.g. "P210").'),
43
- statement: z.string().describe('Precautionary statement text.'),
44
- })
45
- .describe('GHS precautionary statement entry.'))
46
- .describe('GHS precautionary statements.'),
50
+ cid: z.number().describe('PubChem Compound ID.'),
51
+ hasData: z
52
+ .boolean()
53
+ .describe('Whether GHS safety data is available for this compound.'),
54
+ ghs: ghsSchema.optional(),
55
+ source: z.string().optional().describe('Data source attribution.'),
47
56
  })
48
- .optional()
49
- .describe('GHS classification data.'),
50
- source: z.string().optional().describe('Data source attribution.'),
57
+ .describe('Per-CID safety result.'))
58
+ .describe('Safety results, one per requested CID (input order preserved).'),
51
59
  }),
52
- // Agent-facing context — a cross-tool notice when no GHS data exists, pointing to an
53
- // alternative source. Reaches structuredContent and content[]; disjoint from output.
60
+ // Agent-facing context — requested/with-data counts and a cross-tool notice listing the CIDs
61
+ // that lack GHS data. Reaches structuredContent and content[]; keys disjoint from output.
54
62
  enrichment: {
63
+ requestedCount: z.number().describe('CIDs requested.'),
64
+ withDataCount: z.number().describe('CIDs with GHS safety data available.'),
55
65
  notice: z
56
66
  .string()
57
67
  .optional()
58
- .describe('Cross-tool guidance when no GHS data is available, pointing to an alternative source.'),
68
+ .describe('Cross-tool guidance when one or more CIDs have no GHS data, pointing to an alternative source.'),
59
69
  },
60
70
  async handler(input, ctx) {
61
71
  const client = getPubChemClient();
62
- const data = await client.getSafetyData(input.cid);
63
- ctx.log.info('Safety data fetched', { cid: input.cid, hasData: data !== null });
64
- if (!data) {
65
- ctx.enrich.notice(`No GHS classification on file for CID ${input.cid}. Try pubchem_get_compound_details with includeDescription for hazard context, or the compound may simply lack deposited safety data.`);
66
- return { cid: input.cid, hasData: false };
72
+ // Fan out per CID, capped at MAX_IN_FLIGHT in flight.
73
+ const dataByCid = new Map();
74
+ for (let i = 0; i < input.cids.length; i += MAX_IN_FLIGHT) {
75
+ const chunk = input.cids.slice(i, i + MAX_IN_FLIGHT);
76
+ const chunkData = await Promise.all(chunk.map(async (cid) => [cid, await client.getSafetyData(cid)]));
77
+ for (const [cid, data] of chunkData)
78
+ dataByCid.set(cid, data);
79
+ }
80
+ const results = input.cids.map((cid) => {
81
+ const data = dataByCid.get(cid) ?? null;
82
+ if (!data)
83
+ return { cid, hasData: false };
84
+ return {
85
+ cid,
86
+ hasData: true,
87
+ ghs: {
88
+ signalWord: data.signalWord,
89
+ pictograms: data.pictograms,
90
+ hazardStatements: data.hazardStatements,
91
+ precautionaryStatements: data.precautionaryStatements,
92
+ },
93
+ source: data.source,
94
+ };
95
+ });
96
+ const withDataCount = results.filter((r) => r.hasData).length;
97
+ ctx.log.info('Safety data fetched', {
98
+ requested: input.cids.length,
99
+ withData: withDataCount,
100
+ });
101
+ ctx.enrich({ requestedCount: input.cids.length, withDataCount });
102
+ if (withDataCount < input.cids.length) {
103
+ const missing = results.filter((r) => !r.hasData).map((r) => r.cid);
104
+ ctx.enrich.notice(`No GHS classification on file for ${missing.length} of ${input.cids.length} CID(s): ${missing.join(', ')}. Try pubchem_get_compound_details with includeDescription for hazard context, or those compounds may simply lack deposited safety data.`);
67
105
  }
68
- return {
69
- cid: input.cid,
70
- hasData: true,
71
- ghs: {
72
- signalWord: data.signalWord,
73
- pictograms: data.pictograms,
74
- hazardStatements: data.hazardStatements,
75
- precautionaryStatements: data.precautionaryStatements,
76
- },
77
- source: data.source,
78
- };
106
+ return { results };
79
107
  },
80
108
  format(result) {
81
- if (!result.hasData || !result.ghs) {
82
- return [{ type: 'text', text: `No GHS safety data available for CID ${result.cid}.` }];
109
+ if (result.results.length === 0) {
110
+ return [{ type: 'text', text: 'No compounds requested.' }];
83
111
  }
84
- const lines = [`## GHS Safety Data — CID ${result.cid}`, ''];
85
- const g = result.ghs;
86
- if (g.signalWord)
87
- lines.push(`**Signal Word:** ${g.signalWord}`);
88
- if (g.pictograms.length > 0)
89
- lines.push(`**Pictograms:** ${g.pictograms.join(', ')}`);
90
- if (g.hazardStatements.length > 0) {
91
- lines.push('', '**Hazard Statements:**');
92
- for (const h of g.hazardStatements) {
93
- lines.push(` ${h.code}: ${h.statement}`);
112
+ const blocks = [];
113
+ for (const r of result.results) {
114
+ if (!r.hasData || !r.ghs) {
115
+ blocks.push(`## CID ${r.cid} — no GHS safety data`, '');
116
+ continue;
94
117
  }
95
- }
96
- if (g.precautionaryStatements.length > 0) {
97
- lines.push('', '**Precautionary Statements:**');
98
- for (const p of g.precautionaryStatements) {
99
- lines.push(` ${p.code}: ${p.statement}`);
118
+ const lines = [`## GHS Safety Data — CID ${r.cid}`];
119
+ const g = r.ghs;
120
+ if (g.signalWord)
121
+ lines.push(`**Signal Word:** ${g.signalWord}`);
122
+ if (g.pictograms.length > 0)
123
+ lines.push(`**Pictograms:** ${g.pictograms.join(', ')}`);
124
+ if (g.hazardStatements.length > 0) {
125
+ lines.push('', '**Hazard Statements:**');
126
+ for (const h of g.hazardStatements)
127
+ lines.push(` ${h.code}: ${h.statement}`);
100
128
  }
129
+ if (g.precautionaryStatements.length > 0) {
130
+ lines.push('', '**Precautionary Statements:**');
131
+ for (const p of g.precautionaryStatements)
132
+ lines.push(` ${p.code}: ${p.statement}`);
133
+ }
134
+ if (r.source)
135
+ lines.push('', `*Source: ${r.source}*`);
136
+ blocks.push(lines.join('\n'), '');
101
137
  }
102
- if (result.source) {
103
- lines.push('', `*Source: ${result.source}*`);
104
- }
105
- return [{ type: 'text', text: lines.join('\n') }];
138
+ return [{ type: 'text', text: blocks.join('\n') }];
106
139
  },
107
140
  });
108
141
  //# sourceMappingURL=get-compound-safety.tool.js.map