⚡ Official ClickHouse MCP Runtime Integration

Cinema Command actively uses the official ClickHouse MCP server (ClickHouse/mcp-clickhouse) at runtime, connected to our ClickHouse Cloud cluster.

Gemini-powered specialist agents do not query ClickHouse directly for decision evidence. When historical operational evidence is required, the Cinema Command backend invokes the official MCP server through Model Context Protocol and calls its run_query tool.

Runtime path:

Specialist Agent → MCP Client → official mcp-clickhouse → run_query → ClickHouse Cloud → Evidence Object → deterministic normalization → scenario re-scoring

In the hero decision, the Scheduling Agent identifies the compressed-turnaround risk and escalates to the Camera Agent, which investigates comparable transitions through mcp-clickhouse. The returned synthetic historical evidence is converted into deterministic Cost and Operational Risk adjustments.

  • Without ClickHouse evidence → Friday remains the baseline winner at 89.
  • With official mcp-clickhouse runtime evidence → Friday falls to 72 and Saturday becomes the Best Future at 91.

ClickHouse is not merely persistence: an official ClickHouse MCP runtime tool call materially changes which production future the application recommends.

All historical counts and rates in the demo are computed from our synthetic seeded dataset and are not presented as industry-wide statistics.


Inspiration

In high-stakes Hollywood film and television production, schedule disruptions—such as sudden weather threatening an exterior night stunt shoot—force Line Producers and Unit Production Managers (UPMs) to make multi-million-dollar rescheduling decisions in minutes.

On paper, shifting an exterior shoot to Friday night often looks like the quickest, cheapest option. But in physical production, naive heuristics hide catastrophic operational traps:

  • Turnaround breaches: Violating a modeled 11-hour contractual rest threshold in the demo scenario between wrap and call.
  • Cascading overtime pay penalties: Severe turnaround buyouts, penalty tiers, and meal penalty violations.
  • Hazardous crew fatigue and logistics gridlock: Camera/lighting re-rigging bottlenecks across distant physical locations without sufficient rest.

We realized that large language models should not hallucinate high-stakes operational scores on their own. Autonomous agents must investigate, code must score deterministically, and reproducible warehouse evidence must ground the final decision.

This inspired Cinema Command: an autonomous multi-agent decision intelligence platform that simulates competing production futures, queries historical shooting telemetry via the official ClickHouse Model Context Protocol server (ClickHouse/mcp-clickhouse), and uses Google Cloud Vertex AI & Gemini to synthesize explainable executive debriefs for human-in-the-loop sign-off.


What it does

