chemanim

chemanim

Converts chemistry animation requests into Manim scenes using DeepSeek for structure generation and RDKit for validation, with PubChem lookup and optional 3D rendering.

Category
Visit Server

README

ChemAnim

把中文化学动画要求转换为可校验的 Manim 场景:DeepSeek 负责理解需求并给出英文规范名称和候选 isomeric SMILES;程序再查询 PubChem,用 Morgan 指纹比较候选结构,采用数据库结构,并由 RDKit 校验分子式、形式电荷和方程式守恒。Manim 只读取最终 JSON,不执行模型生成的代码。

准备

需要 Python 3.12 和 DeepSeek API 密钥。方程式使用 Unicode 化学下标显示,不再依赖 MiKTeX。首次安装:

cd C:\Users\i\Documents\chemenv
py -3.12 -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .

不要把密钥写进源码或 .env。在当前 PowerShell 会话中设置:

$secureKey = Read-Host "DeepSeek API Key" -AsSecureString
$env:DEEPSEEK_API_KEY = [Net.NetworkCredential]::new("", $secureKey).Password

如果要跨新终端保存,请在 Windows 用户环境变量中添加 DEEPSEEK_API_KEY,然后重新打开 PowerShell。检查环境:

.\check_environment.ps1

使用

先只生成并检查场景、结构图和核验报告:

.\.venv\Scripts\chemanim.exe "演示乙烯与溴的加成反应。生成物为1,2-二溴乙烷,展示所有物质的结构式。" --no-render

渲染二维或三维动画:

.\.venv\Scripts\chemanim.exe "演示乙烯与溴的加成反应。生成物为1,2-二溴乙烷。" --quality high
.\.venv\Scripts\chemanim.exe "演示乙烯与溴的加成反应。生成物为1,2-二溴乙烷。" --quality high --structure-mode 3d

--structure-mode 3d 默认自动启用 OpenGL/GPU;二维结构默认使用更兼容的 Cairo。快速预览建议使用 --quality medium,需要手动选择时可加 --renderer opengl--renderer cairo

二维模式会让同一画面中的结构式共享比例尺,小分子不再被强行放大到与复杂分子相同的宽度。

输出位于:

  • build/scene.json:最终场景及核验摘要
  • build/verification.json:PubChem CID、InChIKey、候选/核验 SMILES 和 Morgan Tanimoto 相似度
  • build/molecule_*.svg 或场景中的 3D 原子/键数据
  • media/:Manim 视频

流程会在 DeepSeek JSON 无效时最多自动回传修正三次。PubChem 暂时不可用时,会保留候选结构并进行本地 RDKit 校验;未通过校验则停止,不渲染错误结果。

默认使用响应更快的 deepseek-v4-flash,化学结构仍由 PubChem 和 RDKit 校验。需要更强规划时可添加 --model deepseek-v4-pro --request-timeout 180

更多示例

.\.venv\Scripts\chemanim.exe "演示甲苯被氧气选择性氧化为苯甲醛和水,展示全部结构式。" --quality medium
.\.venv\Scripts\chemanim.exe "制作阿莫西林半合成原理动画,保持正确立体化学,不要虚构实验条件。" --no-render

MCP 服务器

项目提供标准 stdio MCP 入口:

.\.venv\Scripts\chemanim-mcp.exe

MCP 客户端配置示例(密钥由客户端进程继承,不要写进 JSON):

{
  "mcpServers": {
    "chemanim": {
      "command": "C:\\Users\\i\\Documents\\chemenv\\.venv\\Scripts\\chemanim-mcp.exe"
    }
  }
}

服务器暴露 generate_chemistry_animation 工具,参数包括 promptqualitystructure_moderendermodelrequest_timeout。它只调用受约束的 ChemAnim CLI,不执行模型提交的 Python 代码。

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured