Appearance
AI Driver Builder MCP
The AI Driver Builder MCP server lives at apps/mcp-driver-builder. It gives AI assistants a constrained way to generate reviewable Haptique OS local driver packages from a plain-language device description.
This is an OS-local workflow. It uploads through the HOS Integration Manager package path and does not replace Fleet cloud integrations or legacy /integration/... routes.
The legacy product entry point remains /os/driver-integrations/ai-builder. The primary broader surface is now OS Builder Chat under AI Chat Development Mode. HOS acts as the MCP host, connects to the local stdio Driver Builder MCP server, and lets the selected AI provider call driver-builder tools through the HOS-owned agent loop. Supported in-OS inference providers are Local, OpenRouter, and Gemini API.
Important service boundary:
apps/mcp-driver-builderowns driver schema, generation, validation, packaging, artifact versioning, and controlled driver-doc research.apps/mcp-serviceis the general OS MCP service used by the OS Builder Chat agent to call HOS tools and APIs.apps/llama-serviceis the older OS AI runtime compatibility path.- Gemini is a model/provider backend only in v1. HOS does not expose Gemini CLI shell/file tools to end users.
Runtime Targets
| Runtime | Upload file | Status |
|---|---|---|
javascript | .js | First-class local driver runtime. Uses Node-compatible CommonJS and newline-delimited JSON over stdin/stdout. |
python | .py | Local driver runtime using the same JSON-line process contract. |
lua | .lua | Local command-oriented driver runtime. |
typescript | compiled .js | Authoring/generation option only. Raw .ts is not accepted in OS driver ZIP uploads for v1. |
JavaScript drivers use the HOS-managed JavaScriptDriverProcess. It starts Node with a configurable binary (HOS_NODE_BINARY or process.execPath), forwards stderr, parses stdout JSON lines, writes commands to stdin, and terminates with SIGTERM before SIGKILL fallback.
Generated Package Contract
A valid generated package contains:
- Exactly one
*.driver.jsonmanifest. - Exactly one
.py,.lua, or.jsdriver implementation. - Optional
README.md. - Optional
package.jsononly when a JavaScript driver needs external dependencies.
For JavaScript v1, dependency-free packages are preferred. Generated JS drivers should use Node 20+ built-ins such as fetch, net, dgram, and readline where possible.
Manifest Requirements
The manifest drives the Integration Manager listing, setup form, logical-device UI, command catalog, and runtime launch.
Required behavior:
driverTypemust bepython,lua, orjavascriptfor local uploaded drivers.driverFilemust point to the matching implementation file.propertiesdefine the Integration Manager setup form.commandsdefine user-visible actions and command payload schemas.iodefines integration inputs/outputs for UI and topology display.envMapmaps setup properties into runtime environment variables.
Driver Protocol Requirements
Generated local drivers must emit and handle the same core protocol concepts as remote WebSocket drivers:
| Direction | Message | Required behavior |
|---|---|---|
| Driver to HOS | DEVICE_DISCOVERED | Create or refresh logical devices. |
| Driver to HOS | STATE_UPDATE | Publish current runtime state. |
| Driver to HOS | ACTION_RESULT | Report command success/failure. |
| Driver to HOS | METRIC_UPDATE | Optional telemetry. |
| HOS to driver | ACTION | Execute a user or automation command. |
| HOS to driver | COMMAND_EXECUTE | Execute command-catalog driven actions. |
Generated JavaScript templates support HTTP, TCP, UDP, WebSocket-device, and generic polling patterns. They should keep credentials in environment variables or setup properties, never hard-code secrets.
MCP Tool Workflow
The MCP app exposes tools that let an AI assistant:
- Read HOS driver context and schema rules.
- Find similar reference drivers.
- Draft an implementation plan from device documentation.
- Generate a manifest.
- Generate driver code.
- Validate the manifest and code.
- Build an uploadable ZIP package.
- Hand off upload instructions for the HOS Integration Manager.
The upload route remains the existing Integration Manager validation path. Direct MCP upload should only be added if it reuses that same validation and auth model.
In-OS Chat Flow
The in-OS user flow is:
- Open Integration Manager.
- Click AI Driver Builder.
- Ensure AI Settings has Local, OpenRouter, or Gemini configured and the AI service is running.
- Pick the model from the composer footer when a different Driver Builder model is needed.
- Describe the device, protocol, API endpoints, auth, and desired commands.
- The selected provider calls
driver_builder_*tools through HOS. - HOS calls the MCP server and saves generated ZIP output as an artifact under
storage/ai/driver-builder/. - The UI shows downloadable artifacts for review and Integration Manager upload.
This keeps MCP local to the OS process while allowing the model itself to be local, OpenRouter-backed, or Gemini-backed. Users do not need Claude Desktop, Gemini CLI, ChatGPT developer mode, or manual MCP configuration for the main product flow.
OS Builder Chat can also route driver requests through managed AgentTask state:
- User starts a Development Mode prompt.
- HOS creates an OS Builder task with intent, plan, steps, activity, artifacts, and approval requests.
- Read-only tool calls and driver package generation can run automatically.
- Installing packages or changing OS configuration requires preview plus approval.
- Generated driver artifacts remain available for review, tagging, revision, and Integration Manager upload.
OpenRouter generation uses OPENROUTER_TIMEOUT_MS, defaulting to 120000 ms, because driver-building prompts can take substantially longer than ordinary chat completions.
The Driver Builder agent loop uses AI_DRIVER_BUILDER_MAX_TOOL_ITERATIONS, defaulting to 12. Successful driver_builder_generate_package calls are terminal: the agent returns the generated artifact summary immediately instead of spending extra model steps summarizing.
The OS controller waits up to AI_DRIVER_BUILDER_SYNC_TIMEOUT_MS, defaulting to 300000 ms, for in-OS chat generation to finish.
Controlled Internet Sources
Driver Builder can use internet sources for device API exploration, but only after the user approves the chat-time prompt in AI Builder.
Allowed sources:
- Vendor documentation and manuals.
- Public API/reference/developer docs.
- GitHub examples and public driver samples.
- Public documentation pages relevant to driver implementation.
Blocked or rejected sources:
localhost, private LAN IPs, link-local addresses, and loopback URLs.- URLs containing embedded credentials.
- Non-HTTP protocols.
- General web pages that do not look like documentation, API, support, wiki, reference, integration, or GitHub example pages.
The permission is short-lived and scoped to the Driver Builder request. The model must include source URLs in the AI Builder chat when those sources influence generated code. Generated packages remain reviewable artifacts and are not installed automatically.
Using the AI Driver Builder
The AI Driver Builder is available inside Haptique OS under Integration Manager → AI Driver Builder. No CLI setup is required — the MCP server runs as part of the OS process.
To use it:
- Open Integration Manager in the HOS admin UI
- Click AI Driver Builder
- Ensure AI Settings has Local, OpenRouter, or Gemini configured
- Describe your device, protocol, API endpoints, auth method, and desired commands
- The AI generates a complete driver package (manifest + implementation)
- Download the artifact and upload it through Integration Manager
Cross-References
- HOS Overview — conceptual driver architecture.
- Server Internals — local process runtime and protocol event flow.
- API Reference — WebSocket and local-driver protocol notes.