When an operational crisis strikes Scene 42 (Apex Protocol • Night Waterfront Stunt), Cinema Command executes an autonomous decision intelligence loop:

  1. Simulates Competing Futures: Generates parallel operational candidate scenarios:
    • Future A (Hold Thursday): Shoot exterior night in the rain (78% squall risk, stunt hazard).
    • Future B (Push to Friday Night): De-rig heavy gear and compress turnaround to 7.8 hours (hidden union conflict trap).
    • Future C (Push to Saturday Night): Staged company move, a 14.2-hour modeled rest window, full dry window, compliant permits (optimal).
  2. Orchestrates a 6-Agent Autonomous Specialist Fleet: Autonomous agents investigate the disruption across specialized domains:
    • Weather Agent: Assesses precipitation probabilities (78% marine layer risk) and wind limits for stunt cranes.
    • Budget Agent: Forecasts daily burn rates ($145,000 baseline) and overtime penalty tier cascades.
    • Scheduling Agent: Audits union rest rules under industry contracts (flagging Friday's 7.8h modeled turnaround against the configured rest threshold).
    • Camera Agent: Analyzes heavy equipment and anamorphic lens package transit bottlenecks between basecamp and the wharf.
    • Cast Agent: Tracks lead actor rest windows, meal penalties, and cognitive fatigue indices.
    • Logistics Agent: Audits municipal street closure permits and marine police harbor coordination.
  3. Executes the Sponsor Necessity Test via official ClickHouse MCP (mcp-clickhouse):
    • Under naive planning (without ClickHouse telemetry), Friday night appears optimal with a score of 89 out of 100.
    • The Camera Agent queries ClickHouse through the official MCP server using tool run_query (logged with runtime telemetry identifiers such as MCP-Q-###) over 74 synthetic seeded production-event records.
    • ClickHouse uncovers that 19 of 31 comparable synthetic transitions met the incident criterion (equipment conflict or >1.5h overtime), a 61.3% incident rate, revealing elevated modeled turnaround and overtime exposure.
    • Grounded in ClickHouse-returned structured evidence from the seeded synthetic dataset, Friday's score deterministically drops from 89 to 72, and Saturday night rightfully takes the crown at 91 with a 14.2-hour modeled rest window, a 92% clean-wrap rate across 25 comparable synthetic recovery transitions, and an intact budget.
  4. Google Cloud Gemini Executive Synthesis: Using the modern @google/genai SDK with Gemini 2.5 Flash, an Executive Agent synthesizes an audit-ready debrief explaining why Friday was penalized and summarizing the operational trade-offs for studio leadership.
  5. Human-in-the-Loop Governance: The Line Producer reviews the audit trail and confirms the Saturday schedule change in the timestamped Decision Replay sign-off log ("Approved - Line Producer").

How we built it

Cinema Command was designed as a full-stack, enterprise-grade application deployed on Google Cloud Run:

1. Deterministic Multi-Factor Scoring Engine

To prevent non-deterministic score hallucination, we implemented an exact mathematical formulation:

$$\text{Decision Score} = 0.30 \cdot C_{\text{cost}} + 0.25 \cdot S_{\text{schedule}} + 0.20 \cdot R_{\text{resources}} + 0.15 \cdot O_{\text{risk}} + 0.10 \cdot W_{\text{weather}}$$

Where each dimension is evaluated on a normalized scale $[0, 100]$.

2. Official ClickHouse Model Context Protocol (MCP) Runtime

The Cinema Command backend implements the official TypeScript @modelcontextprotocol/client with StreamableHTTPClientTransport. All analytical evidence queries invoke the official ClickHouse/mcp-clickhouse server's run_query tool:

SELECT
  count() AS sample_size,
  countIf(conflict_flag = 1 OR overtime_hours > 1.5) AS incident_count,
  round(incident_count / sample_size, 4) AS incident_rate,
  round(avg(turnaround_hours), 2) AS avg_turnaround_hours,
  round(avg(overtime_cost_usd), 2) AS avg_cost_impact,
  countIf(legal_turnaround_violated = 1) AS turnaround_violations
FROM cinema_command.historical_equipment_transitions
WHERE transition_profile = 'friday_turnaround_compressed'
  AND equipment_profile = 'heavy_vehicle_anamorphic_package_b';

The analytical evidence calculation:

$$\text{Incident Rate} = \frac{\text{incidents}}{N} = \frac{19}{31} \approx 61.3\%$$

$$\Delta \text{Score}_{\text{Friday}} = 89 \xrightarrow{\text{ClickHouse MCP Evidence}} 72 \quad (\Delta = -17)$$

3. Google Cloud Vertex AI & Gemini 2.5 Flash

Built with the modern @google/genai SDK on our Express backend. The Executive Agent invokes Google Cloud Vertex AI using gemini-2.5-flash with strict system instructions to generate:

  • Executive rationale explaining why Friday was disqualified.
  • Structured operational trade-offs (weather risk, budget impact, cast/crew rest).
  • Mitigation recommendations for city permits and staging.

4. Interactive Command UI & Products Used

  • Google Cloud Products: Google Cloud Run, Google Vertex AI, Google GenAI SDK (@google/genai), Gemini 2.5 Flash, Cloud Build, Secret Manager.
  • Other Tools & Technologies: ClickHouse Cloud; official ClickHouse MCP server (ClickHouse/mcp-clickhouse); Model Context Protocol; run_query; @modelcontextprotocol/client; TypeScript; React 19; Vite; Tailwind CSS v4; Motion; Lucide React; Express; Node.js.
  • Live Architecture Features: An Official ClickHouse MCP Evidence Inspector displaying tool receipts and SQL queries, an Agent Escalation Chain Matrix, a Futures Comparison Grid, and a ClickHouse Runtime Verification Panel.
  • Open Source License & Repository Compliance: Released under the Apache-2.0 License (LICENSE file located at repository root, visible on GitHub).

Challenges we ran into

  • Enforcing Official MCP Protocol Rigor: Ensuring that the agent analytical pipeline strictly routes through @modelcontextprotocol/client and the official ClickHouse/mcp-clickhouse service (ghcr.io/clickhouse/mcp-clickhouse:0.4.0) via Streamable HTTP, rather than direct database drivers.
  • Preventing Hallucinatory Decision-Making: Asking an LLM to assign raw numerical scores produces inconsistent rankings. We solved this by strictly separating concerns: deterministic code computes the mathematical metrics and penalties, while Gemini synthesizes qualitative explanations and trade-off debriefs.
  • Cross-Agent Autonomous Escalation: Film departments do not operate in silos. When the Budget Agent detects a turnaround squeeze, the Camera and Logistics agents must automatically investigate equipment transit. We implemented an orchestrator with cross-agent event triggers and message passing.

Accomplishments that we're proud of

  • The Sponsor Necessity Test: Proving mathematically that ClickHouse is irreplaceable. Toggling ClickHouse evidence dynamically swings the winning decision between Friday (89) and Saturday (91), preventing a catastrophic schedule failure.
  • Official ClickHouse MCP Integration: Genuine end-to-end integration with the official ClickHouse/mcp-clickhouse server calling run_query on ClickHouse Cloud at runtime.
  • True Multi-Agent Coordination: Six distinct specialist agents working in concert, sharing evidence, and triggering cross-department escalations.
  • Deterministic Decision Scoring: Final metrics and rankings are code-computed and reproducible; Gemini is restricted to synthesis and explanation, grounded in reproducible warehouse evidence.
  • Full-Stack Security on Google Cloud: All API keys and ClickHouse credentials remain strictly server-side on Google Cloud Run, with zero client-side credential exposure.

What we learned

  • Grounding multi-agent reasoning in fast, analytical column-oriented databases like ClickHouse bridges the gap between creative AI and industrial-grade operational reliability.
  • Model Context Protocol (MCP) provides a clean, standardized abstraction for tool calling that allows agents to query complex data systems with full auditability.
  • Gemini 2.5 Flash provides exceptional latency and structured synthesis capabilities, making it ideal for real-time executive summaries under tight turnaround requirements.
  • In high-value entertainment workflows, human-in-the-loop governance is paramount: AI should advise and simulate, but the Line Producer must hold the final sign-off key.

What's next for Cinema Command

  • Live Doppler Weather Radar MCP Tooling: Ingesting real-time radar telemetry to update precipitation probabilities dynamically down to 15-minute shooting blocks.
  • Automated Call Sheet Generation: One-click dispatch of revised daily call sheets and digital crew notifications upon Line Producer sign-off.
  • Multi-Project Studio Portfolio Analytics: Expanding ClickHouse schemas across multi-movie studio slates to benchmark crew turnaround patterns and director pace across entire production slates.

Built With

  • autonomous-agents
  • clickhouse
  • data-analytics
  • decision-intelligence
  • entertainment-tech
  • express.js
  • film-production
  • gemini-2-5-flash
  • gemini-api
  • google-cloud
  • google-cloud-run
  • lucide-react
  • model-context-protocol
  • motion
  • multi-agent-systems
  • node.js
  • react
  • rest-api
  • sql
  • tailwindcss
  • typescript
  • vertex-ai
  • vite
Share this project:

Updates

Submission history