chemcp 1.0.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.
- package/README.md +69 -0
- package/bin/chemcp.js +2 -0
- package/dist/mcp-app.html +25960 -0
- package/dist/server.js +105 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# ChemCP - Molecule Viewer MCP App
|
|
2
|
+
|
|
3
|
+
An MCP App that renders 2D molecular structure diagrams from SMILES notation using RDKit.js. Displays interactive molecule images with computed molecular properties directly inside AI chat.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
- **`render_molecule` tool**: Accepts a SMILES string and renders a 2D structure diagram
|
|
8
|
+
- **RDKit.js (WASM)**: Client-side molecule rendering via the RDKit JavaScript library
|
|
9
|
+
- **Molecular properties**: Computes MW, LogP, H-bond donors/acceptors, TPSA, rings, etc.
|
|
10
|
+
- **Interactive UI**: Input field to try SMILES, example molecules, live re-rendering
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
npm run build
|
|
17
|
+
npm run serve
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Server listens on `http://localhost:3001/mcp`.
|
|
21
|
+
|
|
22
|
+
## Development
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm run dev # Build + serve with watch mode
|
|
26
|
+
npm run start # Build then serve (production)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Testing with Claude
|
|
30
|
+
|
|
31
|
+
1. Start the server: `npm run serve`
|
|
32
|
+
2. In a separate terminal, expose via tunnel:
|
|
33
|
+
```bash
|
|
34
|
+
npx cloudflared tunnel --url http://localhost:3001
|
|
35
|
+
```
|
|
36
|
+
3. Add the tunnel URL as a custom connector in Claude (Settings > Connectors > Add custom connector)
|
|
37
|
+
4. Ask Claude: "Show me the molecule for aspirin" or "Render SMILES: CCO"
|
|
38
|
+
|
|
39
|
+
## Testing with basic-host
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Terminal 1
|
|
43
|
+
npm run serve
|
|
44
|
+
|
|
45
|
+
# Terminal 2
|
|
46
|
+
git clone https://github.com/modelcontextprotocol/ext-apps.git
|
|
47
|
+
cd ext-apps/examples/basic-host
|
|
48
|
+
npm install
|
|
49
|
+
SERVERS='["http://localhost:3001/mcp"]' npm start
|
|
50
|
+
# Open http://localhost:8080
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Architecture
|
|
54
|
+
|
|
55
|
+
- **[server.ts](server.ts)**: MCP server using `McpServer` + `registerAppTool`/`registerAppResource` with `StreamableHTTPServerTransport`
|
|
56
|
+
- **[src/mcp-app.html](src/mcp-app.html)**: HTML entry point loading RDKit.js from CDN
|
|
57
|
+
- **[src/mcp-app.tsx](src/mcp-app.tsx)**: React UI that initializes RDKit WASM, parses SMILES, renders SVG, computes descriptors
|
|
58
|
+
- **CSP**: Resource metadata allows `unpkg.com` for loading RDKit.js + WASM
|
|
59
|
+
|
|
60
|
+
## Example SMILES
|
|
61
|
+
|
|
62
|
+
| Molecule | SMILES |
|
|
63
|
+
|--------------|-----------------------------------------|
|
|
64
|
+
| Ethanol | `CCO` |
|
|
65
|
+
| Benzene | `c1ccccc1` |
|
|
66
|
+
| Aspirin | `CC(=O)Oc1ccccc1C(=O)O` |
|
|
67
|
+
| Caffeine | `CN1C=NC2=C1C(=O)N(C(=O)N2C)C` |
|
|
68
|
+
| Testosterone | `CC12CCC3C(C1CCC2O)CCC4=CC(=O)CCC34C` |
|
|
69
|
+
| Glucose | `OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O` |
|
package/bin/chemcp.js
ADDED