chemdraw-mcp 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. chemdraw_mcp-0.2.0/.github/workflows/ci.yml +55 -0
  2. chemdraw_mcp-0.2.0/.github/workflows/publish.yml +35 -0
  3. chemdraw_mcp-0.2.0/.gitignore +15 -0
  4. chemdraw_mcp-0.2.0/CLAUDE.md +75 -0
  5. chemdraw_mcp-0.2.0/LICENSE +202 -0
  6. chemdraw_mcp-0.2.0/PKG-INFO +190 -0
  7. chemdraw_mcp-0.2.0/README.md +165 -0
  8. chemdraw_mcp-0.2.0/chemdraw_tool/__init__.py +1 -0
  9. chemdraw_mcp-0.2.0/chemdraw_tool/anki_export.py +244 -0
  10. chemdraw_mcp-0.2.0/chemdraw_tool/calculator/__init__.py +1 -0
  11. chemdraw_mcp-0.2.0/chemdraw_tool/calculator/photometry.py +93 -0
  12. chemdraw_mcp-0.2.0/chemdraw_tool/calculator/stats.py +215 -0
  13. chemdraw_mcp-0.2.0/chemdraw_tool/calculator/titration.py +97 -0
  14. chemdraw_mcp-0.2.0/chemdraw_tool/cdxml_writer.py +200 -0
  15. chemdraw_mcp-0.2.0/chemdraw_tool/chemdraw.py +141 -0
  16. chemdraw_mcp-0.2.0/chemdraw_tool/curated_decks.py +140 -0
  17. chemdraw_mcp-0.2.0/chemdraw_tool/databases.py +298 -0
  18. chemdraw_mcp-0.2.0/chemdraw_tool/generator.py +17 -0
  19. chemdraw_mcp-0.2.0/chemdraw_tool/image_export.py +320 -0
  20. chemdraw_mcp-0.2.0/chemdraw_tool/layout.py +221 -0
  21. chemdraw_mcp-0.2.0/chemdraw_tool/mechanism.py +70 -0
  22. chemdraw_mcp-0.2.0/chemdraw_tool/mechanism_coords.py +126 -0
  23. chemdraw_mcp-0.2.0/chemdraw_tool/mechanism_renderer.py +238 -0
  24. chemdraw_mcp-0.2.0/chemdraw_tool/payloads.py +228 -0
  25. chemdraw_mcp-0.2.0/chemdraw_tool/ph_plots.py +254 -0
  26. chemdraw_mcp-0.2.0/chemdraw_tool/png_writer.py +70 -0
  27. chemdraw_mcp-0.2.0/chemdraw_tool/resolver.py +209 -0
  28. chemdraw_mcp-0.2.0/chemdraw_tool/server.py +1575 -0
  29. chemdraw_mcp-0.2.0/chemdraw_tool/spectrum.py +332 -0
  30. chemdraw_mcp-0.2.0/chemdraw_tool/structure3d.py +56 -0
  31. chemdraw_mcp-0.2.0/chemdraw_tool/svg_renderer.py +255 -0
  32. chemdraw_mcp-0.2.0/chemdraw_tool/templates/__init__.py +35 -0
  33. chemdraw_mcp-0.2.0/chemdraw_tool/templates/ester.py +64 -0
  34. chemdraw_mcp-0.2.0/chemdraw_tool/templates/substitution.py +92 -0
  35. chemdraw_mcp-0.2.0/chemdraw_tool/ui/.gitignore +1 -0
  36. chemdraw_mcp-0.2.0/chemdraw_tool/ui/app.html +175 -0
  37. chemdraw_mcp-0.2.0/chemdraw_tool/ui/dist/index.html +175 -0
  38. chemdraw_mcp-0.2.0/chemdraw_tool/ui/gen_3d_frames.mjs +52 -0
  39. chemdraw_mcp-0.2.0/chemdraw_tool/ui/gen_mechanism_frames.mjs +36 -0
  40. chemdraw_mcp-0.2.0/chemdraw_tool/ui/gen_panel_png.mjs +28 -0
  41. chemdraw_mcp-0.2.0/chemdraw_tool/ui/generate_test_payloads.py +123 -0
  42. chemdraw_mcp-0.2.0/chemdraw_tool/ui/index.html +12 -0
  43. chemdraw_mcp-0.2.0/chemdraw_tool/ui/package.json +26 -0
  44. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/AnkiDeckView.jsx +59 -0
  45. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/App.jsx +45 -0
  46. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/AppContext.js +9 -0
  47. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/DatabaseView.jsx +139 -0
  48. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/MechanismView.jsx +287 -0
  49. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/Molecule3DView.jsx +239 -0
  50. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/MoleculeView.jsx +217 -0
  51. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/PlotView.jsx +57 -0
  52. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/ReactionView.jsx +225 -0
  53. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/SpectrumView.jsx +77 -0
  54. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/ValidationView.jsx +232 -0
  55. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/components/AtomHighlights.jsx +48 -0
  56. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/components/AtomTooltip.jsx +79 -0
  57. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/components/CopyButton.jsx +65 -0
  58. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/components/ExportPngButton.jsx +125 -0
  59. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/components/FunctionalGroupList.jsx +62 -0
  60. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/components/LipinskiBadge.jsx +64 -0
  61. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/components/NavTabs.jsx +41 -0
  62. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/components/PropRow.jsx +35 -0
  63. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/components/SectionHeader.jsx +23 -0
  64. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/main.jsx +45 -0
  65. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/styles.css +90 -0
  66. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/utils/__fixtures__/aspirin.expected.linux.png +0 -0
  67. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/utils/__fixtures__/aspirin.expected.png +0 -0
  68. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/utils/__fixtures__/aspirin.fill.svg +130 -0
  69. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/utils/svgCoords.js +53 -0
  70. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/utils/svgToPng.e2e.mjs +207 -0
  71. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/utils/svgToPng.js +83 -0
  72. chemdraw_mcp-0.2.0/chemdraw_tool/ui/src/utils/svgToPng.test.mjs +30 -0
  73. chemdraw_mcp-0.2.0/chemdraw_tool/ui/test-harness.html +59 -0
  74. chemdraw_mcp-0.2.0/chemdraw_tool/ui/test-payloads.json +566 -0
  75. chemdraw_mcp-0.2.0/chemdraw_tool/ui/vite.config.js +11 -0
  76. chemdraw_mcp-0.2.0/chemdraw_tool/validator.py +225 -0
  77. chemdraw_mcp-0.2.0/chemdraw_tool/vault.py +118 -0
  78. chemdraw_mcp-0.2.0/install.sh +56 -0
  79. chemdraw_mcp-0.2.0/pyproject.toml +77 -0
  80. chemdraw_mcp-0.2.0/scripts/gen_3d_gif.sh +22 -0
  81. chemdraw_mcp-0.2.0/scripts/gen_mechanism_gif.sh +20 -0
  82. chemdraw_mcp-0.2.0/scripts/gen_titrations.py +287 -0
  83. chemdraw_mcp-0.2.0/scripts/install_claude_config.py +109 -0
  84. chemdraw_mcp-0.2.0/server.json +21 -0
  85. chemdraw_mcp-0.2.0/test.sh +41 -0
  86. chemdraw_mcp-0.2.0/tests/__init__.py +0 -0
  87. chemdraw_mcp-0.2.0/tests/screenshot_ui.py +123 -0
  88. chemdraw_mcp-0.2.0/tests/test_anki_export.py +239 -0
  89. chemdraw_mcp-0.2.0/tests/test_calculator_photometry.py +109 -0
  90. chemdraw_mcp-0.2.0/tests/test_calculator_stats.py +81 -0
  91. chemdraw_mcp-0.2.0/tests/test_calculator_titration.py +135 -0
  92. chemdraw_mcp-0.2.0/tests/test_cdxml_writer.py +290 -0
  93. chemdraw_mcp-0.2.0/tests/test_chemdraw.py +162 -0
  94. chemdraw_mcp-0.2.0/tests/test_compare.py +62 -0
  95. chemdraw_mcp-0.2.0/tests/test_curated_decks.py +53 -0
  96. chemdraw_mcp-0.2.0/tests/test_databases.py +300 -0
  97. chemdraw_mcp-0.2.0/tests/test_generator.py +40 -0
  98. chemdraw_mcp-0.2.0/tests/test_image_export.py +181 -0
  99. chemdraw_mcp-0.2.0/tests/test_install_config.py +122 -0
  100. chemdraw_mcp-0.2.0/tests/test_integration.py +85 -0
  101. chemdraw_mcp-0.2.0/tests/test_layout.py +166 -0
  102. chemdraw_mcp-0.2.0/tests/test_mechanism.py +181 -0
  103. chemdraw_mcp-0.2.0/tests/test_mechanism_coords.py +78 -0
  104. chemdraw_mcp-0.2.0/tests/test_mechanism_renderer.py +95 -0
  105. chemdraw_mcp-0.2.0/tests/test_ph_plots.py +139 -0
  106. chemdraw_mcp-0.2.0/tests/test_png_writer.py +93 -0
  107. chemdraw_mcp-0.2.0/tests/test_resolver.py +217 -0
  108. chemdraw_mcp-0.2.0/tests/test_server_anki.py +114 -0
  109. chemdraw_mcp-0.2.0/tests/test_server_formats.py +87 -0
  110. chemdraw_mcp-0.2.0/tests/test_server_lookup_ui.py +152 -0
  111. chemdraw_mcp-0.2.0/tests/test_server_mechanism.py +64 -0
  112. chemdraw_mcp-0.2.0/tests/test_server_open_file.py +82 -0
  113. chemdraw_mcp-0.2.0/tests/test_server_plots.py +82 -0
  114. chemdraw_mcp-0.2.0/tests/test_server_reaction.py +64 -0
  115. chemdraw_mcp-0.2.0/tests/test_server_spectrum.py +66 -0
  116. chemdraw_mcp-0.2.0/tests/test_server_ui.py +152 -0
  117. chemdraw_mcp-0.2.0/tests/test_server_validation.py +80 -0
  118. chemdraw_mcp-0.2.0/tests/test_spectrum.py +291 -0
  119. chemdraw_mcp-0.2.0/tests/test_structure3d.py +59 -0
  120. chemdraw_mcp-0.2.0/tests/test_svg_renderer.py +199 -0
  121. chemdraw_mcp-0.2.0/tests/test_validator.py +161 -0
  122. chemdraw_mcp-0.2.0/tests/test_vault.py +95 -0
  123. chemdraw_mcp-0.2.0/uv.lock +1753 -0
@@ -0,0 +1,55 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v6
13
+
14
+ # setup-uv publishes no floating major tag for v8+ — pin the exact version
15
+ - uses: astral-sh/setup-uv@v8.2.0
16
+ with:
17
+ enable-cache: true
18
+
19
+ - uses: actions/setup-node@v6
20
+ with:
21
+ node-version: 22
22
+
23
+ - name: Install backend dependencies
24
+ run: uv sync
25
+
26
+ - name: Install frontend dependencies
27
+ run: npm --prefix chemdraw_tool/ui install
28
+
29
+ - name: Install Playwright Chromium
30
+ working-directory: chemdraw_tool/ui
31
+ run: npx playwright install --with-deps chromium
32
+
33
+ # The pixel snapshot is platform-specific (see svgToPng.e2e.mjs). On the
34
+ # very first CI run the linux golden file doesn't exist yet — generate it
35
+ # so ./test.sh below can run, and publish it as an artifact. Download that
36
+ # artifact and commit it as
37
+ # chemdraw_tool/ui/src/utils/__fixtures__/aspirin.expected.linux.png
38
+ # — from then on this step is a no-op and the comparison is a real
39
+ # regression check. Never regenerate it just to make a diff disappear.
40
+ - name: Bootstrap linux snapshot (first run only)
41
+ run: |
42
+ if [ ! -f chemdraw_tool/ui/src/utils/__fixtures__/aspirin.expected.linux.png ]; then
43
+ echo "::warning::linux golden file missing — bootstrapping (commit the artifact!)"
44
+ UPDATE_SNAPSHOTS=1 npm --prefix chemdraw_tool/ui run test:e2e
45
+ fi
46
+
47
+ - name: Run the gate (backend + frontend)
48
+ run: ./test.sh
49
+
50
+ - name: Upload fixtures (for snapshot bootstrap)
51
+ uses: actions/upload-artifact@v7
52
+ if: always()
53
+ with:
54
+ name: ui-fixtures
55
+ path: chemdraw_tool/ui/src/utils/__fixtures__/
@@ -0,0 +1,35 @@
1
+ name: Publish to PyPI
2
+
3
+ # Trusted Publishing (OIDC) — no API token stored anywhere.
4
+ # One-time setup on pypi.org: Account → Publishing → Add pending publisher
5
+ # PyPI project name: chemdraw-mcp
6
+ # Owner: jurimaxam-dotcom Repository: chemdraw-mcp
7
+ # Workflow name: publish.yml Environment: (leave empty)
8
+ on:
9
+ release:
10
+ types: [published]
11
+ workflow_dispatch:
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v6
18
+ - uses: astral-sh/setup-uv@v8.2.0
19
+ - run: uv build
20
+ - uses: actions/upload-artifact@v7
21
+ with:
22
+ name: dist
23
+ path: dist/
24
+
25
+ publish:
26
+ needs: build
27
+ runs-on: ubuntu-latest
28
+ permissions:
29
+ id-token: write
30
+ steps:
31
+ - uses: actions/download-artifact@v8
32
+ with:
33
+ name: dist
34
+ path: dist/
35
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,15 @@
1
+ # Python
2
+ .venv/
3
+ __pycache__/
4
+ *.pyc
5
+
6
+ # Node
7
+ node_modules/
8
+ package-lock.json
9
+
10
+ # OS / IDE / local agent config
11
+ .DS_Store
12
+ .idea/
13
+ .ai/
14
+ .claude/settings.local.json
15
+ CLAUDE.local.md
@@ -0,0 +1,75 @@
1
+ # chemdraw-mcp
2
+
3
+ MCP server for Claude Desktop that turns molecule names or SMILES into
4
+ publication-style 2D structure drawings. PNG/SVG are the primary outputs
5
+ (rendered offline via RDKit) — ChemDraw CDXML is an optional extra format,
6
+ never a runtime requirement.
7
+
8
+ ## Build / Run
9
+
10
+ ```bash
11
+ ./install.sh # one-command setup: uv + deps + Claude Desktop config
12
+ uv sync # deps only
13
+ uv run chemdraw-tool-server # run the MCP server (stdio) manually
14
+ ```
15
+
16
+ `install.sh` registers the server in Claude Desktop via
17
+ `scripts/install_claude_config.py` (idempotent merge, writes a `.bak` backup,
18
+ never touches other configured MCP servers).
19
+
20
+ **After changing server code or dependencies, restart Claude Desktop** —
21
+ it keeps the server process alive, and a stale process mixes old in-memory
22
+ modules with new files (manifests as confusing RDKit/Boost signature errors).
23
+
24
+ ## Auto-Gate (the project's green/red)
25
+
26
+ ```bash
27
+ ./test.sh # full pipeline: backend + frontend
28
+ npm --prefix chemdraw_tool/ui run test:watch # JS unit tests in watch mode
29
+ ```
30
+
31
+ One-time frontend setup: `cd chemdraw_tool/ui && npm install && npx playwright install chromium`
32
+
33
+ The e2e test rasters a real RDKit SVG in headless Chromium and compares an
34
+ exact pixel snapshot. The snapshot is machine-specific: regenerate once per
35
+ machine with `npm --prefix chemdraw_tool/ui run test:e2e:update` — never
36
+ regenerate it just to make a diff disappear.
37
+
38
+ ## Architecture
39
+
40
+ ```
41
+ chemdraw_tool/
42
+ ├── resolver.py — SMILES detection + name→SMILES cascade:
43
+ │ OPSIN (offline, needs Java; degrades gracefully)
44
+ │ → PubChem → NCI
45
+ ├── generator.py — RDKit 2D coordinates
46
+ ├── image_export.py — PNG/SVG file rendering (primary output path)
47
+ ├── svg_renderer.py — SVG for the embedded UI preview (shared BOND_LINE_WIDTH)
48
+ ├── spectrum.py — schematic spectra from peak lists (matplotlib → PNG/SVG)
49
+ ├── cdxml_writer.py — RDKit mol → ChemDraw CDXML (optional format)
50
+ ├── layout.py — reaction scheme layout (arrows, +, conditions)
51
+ ├── mechanism*.py — reaction mechanism definitions/coords/rendering
52
+ ├── databases.py — PubChem / ChEBI / KEGG / UniProt lookups
53
+ ├── validator.py — input validation + CDXML round-trip validation
54
+ ├── calculator/ — Ph.Eur. content-determination math (pure functions)
55
+ ├── payloads.py — Pydantic models for MCP structured output
56
+ ├── chemdraw.py — optional macOS AppleScript bridge to ChemDraw
57
+ ├── server.py — FastMCP server (stdio) + tool definitions
58
+ └── ui/ — embedded MCP App UI (React/Vite, served as resource)
59
+ ```
60
+
61
+ Pipeline: input (name/SMILES) → resolver → RDKit 2D → image_export (PNG/SVG)
62
+ [→ cdxml_writer if requested] → `~/ChemDraw-Output/`
63
+
64
+ Output formats: `generate_*` tools accept `formats=["png","svg","cdxml"]`,
65
+ default `["png","svg"]`. CDXML only on explicit request.
66
+
67
+ ## Conventions
68
+
69
+ - Python 3.11+, package manager: `uv`
70
+ - Tests: pytest, TDD (red first — no production code without a failing test)
71
+ - UI preview and exported files must stay visually consistent
72
+ (shared constants like `BOND_LINE_WIDTH`; parity is test-enforced)
73
+ - Dependencies: rdkit, lxml, requests, mcp, Pillow, matplotlib, py2opsin
74
+ (OPSIN needs a JRE at runtime; without one the resolver degrades to
75
+ PubChem/NCI — never make Java a hard requirement)
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.4
2
+ Name: chemdraw-mcp
3
+ Version: 0.2.0
4
+ Summary: MCP server that turns molecule names or SMILES into publication-style 2D structure drawings (PNG/SVG via RDKit) — reaction schemes, mechanisms, spectra. Unofficial, not affiliated with Revvity.
5
+ Project-URL: Repository, https://github.com/jurimaxam-dotcom/chemdraw-mcp
6
+ Project-URL: Issues, https://github.com/jurimaxam-dotcom/chemdraw-mcp/issues
7
+ Author: jurimaxam-dotcom
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: chemistry,claude,mcp,rdkit,smiles,structure-drawing
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: genanki>=0.13.1
17
+ Requires-Dist: lxml
18
+ Requires-Dist: matplotlib>=3.10.9
19
+ Requires-Dist: mcp
20
+ Requires-Dist: pillow
21
+ Requires-Dist: py2opsin>=1.2.0
22
+ Requires-Dist: rdkit
23
+ Requires-Dist: requests
24
+ Description-Content-Type: text/markdown
25
+
26
+ # chemdraw-mcp
27
+
28
+ <!-- mcp-name: io.github.jurimaxam-dotcom/chemdraw-mcp -->
29
+
30
+ [![CI](https://github.com/jurimaxam-dotcom/chemdraw-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/jurimaxam-dotcom/chemdraw-mcp/actions/workflows/ci.yml)
31
+ [![Release](https://img.shields.io/github/v/release/jurimaxam-dotcom/chemdraw-mcp)](https://github.com/jurimaxam-dotcom/chemdraw-mcp/releases)
32
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
33
+
34
+ **Chat → chemical structure.** An MCP server for Claude Desktop that turns
35
+ molecule names or SMILES into publication-style 2D structure drawings —
36
+ *"draw aspirin"* produces a print-ready PNG/SVG, rendered fully offline with
37
+ RDKit. No ChemDraw required; ChemDraw CDXML is available as an optional extra
38
+ format for users who want to keep editing there.
39
+
40
+ Built for pharmacy/chemistry students who spend too much time clicking
41
+ hexagons: structures, full reaction schemes, step-by-step mechanisms,
42
+ substance data sheets and Ph.Eur. assay calculations — straight from the chat,
43
+ with an interactive preview panel rendered inline.
44
+
45
+ <p align="center"><img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/demo.gif" alt="Live demo: 'Draw Caffein' renders an interactive structure panel in Claude Desktop" width="560"></p>
46
+
47
+ ## Example output
48
+
49
+ *"Draw caffeine"* — print-ready PNG, generated by `generate_molecule`:
50
+
51
+ <p align="center"><img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/caffeine.png" alt="Caffeine structure, rendered by generate_molecule" width="420"></p>
52
+
53
+ *"Show the Fischer esterification of ethanol with acetic acid"* —
54
+ `generate_reaction` renders the scheme with conditions above the arrow,
55
+ live in the chat panel:
56
+
57
+ <p align="center"><img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/reaction-demo.gif" alt="Reaction scheme with conditions appearing live in the chat panel" width="640"></p>
58
+
59
+ *"Show the Fischer esterification mechanism step by step"* —
60
+ `generate_mechanism` renders curved electron-flow arrows in the interactive
61
+ panel:
62
+
63
+ <p align="center"><img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/mechanism-demo.gif" alt="Step-by-step Fischer esterification mechanism with curved arrows in the chat panel" width="560"></p>
64
+
65
+ *"Sketch the IR spectrum of ethyl acetate"* — `generate_spectrum` (draws the
66
+ peaks it is given, with per-type axis conventions):
67
+
68
+ <p align="center"><img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/ethyl-acetate-ir.png" alt="Schematic IR spectrum of ethyl acetate with labeled bands" width="560"></p>
69
+
70
+ *"Show caffeine in 3D"* — `generate_3d` embeds the molecule (ETKDG + force
71
+ field) and opens a drag-to-rotate ball-and-stick viewer in the chat panel:
72
+
73
+ <p align="center"><img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/3d-demo.gif" alt="Rotating 3D ball-and-stick caffeine model inside the concave viewer" width="560"></p>
74
+
75
+ *"What distinguishes ibuprofen from naproxen and ketoprofen?"* —
76
+ `compare_molecules` keeps the shared scaffold (MCS) neutral and highlights
77
+ everything that differs:
78
+
79
+ <p align="center"><img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/compare-profens.png" alt="Ibuprofen, naproxen and ketoprofen side by side with differences highlighted" width="680"></p>
80
+
81
+ *"Titration curve of phosphoric acid with NaOH, phenolphthalein as
82
+ indicator"* — `generate_titration_curve` computes pH from the exact charge
83
+ balance, with equivalence points, buffer points (pH = pKa) and the indicator
84
+ band; its sibling `generate_species_distribution` shows which protonation
85
+ species dominates at every pH:
86
+
87
+ <p align="center">
88
+ <img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/titration-phosphoric.png" alt="Titration curve of phosphoric acid with three equivalence points and phenolphthalein band" width="420">
89
+ <img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/species-phosphoric.png" alt="Species distribution of phosphoric acid over pH with pKa crossovers" width="420">
90
+ </p>
91
+
92
+ *"Create an Anki deck with important molecules and open it in Anki"* —
93
+ `export_anki_deck` / `export_curated_deck` build a ready-to-import `.apkg`
94
+ with rendered structures embedded; with the optional AnkiConnect add-on the
95
+ cards land straight in the running Anki, no clicks:
96
+
97
+ <p align="center"><img src="https://raw.githubusercontent.com/jurimaxam-dotcom/chemdraw-mcp/main/assets/anki-demo.gif" alt="Split screen: asking Claude for an Anki deck, cards appear in Anki via AnkiConnect" width="760"></p>
98
+
99
+ ## Features
100
+
101
+ - **`generate_molecule`** — name/SMILES → 2D structure as PNG + SVG
102
+ (optionally CDXML), with properties, functional-group detection and a
103
+ Lipinski rule-of-five check
104
+ - **`generate_reaction`** — educts + products + conditions → reaction scheme
105
+ - **`batch_generate`** — a whole list of structures in one call
106
+ - **`generate_mechanism`** — curved-arrow mechanisms (SN1, SN2, Fischer
107
+ esterification) step by step
108
+ - **`generate_spectrum`** — schematic spectra from peak lists (IR, NIR,
109
+ Raman, UV/Vis, fluorescence, ORD, CD, ¹H/¹³C NMR, MS) with per-type axis
110
+ conventions — draws given peaks, does not predict spectra
111
+ - **`export_anki_deck`** — exam-prep flashcards as a ready-to-import
112
+ Anki `.apkg`: structure↔name drills (optionally reversed: one note,
113
+ both directions), cloze/fill-in-the-blank cards, identity/detection
114
+ reactions, spectrum band assignment — with rendered images embedded,
115
+ per-card tags, `Parent::Child` subdecks; re-exporting a deck updates
116
+ cards instead of duplicating them. Optional delivery straight into the
117
+ running Anki via the AnkiConnect add-on
118
+ - **`export_curated_deck`** — small, formula-verified starter decks
119
+ (classic analgesics, Ph.Eur. identity reactions)
120
+ - **`generate_titration_curve`** — pH vs. titrant volume from the exact
121
+ charge balance, with equivalence points, buffer points (pH = pKa) and
122
+ indicator transition band
123
+ - **`generate_species_distribution`** — protonation species fractions
124
+ over pH (Henderson-Hasselbalch) with pKa crossovers marked
125
+ - **`compare_molecules`** — 2-4 structures side by side, differences
126
+ highlighted, shared scaffold (MCS) neutral
127
+ - **`generate_3d`** — rotatable 3D ball-and-stick conformer in the chat
128
+ panel (ETKDG + force field) plus SDF export; stereo descriptors (R/S,
129
+ E/Z) available on 2D drawings via `annotate_stereo`
130
+ - **`lookup_*`** — substance data from PubChem, ChEBI, KEGG and UniProt
131
+ (properties, GHS safety, pathways)
132
+ - **`calculate_validation`** — Ph.Eur.-style content determination with full
133
+ calculation steps, t-test/F-test statistics
134
+ - **Interactive in-chat UI** (MCP App): hover atoms, inspect functional
135
+ groups, export PNG with one click
136
+ - **macOS ChemDraw bridge** (optional): open any generated structure directly
137
+ in ChemDraw via `open_chemdraw_file`
138
+
139
+ ## Installation
140
+
141
+ ```bash
142
+ git clone https://github.com/jurimaxam-dotcom/chemdraw-mcp.git
143
+ cd chemdraw-mcp && ./install.sh
144
+ ```
145
+
146
+ The installer sets up everything: installs [uv](https://docs.astral.sh/uv/)
147
+ if missing, resolves Python + RDKit, and registers the server in Claude
148
+ Desktop's config (idempotent, with backup — existing MCP servers are left
149
+ untouched). Restart Claude Desktop, then ask: *"draw caffeine"*.
150
+
151
+ Optional: with a Java runtime installed (e.g. `brew install openjdk`),
152
+ systematic IUPAC names — including ones no database indexes — are parsed
153
+ offline via [OPSIN](https://github.com/dan2097/opsin). Without Java the
154
+ server falls back to the PubChem/NCI online lookup.
155
+
156
+ ## How it works
157
+
158
+ ```
159
+ name / SMILES
160
+
161
+
162
+ resolver ──► OPSIN (systematic IUPAC names, offline) ──► PubChem / NCI (names) · direct parse (SMILES)
163
+
164
+
165
+ RDKit 2D coordinates ──► validation (sanity, round-trip)
166
+
167
+ ├──► image_export → PNG + SVG files (primary, offline)
168
+ ├──► svg_renderer → interactive chat preview (MCP App resource)
169
+ └──► cdxml_writer → ChemDraw CDXML (optional, on request)
170
+ ```
171
+
172
+ ## Development
173
+
174
+ ```bash
175
+ uv sync # backend deps
176
+ cd chemdraw_tool/ui && npm install && npx playwright install chromium # frontend, once
177
+ ./test.sh # the gate: pytest + JS unit + headless-Chromium e2e
178
+ ```
179
+
180
+ ~400 tests, written test-first. The e2e test rasters a real RDKit SVG in
181
+ headless Chromium and compares it against an exact pixel snapshot.
182
+
183
+ ## License
184
+
185
+ Apache-2.0 — see [LICENSE](LICENSE). Copyright 2026 jurimaxam-dotcom.
186
+
187
+ > **Disclaimer:** This is an unofficial, independent project, not affiliated
188
+ > with or endorsed by Revvity. *ChemDraw* is a trademark of Revvity Signals
189
+ > Software, Inc. This tool does not include or require ChemDraw; it can
190
+ > optionally export files in the open CDXML format.