Skip to content

Add image generation and HTML artifact templates (Tools 8–10)#3

Open
klausagnoletti wants to merge 6 commits intoArcanum-Sec:mainfrom
klausagnoletti:feature/image-generation
Open

Add image generation and HTML artifact templates (Tools 8–10)#3
klausagnoletti wants to merge 6 commits intoArcanum-Sec:mainfrom
klausagnoletti:feature/image-generation

Conversation

@klausagnoletti
Copy link

Summary

Depends on: PR #1 (MCP server, Tools 1–7) — merge that first.

  • Adds three image generation tools to the TabletopExercise MCP server (Tools 8–10)
  • Implements HTML/CSS artifact templates for UI-heavy artifacts where AI diffusion models produce unreadable text
  • Routes artifact rendering: UI subtypes → pixel-perfect HTML templates, physical subtypes → AI image provider
  • Supports 5 AI image providers: OpenAI DALL-E, Google Imagen, Stability AI, Replicate, Ollama

New tools

# Tool Description
8 generate_attack_vector_images Generate images for attack vector artifacts
9 generate_evidence_images Generate images for evidence/forensic artifacts
10 generate_atmosphere_images Generate atmospheric/cover art images

Artifact routing

Rendering path Subtypes
HTML template (crisp text, no API key needed) phishing_email, ransomware_note, fraudulent_invoice, network_capture, dark_web_listing, scada_interface
AI provider usb_device, network_diagram, period_photograph, portrait, location_illustration, cover_art

New files

  • generators/generate-images.ts — multi-provider AI image generation
  • generators/generate-html-artifacts.ts — six self-contained HTML/CSS templates

Test plan

  • Run bun run test-mcp.ts — all 83 assertions pass (including Tests 25–26 for HTML template path)
  • Call generate_attack_vector_images with type: 'email' artifact — verify html_data is set, image_data is undefined
  • Call generate_evidence_images with type: 'log' artifact — verify Wireshark-style table renders with correct row count
  • Set OPENAI_API_KEY and call with image_subtype: 'usb_device' — verify AI provider is called and image_data base64 is returned
  • Run full pipeline: inject email artifact → generate_attack_vector_imagesgenerate_exercise → open facilitator.html — verify email template renders with readable text

🤖 Generated with Claude Code

klausagnoletti and others added 6 commits March 6, 2026 17:13
Converts the TabletopExercise skill into an MCP server so AI coding
agents can enrich M&M scenario cards in a schema-validated,
additive-only way.

New files:
- generators/schema.ts — Zod v3 schemas as single source of truth for
  types, MCP validation, and the tabletop://schema resource
- generators/mcp-server.ts — MCP server (StdioServerTransport) with
  6 tools and 3 resources
- generators/test-mcp.ts — integration tests via InMemoryTransport
  (39/39 passing)
- CLAUDE.md — project coding standards (security, TypeScript, MCP
  tool design, code quality)
- .gitignore — excludes node_modules and generated test HTML

Modified files:
- generators/generate-pdf.ts — exports generateTabletopHTML(data, mode)
  wrapper; existing generatePDF and CLI entry point untouched
- generators/package.json — adds @modelcontextprotocol/sdk, zod,
  zod-to-json-schema; adds mcp and test scripts

Tools: check_scenario_completeness, validate_exercise_data,
generate_exercise, merge_exercise_data, validate_m_and_m_formatting,
list_scenario_cards

Resources: tabletop://schema, tabletop://atomics, tabletop://template

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…and-monsters)

Implements native Quarto markdown output for the M&M handbook:
- generate-qmd.ts: formatting helpers, guards (safeQmd, validateTestNetIPs,
  validateContemporaryReadAloud), variation block wrapping, section renderers
  for Inject Sequence / NPC Dialogue / Red Herrings / Gap Analysis, handout
  renderer with verified CSS block
- mcp-server.ts: registers generate_exercise_qmd as Tool 6; populates
  MALMON_FAMILIES with all 13 canonical names from M&M scenario-cards
- schema.ts: extends all sub-schemas with QMD-specific fields (trigger,
  read_aloud, artifact_inline, hint_if_stuck, NPCDialogueLinesQMD union,
  RedHerringSchema, handout artifact fields, etc.)
- test-mcp.ts: adds 6 new integration tests (Tests 13-18) covering basic
  generation, handout output, em dash guard, contemporary read_aloud
  violation, TEST-NET IP validation, path traversal; 63/63 pass

Verified: quarto render on lockbit/hospital-emergency fixture produces
clean HTML with no warnings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…stral Vibe

Documents setup for all four CLIs with correct config formats:
- Claude Code: claude mcp add CLI command
- Gemini CLI: ~/.gemini/settings.json (JSON mcpServers block)
- OpenAI Codex CLI: codex mcp add command + config.toml format
- Mistral Vibe: ~/.vibe/config.toml TOML format

Also adds v3.0 version entry and updated file structure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three new MCP tools for visual artifact rendering:
- generate_attack_vector_images: phishing emails, ransomware notes, invoices, USB photos
- generate_evidence_images: SIEM/Wireshark captures, dark web listings, SCADA HMI
- generate_atmosphere_images: cover art, NPC portraits, location illustrations

Routing strategy — UI subtypes use CSS/HTML templates (no API key needed,
text always legible); physical subtypes use AI image providers:
- HTML templates: phishing_email, ransomware_note, fraudulent_invoice,
  network_capture, dark_web_listing, scada_interface
- AI providers: usb_device, network_diagram, portrait, location_illustration,
  cover_art, period_photograph

AI provider chain: IMAGE_PROVIDER accepts comma-separated fallback list
(openai,replicate). Providers: OpenAI DALL-E 3, Gemini Imagen 4, Stability AI,
Replicate Flux Schnell, Ollama (self-hosted). API keys from .env or shell.

Schema: adds ImageSubtypeSchema (12 subtypes), VisualStyleSchema, image_data,
html_data, and cover_image_data fields.

PDF/HTML output: generate_exercise renders html_data as inline <div> embed and
image_data as <img>; generate_exercise_qmd writes [slug].png for handouts.

Tests expanded from 63 to 83 assertions (Tests 19–26 cover image paths).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant