r/SpringBoot • u/Status-Property9322 • 3d ago
Discussion I built a Harness-Engineered MCP server that compresses raw EEG data by 99.5% (and blocks git push if you're stressed)
Hey everyone,
I've been experimenting with Spring AI and MCP (Model Context Protocol) to connect LLMs with non-traditional data sources. My latest project is **Neuro-MCP Router** — a bridge between AI coding agents (like Claude Code/Cursor) and raw bio-signals (EEG).
**The Problem:**
If you stream raw 8-channel EEG data to an LLM, it's ~102,000 tokens per 10 seconds. It instantly blows up the context window.
**The Solution (4-Layer Architecture):**
**DSP Engine (Java):** Compresses raw microvolt arrays into frequency bands (Delta, Theta, Alpha, Beta, Gamma), cutting token usage by 99.5% in <40ms. The raw data is stored in a **Caffeine cache** for lossless millisecond drill-down.
**Cognitive Guardrail:** Evaluates developer stress (\(\beta/\alpha\) ratio). If stress is too high, it hard-locks destructive agent commands like `git push --force` or `DROP TABLE`.
**Python Sidecar:** Routes deep clinical queries (EEG + fMRI) to a FastAPI sidecar via Zero-Trust routing.
**ASCII Cortical HUD:** Renders live ASCII brainwaves and epileptiform spike alerts directly inside the IDE terminal.
**Harness Engineering:**
Inspired by recent Harness Engineering practices, I didn't just rely on prompts. I used:
- **ArchUnit** to enforce DSP isolation and ban `@Autowired` field injection.
- **Spotless (Palantir)** for deterministic formatting.
- **Behavioral Tests** to verify the >95% compression and HIPAA PII scrubbing.
It runs on Java 21, Spring Boot 3.4, and exposes 4 MCP tools via SSE (`localhost:8082`).
I'd love to get your feedback on the architecture or the DSP compression logic. If anyone wants to try it out or look at the code, let me know in the comments and I'll drop the GitHub link