This is a submission for the Sanity Challenge, Path One: Ship an Agent That Queries Real Content
r674mqrk (Dataset: production)
Building a Eurorack modular synthesizer is notoriously treacherous. Beginners and professional sound designers alike routinely damage expensive hardware due to four silent traps:
+12V, -12V, and +5V. When powering on, analog oscillators and digital DSP modules draw an inrush surge exceeding 150–200% of steady-state draw. Exceeding Racksmith solves this by pairing an autonomous AI agent (powered by the Vercel AI SDK and Gemini 3.8 Flash) with a Sanity Knowledge Lake via a standards-compliant Model Context Protocol (MCP) server. The agent queries structured documents with field-level provenance, evaluates safety through a deterministic mathematical validation engine, surfaces real-world manufacturer errata in an interactive resolution modal, and renders the result in a photorealistic 3D interactive hardware visualizer.
+------------------------------------------------+
| User Browser Client |
| (Next.js 16 + React Three Fiber 3D + Zustand) |
+-----------------------+------------------------+
|
+-------------------+-------------------+
| User Prompt / GUI Actions |
v v
+--------------------+ +---------------------+
| AI Agent Router | | 5-Step Golden Path |
| (Vercel AI SDK + | | Demo Controller |
| Gemini 3.8 Flash) | +----------+----------+
+---------+----------+ |
| Tool Calls |
v |
+-------------------------------------+ |
| Model Context Protocol (MCP) Client | |
| - searchSanityKnowledge | |
| - getModule / getCase | |
| - getContradictions | |
| - validateRackDeterministic | |
| - saveUserDecision | |
+-----------------+-------------------+ |
| Linked Transport |
v |
+-------------------------------------+ |
| Sanity Context MCP Server | |
| (Model Context Protocol Spec 1.2.0) | |
+-----------------+-------------------+ |
| GROQ / Lake Fetch |
v |
+-------------------------------------+ |
| Sanity Lake (r674mqrk) | |
| - 33 Modules | |
| - 4 Cases | |
| - 8 Manufacturers | |
| - 6 Claims with Provenance | |
| - 3 Contradictions with Errata | |
| - UserDecisions (Persisted) | |
+-----------------+-------------------+ |
| |
+---------------+---------------+
|
v
+---------------------------------------+
| Deterministic Validation Engine |
| - HP Width Boundary Check |
| - Mechanical Depth Collision Check |
| - 3-Rail Power & 80% Headroom Buffer |
+-------------------+-------------------+
|
v
+---------------------------------------+
| Photorealistic 3D Eurorack Rack |
| (Anodized Faceplates, Jacks, Collide) |
+---------------------------------------+
In this demonstration, the AI Agent plans a modular synth system autonomously using natural language while querying real content from Sanity:
The user navigates to the AI Agent tab. The agent is initialized with direct tool bindings to the Sanity Context MCP server.
The user enters a complex hardware request:
"Build an ambient sound design rack with complex modulation and reverb, make sure modules fit in depth and don't exceed power limits."
The agent executes tool calls against the Sanity MCP Server:
searchSanityKnowledge: Queries Sanity for ambient sound sources and filters. getModule: Retrieves exact dimensions and multi-rail power draws. validateRackDeterministic: Passes candidate configurations through the mathematical engine, automatically rejecting modules that exceed case depth or violate the 80% power headroom ceiling.
The agent presents its verified reasoning, citing the exact GROQ documents retrieved from Sanity, and directly mounts the optimal modules (Plaits, Rings, Beads, Maths SMD) onto the 3D hardware rack without human intervention.
The complete source code is public and open source on GitHub:
👉 https://github.com/Shreyansh00987/Racksmith
ai/rsc) + Google Gemini 3.8 Flash
If Sanity were replaced with a generic vector database, Racksmith would fail.
A modular synthesizer build requires strict relational invariants:
module.depthMM + clearanceBuffer <= case.maxDepthMM`` sum(module.powerPlus12) <= case.powerCapacityPlus12 * 0.80
In an unstructured vector store, a search for "Make Noise Maths power draw" returns chunk embeddings where "Draws 60mA" and "Draws 90mA under active cycle" look like identical high-confidence semantic matches. An LLM has no mechanism to determine which claim corresponds to which revision or test methodology.
With Sanity, specifications are stored as typed, structured entities with field-level provenance.
module`` hp), mechanical depth ( depthMM), 3-rail current ( powerPlus12, powerMinus12, powerPlus5), category, and manufacturer reference. case``maxDepthMM), and power supply ratings ( manufacturer``claim`` field, value, unit, sourceURL, revision, confidence). contradiction``claimA <-> claimB) with explanation, conflictType, and impactAnalysis. userDecision
The Next.js application exposes an MCP server (/api/mcp) implementing 5 core tools:
// Example: Sanity MCP Tool for Discrepancy & Errata Retrieval
server.tool(
'getContradictions',
'Retrieve known specification contradictions and manufacturer errata',
{ moduleId: z.string().optional() },
async ({ moduleId }) => {
const query = moduleId
? `*[_type == "contradiction" && (claimA->module._ref == $moduleId || claimB->module._ref == $moduleId)]{
_id, title, explanation, impactAnalysis,
claimA->{ field, value, unit, source, revision },
claimB->{ field, value, unit, source, revision }
}`
: `*[_type == "contradiction"]{
_id, title, explanation, impactAnalysis,
claimA->{ field, value, unit, source, revision },
claimB->{ field, value, unit, source, revision }
}`;
const result = await sanityClient.fetch(query, { moduleId });
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
}
);
The agent does not guess math. When an agent wants to evaluate a rack configuration, it calls the validateRackDeterministic MCP tool:
export function validateRack(modules: Module[], targetCase: Case): ValidationResult {
const totalHp = modules.reduce((acc, m) => acc + m.hp, 0);
const hpOverflow = totalHp > targetCase.totalHp;
const depthCollisions = modules
.filter(m => m.depthMM > targetCase.maxDepthMM)
.map(m => ({ module: m.name, moduleDepth: m.depthMM, maxDepth: targetCase.maxDepthMM }));
const currentPlus12 = modules.reduce((acc, m) => acc + m.powerPlus12, 0);
const maxPlus12Safe = targetCase.powerCapacityPlus12 * 0.80;
const power12Overload = currentPlus12 > maxPlus12Safe;
return {
isValid: !hpOverflow && depthCollisions.length === 0 && !power12Overload,
metrics: { totalHp, currentPlus12, maxPlus12Safe },
depthCollisions,
hpOverflow,
power12Overload
};
}
https://racksmith.vercel.app, http://localhost:3000
https://r674mqrk.api.sanity.io/v2024-01-01/data/query/production?query=*[_type=="module"][0...5]{name,hp,depthMM,powerPlus12}
Below is a curated transcript excerpt demonstrating how the agent invokes Sanity MCP tools to safely resolve an ambiguous hardware request:
[
{
"role": "user",
"content": "Build an ambient sound design rack with complex modulation and reverb, make sure modules fit in depth and don't exceed power limits."
},
{
"role": "assistant",
"thought": "The user wants an ambient rack. I must query Sanity Knowledge Lake for modules tagged with 'ambient', 'reverb', or 'modulation'. I will check their depths against standard case clearances.",
"tool_call": {
"name": "searchSanityKnowledge",
"arguments": { "query": "ambient modulation reverb granular" }
}
},
{
"role": "tool",
"name": "searchSanityKnowledge",
"content": [
{ "name": "Mutable Instruments Beads", "category": "granular", "hp": 14, "depthMM": 25, "powerPlus12": 100 },
{ "name": "Mutable Instruments Rings", "category": "resonator", "hp": 14, "depthMM": 25, "powerPlus12": 120 },
{ "name": "Make Noise Maths", "category": "modulation", "hp": 20, "depthMM": 25, "powerPlus12": 90 }
]
},
{
"role": "assistant",
"thought": "I will check for known contradictions on Make Noise Maths before adding it.",
"tool_call": {
"name": "getContradictions",
"arguments": { "moduleId": "module-make-noise-maths" }
}
},
{
"role": "tool",
"name": "getContradictions",
"content": [
{
"title": "Make Noise Maths Power & Depth Errata",
"explanation": "Vintage THT units draw 60mA quiescent and measure 45mm deep. Modern SMD units draw up to 90mA active cycle and measure 25mm deep.",
"impactAnalysis": "Vintage revision will collide with shallow skiff cases (Palette 62)."
}
]
},
{
"role": "assistant",
"thought": "Selecting the Modern SMD revision guarantees 25mm depth, safely fitting within the 45.5mm skiff limit. Now validating total power.",
"tool_call": {
"name": "validateRackDeterministic",
"arguments": {
"caseId": "case-palette-62",
"moduleIds": ["module-plaits", "module-rings", "module-beads", "module-maths-smd"]
}
}
},
{
"role": "tool",
"name": "validateRackDeterministic",
"content": {
"isValid": true,
"totalHp": 60,
"maxHp": 62,
"powerPlus12": 360,
"maxPowerPlus12Allowed": 960,
"depthCollision": null
}
},
{
"role": "assistant",
"content": "I have assembled an ambient sound design rack for you! I verified through the Sanity Knowledge Lake that Make Noise Maths has a known errata between vintage THT (45mm) and modern SMD (25mm). By selecting the modern SMD revision, all 4 modules (Plaits, Rings, Beads, and Maths) safely fit into your 62HP case with 0 depth collisions and consume only 360mA on the +12V rail (well below your 80% safety threshold of 960mA)."
}
]
Built with ❤️ for the DEV & Sanity Community by Shreyansh (@Shreyansh00987)