mirror of
https://github.com/Dasemu/chatgpt-imagegen-mcp.git
synced 2026-11-27 07:46:33 +00:00
Add .claude/settings.json hooks (typecheck on edited .ts files, guard on package-lock.json edits, Stop runs typecheck + test), CI workflow (typecheck + test on PRs/pushes to development/main), and a version bump workflow keyed off package.json. Restructure CLAUDE.md to match the standard section order (Overview, Commands, Architecture, Conventions, Workflow quirks, Deployment, Gotchas); docs/, LESSONS.md and .env.example were already present and in sync. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2.9 KiB
2.9 KiB
CLAUDE.md
Overview
MCP server (TypeScript, ESM, Express 5, @modelcontextprotocol/sdk) that generates images by driving chatgpt.com with Playwright. Mirrors the MCP contract of ZenvairoMediaGenerator-MCP (submit + poll, signed public URLs).
Commands
npm run dev: run with tsxnpm run build/npm start: compile todist/and runnpm run typechecknpm test: unit tests plus fixture-based browser tests. The browser tests skip if Playwright Chromium is missing. When the default cache is read-only, setPLAYWRIGHT_BROWSERS_PATH.npm run login(-- --check): manual chatgpt.com login with the persistent profile. The server must be stopped first.npm run selfheal(SELFHEAL_DRY_RUN=true): codex repair of the scraper in a throwaway clone; live smoke test, auto-merge and deploy (docs/selfheal.md)npm run smoke: generate one real image on chatgpt.com with the current code (uses quota; service stopped)
Architecture
See docs/architecture.md for the generation flow and lineage. Layout:
src/index.ts: HTTP app, auth, media routes, update routessrc/tools.ts: MCP toolssrc/jobs.ts: serial queue, pacing, circuit breakersrc/chatgpt/:selectors.ts(the only DOM knowledge),client.ts(page operations),provider.ts(one image per new chat),browser.ts(persistent context),prompts.tssrc/media.ts,src/public-media.ts: disk storage, manifests, HMAC URLssrc/update.ts,scripts/update.sh: authenticated self-updatesrc/selfheal.ts,scripts/selfheal.sh,scripts/selfheal/(prompt, Playwright + playwright-stealth inspector): codex self-healtest/fixtures/: reduced chatgpt.com DOM used bytest/client.test.ts
Conventions
- When chatgpt.com changes, edit only
src/chatgpt/selectors.ts, putting new selectors first, and update the fixtures. - Never log prompts, reference images, tokens or profile contents.
- Never commit
profiles/,diagnostics/,media/or.env. - Read
LESSONS.mdbefore changing the browser automation.
Workflow quirks
- No linter or formatter is configured;
npm run typecheckis the only static check. The.claude/settings.jsonhooks run it on edited.tsfiles and, together withnpm test, on Stop. - Edit
.env.examplewhenever the code gains or loses an environment variable.
Deployment
Standalone on Debian/Ubuntu under systemd (no Docker), with an authenticated self-update endpoint. See docs/deployment.md and docs/update.md. Unit and nginx files live in deploy/.
Gotchas
scripts/update.shrestarts the service viasudo -n systemctl restart; the systemd unit deliberately omitsNoNewPrivileges=trueto keep that working (seedeploy/sudoers.chatgpt-imagegen-mcp).npm run selfhealneeds acodexbinary and pushes/merges/deploys on success whenSELFHEAL_AUTO_MERGE/SELFHEAL_AUTO_UPDATEare enabled — never run it casually againstmain.