← Back to dashboard
hazina-mcptoolingfreshReader view (for NotebookLM)

Hazina MCP Integration Guide

What is the Hazina MCP?

The real model

McpServer + registerTool over StdioServerTransport, bridged into Windows by wsl.exe.

The live server is codeAmani-Solutions/hazina 0.3.0, built on the v1 SDK (@modelcontextprotocol/sdk ^1.29, Zod 3 input shapes) and wired with server.connect(new StdioServerTransport()). That makes it a legacy-era server: it speaks the 2025 initialize handshake, while the current MCP spec (2026-07-28) is stateless, with per-request _meta and server/discover. The planned move is SDK v2 (@modelcontextprotocol/server 2.3.1, z.object schemas, serveStdio), which serves both eras. v1 gets fixes only for at least six months after 2026-07-27. stdout is reserved for the protocol, so every log goes to stderr, and one stray console.log corrupts the stream. The vault is the Linux source of truth at ~/.codeamani/hazina, and its master key is DPAPI-wrapped — the Linux launcher shells back out to Windows powershell.exe over WSL interop to unwrap it, so key custody stays with the Windows account. Windows clients (Cursor's Grok bot, Claude Code desktop) reach it via wsl.exe -d Ubuntu -- /home/barnabas/.local/bin/hazina-mcp. Do not add an env block to that config: it applies to the Windows process and only crosses into Linux via WSLENV, so a HAZINA_HOME set there is silently ignored and you quietly bind against the wrong vault. For codeAmani this is the difference between convenience and exposure — Daraja consumer secrets and Stripe live keys are the crown jewels, and an M-Pesa credential in a summarized transcript is real money.

Five Hazina MCP primitives

Transport, trust boundary, and the bridge that joins two operating systems.

Hazina MCP Integration Guide

Focus: running codeAmani's first-party Hazina MCP server from WSL and exposing it to Windows-side agents (Cursor's Grok bot, Claude Code desktop) without ever moving the vault.

Overview

Most MCP servers in this stack are vendor-hosted and remote: you point a URL at them and attach a bearer token. Hazina is the opposite. It is a local stdio server you own, launched as a child process, speaking JSON-RPC over stdin/stdout. There is no network listener and no endpoint to leak.

It sits in front of the Hazina encrypted secrets vault. The core design rule is that no MCP tool returns a secret value. Agents get names, references, wiring graphs and readiness reports. Two tools move real values, and both move them outward: inject writes a gitignored env file the agent never reads back, and push sends values to Vercel or Netlify. That is what makes it safe to hand to an autonomous agent.

Source of truth is Linux. The vault lives at ~/.codeamani/hazina inside WSL. The Windows copy under C:\Users\info\.codeamani\hazina is archive-only (it carries an ARCHIVED.md). Do not create new bindings against it.

Which code is which (read this first)

Three codebases carry the Hazina name. Only one of them is what your agents talk to.

CodebaseVersionMCP toolsRole
codeAmani-Solutions/hazina (private), checked out at ~/projects/hazina in WSL0.3.014Live. The vault, CLI, local web portal and the MCP server. ~/.local/bin/hazina-mcp symlinks to its bin/hazina-mcp.
codeAmani-Labs/hazina-mcp (private), checked out at ~/projects/hazina-mcp0.1.014 (declared as data)Standalone MCP layer behind a VaultAdapter port, with an in-memory adapter and a four-client test suite. Installed but not the live launcher.
packages/hazina in this repo0.1.06Historical monorepo snapshot. Do not install from it. Its guard still lacks the 16-char floor.

Verified on 2026-10-20 by reading each repo's source and resolving the WSL symlink (readlink -f ~/.local/bin/hazina-mcp → /home/barnabas/projects/hazina/bin/hazina-mcp). The tool table below describes the live 0.3.0 server.

Official Documentation

Hazina's own repos are private. Their docs ship in-tree: docs/INSTALL.md and docs/UBUNTU-GLOBAL.md in codeAmani-Solutions/hazina; docs/CLIENTS.md, docs/TOOLS.md, docs/TESTING.md and SECURITY.md in codeAmani-Labs/hazina-mcp.

The protocol moved: MCP 2026-07-28 and SDK v2

The current MCP revision is 2026-07-28. It drops the stateful initialize handshake:

  • Every request carries its protocol version in _meta (io.modelcontextprotocol/protocolVersion), along with client capabilities and client info. The server accepts or rejects each request on its own.
  • server/discover is a mandatory RPC that returns supported versions, capabilities and server identity in one call.
  • Revisions 2025-11-25 and earlier are now the legacy (initialize-based) era. On stdio, a dual-era client probes with server/discover and falls back to initialize on any error that is not a recognised modern error.

The TypeScript SDK split to match:

v1 (legacy line)v2 (stable line)
Package@modelcontextprotocol/sdk 1.32.1@modelcontextprotocol/server 2.3.1 (+ /client, /core)
Imports@modelcontextprotocol/sdk/server/mcp.js, .../server/stdio.js@modelcontextprotocol/server, @modelcontextprotocol/server/stdio
Input schemaraw Zod shape { project: z.string() } (Zod 3 or 4)z.object({...}), Zod ^4.2 required
stdio entryserver.connect(new StdioServerTransport())serveStdio(createServer), which serves both eras
Supportbug and security fixes for at least six months after v2 shipped (2026-07-27)current

Per the official build-server tutorial, a v2 server wired by hand with server.connect(new StdioServerTransport()) "only serves 2025-era clients". Use serveStdio with a factory that returns a fresh McpServer on every call.

Where Hazina stands. All three Hazina codebases depend on @modelcontextprotocol/sdk ^1.29.0 and zod ^3.23.8. They use server.connect(new StdioServerTransport()), so Hazina is a legacy-era server. Today's clients (Claude Code, Cursor, Grok Build) still open with initialize or fall back to it, so nothing is broken. The risk is time: v1 fixes are only promised until about late January 2027. The migration is small: swap the package, wrap each input shape in z.object(), move to Zod 4, and replace connect() with serveStdio(). A typed, runnable v2 sketch of the Hazina pattern is in examples/value-free-server.mts.

How it is built (live 0.3.0)

Bash
npm install @modelcontextprotocol/sdk@^1.29.0 zod@^3.23.8   # what Hazina pins today
TypeScript
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer({ name: "hazina", version: packageVersion() }); // "0.3.0"

server.registerTool(
  "describe_project",
  {
    title: "Describe a project's secret wiring",
    description: "For a bound project, return each env var, its reference, and status — value-free.",
    inputSchema: { project: z.string().describe("Project name (a binding).") },
  },
  async ({ project }) => guarded(kp, await describeProject(kp, project)),
);

await server.connect(new StdioServerTransport());
console.error("hazina MCP server running on stdio"); // stderr, never stdout

Two rules follow from the stdio transport, and you cannot break them:

  • stdout is the protocol channel. All logging goes to stderr. A stray console.log corrupts the JSON-RPC stream and the client drops the server.
  • The client owns the lifecycle. It spawns the process. There is no port and no daemon, which is also why there is no authentication layer: there is no network surface to protect.

The value-free guard

Every tool result passes through guarded() before it leaves the process. It re-loads the catalog and calls assertNoValues(), which throws rather than returning if any catalog value appears as a substring of the serialized payload. A future buggy handler therefore cannot leak a value across the agent boundary.

The guard only checks values of at least MIN_ASSERTED_SECRET_LEN = 16 characters. Without that floor, short non-secret values (a 1 flag, a / redirect path) substring-match every count and path, and every tool fails with a "leak" that never happened. That outage happened on 2026-08-19 and was fixed on 2026-08-20 in both private repos (650ed20 in the vault, 5e38bc4 in hazina-mcp). The constant must stay identical in the two repos.

codeAmani-Labs/hazina-mcp adds a second layer on top of the known-value check: a credential prefix list (sk_live_, whsec_, ghp_, sk-ant-, hf_, AKIA, …) and a Shannon-entropy heuristic (tokens of 24+ chars at ≥ 4.0 bits/char, with references containing / or # exempt). The live 0.3.0 vault server uses only the known-value check.

Install (WSL)

Bash
cd ~/projects/hazina            # clone of codeAmani-Solutions/hazina
npm install
npm run install:global          # symlinks ~/.local/bin/hazina and ~/.local/bin/hazina-mcp
hazina version                  # 0.3.0
hazina doctor                   # readiness: vault, key, DPAPI path, counts (names only)
hazina mcp                      # prints the agent config snippet

Requirements: Node 20+, and WSL interop enabled (the DPAPI unwrap shells out to powershell.exe). Re-run npm install && npm run install:global after every pull.

The hazina-mcp launcher is a bash wrapper. It resolves its own symlinks and then:

  • exports HAZINA_PKG_ROOT (the package root) and HAZINA_HOME, which defaults to $HOME/.codeamani/hazina
  • prepends the newest nvm Node to PATH when ~/.nvm/versions/node exists, because a non-login wsl.exe -d Ubuntu -- shell otherwise resolves Ubuntu's /usr/bin/node, often Node 18
  • appends /mnt/c/Windows/System32/WindowsPowerShell/v1.0 to PATH if powershell.exe is not reachable, because the master key is DPAPI-wrapped and is unwrapped through Windows
  • execs node --import file://…/tsx/dist/loader.mjs src/mcp/server.ts

Because the launcher supplies its own HAZINA_HOME, Windows client configs need no env block. See the WSLENV note under Gotchas.

SettingDefaultNotes
HAZINA_HOME$HOME/.codeamani/hazinaVault directory: vault.enc, master.key.dpapi, bindings/, audit.log
HAZINA_PKG_ROOTthe package root (parent of bin/)Where the code lives
HAZINA_POWERSHELLpowershell.exe on PATHOverride the PowerShell binary used for OS-env import
HAZINA_MCP_ADAPTERhazinahazina-mcp repo only: set to memory for synthetic fixtures

None of these are secrets. They hold paths and mode names.

The 14 tools (live 0.3.0)

All 14 are value-free. Input names are taken from src/mcp/server.ts in codeAmani-Solutions/hazina.

ToolInputsWhat it returns
statusnoneinitialized, entry count, bound-project count
doctornoneReadiness: HAZINA_HOME, vault/key presence, PowerShell DPAPI path, counts
list_refsnoneEvery reference: path, type, tags, field names
list_projectsnoneProject names that have a binding
get_bindingprojectenv-to-ref mappings, binding path, env file. Literals show as literal: true without their value
describe_projectprojectEach env var, its ref, status ok / missing / stale / os-env
wiring_summaryproject?, maxEdges? (default 500)project → namespace edges, byNamespace counts, truncated flag
auditproject?Catalog vs bindings: stale, unused, unresolved refs
propose_bindingproject, projectDir (absolute)Scans the first of .env.example / .env.local / .env, proposes refs by name match. Does not write
bindproject, projectDir?, envFile?, add?: [{env, ref}], lit?: [{env, value}], detect?Creates or updates a binding. lit is for non-secrets only (ports, public URLs)
unbindproject, envRemoves one ENV name. Does not delete the vault secret
import_from_os_envnamespace? (default windows-env), keys?, prefix?, scopes?: process|user|machine, overwrite?Imports from the OS / Windows env. Returns key names imported or skipped
injectproject, check?Writes the gitignored env file. Returns which keys were written, missing or stale
pushproject, provider: vercel|netlify, target?, check?, site?, replaceExisting?Pushes resolved values to the host. Returns key names pushed or skipped

There is no reveal, get_value, read_secret, decrypt or export_vault tool, by design. The only value-printing path is the human-run CLI hazina get <path> --reveal (or the portal's Reveal button), and both write an audit-log line.

Statuses explained: stale means the entry is past its rotation window. os-env means the ref is missing from the vault, but inject will fill it from the process, then the Windows User, then the Machine environment under the same ENV name.

CLI essentials (human side)

CommandPurpose
hazina initCreate the vault and the DPAPI-wrapped key
hazina add <path> [--type env|apikey|account|note|file] [--field f ...] [--tag t]Store an entry. The value is read from a hidden prompt, never argv
hazina list [--type T] [--tag G] / hazina projectsPaths, types, field names / bound projects
hazina bind <project> --path DIR --dotenv .env.local --add ENV=ns/ref [--lit ENV=value] [--detect]Wire a project. Use --dotenv (or --env-name), not --env-file, which Node 20+ intercepts
hazina inject <project> --check then hazina inject <project>Dry-run drift report, then write. --no-os-env disables the OS-env fallback
hazina inject --check-allLauncher shortcut: dry-run every bound project
hazina audit [project] · hazina graph [project] [--json]Stale/unused/unresolved refs · wiring graph
hazina import --from <.env> · --from-env --keys A,B --scope user · --markdown <file> [--apply]Migrate existing secrets in
hazina push <project> --provider vercel|netlify [--target …] [--check]Sync to a host
hazina export --out FILE / hazina restore --backup FILEscrypt + AES-256-GCM backup, independent of DPAPI
hazina web [--port N]Local portal on http://127.0.0.1:4318 (loopback only, per-session token)
hazina get <path[#field]> [--reveal]Masked by default. --reveal is the only value-printing command, and it is audited

Exit codes: 0 ok, 1 error, 2 drift (missing or stale refs).

References are namespace/name (field value) or namespace/name#field, for example github/login#password.

Wiring it to clients

Where the client runs decides whether you need the bridge.

ClientRuns onConfig fileCommand
Grok Build (CLI)inside WSL~/.grok/config.toml/home/barnabas/.local/bin/hazina-mcp
Claude Code (in WSL)inside WSL~/.claude.json/home/barnabas/.local/bin/hazina-mcp
Cursor / Grok botWindows~/.cursor/mcp.jsonwsl.exe bridge
Claude Code desktopWindows~/.claude.jsonwsl.exe bridge

The Claude Desktop app reads claude_desktop_config.json, a different file. It is deliberately not wired to Hazina.

Windows clients: the wsl.exe bridge

JSON
{
  "mcpServers": {
    "hazina": {
      "type": "stdio",
      "command": "wsl.exe",
      "args": ["-d", "Ubuntu", "--", "/home/barnabas/.local/bin/hazina-mcp"]
    }
  }
}

wsl.exe passes stdin/stdout through unchanged, so the JSON-RPC stream crosses the boundary intact. The same block works in ~/.cursor/mcp.json and in ~/.claude.json. Confirm the distro name with wsl.exe -l -q.

WSL-native clients

TOML
# ~/.grok/config.toml
[mcp_servers.hazina]
command = "/home/barnabas/.local/bin/hazina-mcp"
Bash
claude mcp add --scope user hazina -- /home/barnabas/.local/bin/hazina-mcp
claude mcp get hazina      # read it back

In claude mcp add, everything after -- is passed to the server untouched. --scope user writes to ~/.claude.json for all projects. The default local scope writes there too, but only for the current project.

Restart the client after any tool change. Clients cache the tool list they read when they connect.

Verifying the bridge

Do not trust the config. Speak the protocol to it. Hazina is a legacy-era server, so open with initialize:

Bash
export MSYS_NO_PATHCONV=1   # only needed in Git Bash
printf '%s\n' \
 '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"1"}}}' \
 '{"jsonrpc":"2.0","method":"notifications/initialized"}' \
 '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
 | wsl.exe -d Ubuntu -- /home/barnabas/.local/bin/hazina-mcp

Expect "serverInfo":{"name":"hazina","version":"0.3.0"} followed by 14 tools. tools/list never calls a handler, so the probe decrypts nothing. reference/probe.sh --era also sends a server/discover request: an error there confirms the server is still on the legacy era.

SymptomCause
silent stdout, error on stderrlauncher problem: no Node 20+, missing tsx, bad path
serverInfo but zero toolsregistration problem in src/mcp/server.ts
both correct, client still blindclient config problem, wrong scope, or the client needs a restart

Gotchas

  • env does not cross the WSL boundary. An env block in a Windows mcp.json sets variables on the Windows wsl.exe process. Linux only inherits what WSLENV forwards, so a HAZINA_HOME set there is silently ignored and the server opens its default vault. Rely on the launcher default, or put the override on the Linux side of --: wsl.exe -d Ubuntu -- env HAZINA_HOME=/home/barnabas/.codeamani/hazina /home/barnabas/.local/bin/hazina-mcp. (An env block is fine in WSL-native configs, which is why the vault's own docs show one there.)
  • Git Bash rewrites Linux paths. Running claude mcp add … -- wsl.exe -d Ubuntu -- /home/… from Git Bash once wrote C:/Program Files/Git/home/… into ~/.claude.json, a config that parses but can never spawn. Set MSYS_NO_PATHCONV=1 or use PowerShell, and always read the entry back.
  • Node 18 under non-login WSL. "Works in my terminal, fails under the agent" usually means wsl.exe -d Ubuntu -- resolved /usr/bin/node. Compare wsl.exe -d Ubuntu -- node -v with wsl.exe -d Ubuntu -- bash -lc 'node -v'. The launcher's nvm fix covers this.
  • DPAPI needs Windows reachable. If interop is disabled, the vault cannot open. doctor reports powershellPath: null for exactly this case.
  • Distro name is load-bearing. -d Ubuntu must match wsl.exe -l -q exactly.
  • Never log to stdout in a stdio server.
  • Don't store non-secrets in the vault. Feature flags, redirect paths and region names belong in --lit literals, not catalog entries. That is what the 16-char guard floor assumes.

Known drift (as of 2026-10-20)

  • codeAmani-Labs/hazina-mcp's real adapter does not match the live handlers. src/adapters/hazina.ts calls bindProject(kp, project, env, ref), pushProject(kp, project, host), importFromOsEnv(kp, scope, names), getBindingView(kp, project) and wiringSummary(kp, project). The 0.3.0 handlers take option objects, and getBindingView takes only project. If you run that server against the real vault, bind, push and import_from_os_env will throw, and get_binding and wiring_summary will return wrong results. The read tools are unaffected. Fix the adapter before switching the launcher to hazina-mcp.
  • Tool input names differ between the two private repos (push.host vs push.provider, propose_binding.root? vs projectDir, bind single env/ref vs add[]/lit[]). This guide documents the live 0.3.0 names.
  • packages/hazina in this repo still has v.length > 0 in assertNoValues, which is the pre-fix bug. Don't run it against the real vault.
  • The Vercel push can fall back to argv. src/connectors/vercel.ts sends the value over stdin first. If that fails, it retries with vercel env add NAME TARGET --value <secret>, which puts the value in the process list for the life of the call. The Netlify push always uses a 0600 temp file. On a shared or monitored host, prefer inject plus the host's own import, or remove the fallback in the vault repo.

Hazina vs the vendor MCPs

HazinaCloudflare / Vercel / xAI
Transportlocal stdio (child process)remote Streamable HTTP
Protocol eralegacy (initialize, SDK v1)vendor-dependent
Config keycommand + argsurl + Authorization header
Authfilesystem + DPAPI-wrapped keybearer API token / OAuth
Ownershipfirst-party, privatevendor-hosted
Failure modeprocess will not spawn401 / network
Secrets exposurenone: value-free toolstoken sits in the config

The vendor configs carry ${CLOUDFLARE_API_TOKEN}-style headers. Hazina exists to get rid of exactly that kind of token sprawl. See cloudflare/, vercel/ and xai/ for the vendor-side guides.

codeAmani notes

  • Zero exposure is the product. Never add a tool that returns a secret value. If an agent needs a value, it needs inject writing a gitignored file, not a tool result in a transcript that gets logged, summarized and cached. A tool that cannot answer its question without plaintext belongs on the CLI, where a human is present.
  • One vault, Linux SoT, one launcher. ~/.codeamani/hazina in WSL, reached only through ~/.local/bin/hazina-mcp. The Windows path is archived, and new bindings against it will drift.
  • Secrets stay server-side, and Hazina stays local. Never deploy the MCP server to Vercel or expose it over HTTP. The portal binds to 127.0.0.1 only.
  • Payments secrets. Stripe is the default rail, so stripe/* refs are in most bindings. Daraja (M-Pesa) consumer keys and passkeys belong in the vault only for Kenya-targeted projects (the WhatsApp + M-Pesa batch in codeAmani-labs-projects/). Bind them by reference. A leaked Daraja credential is real money.
  • AI keys. Anthropic is primary and OpenAI secondary. Bind anthropic/* and openai/* refs per project rather than copying keys between .env.local files, so a rotation reaches every bound app with one hazina rotate.
  • Audit before shipping. Run audit (stale refs) and wiring_summary (which project pulls which namespace) before any release that touches env config. Run gitleaks before every push.
  • Vault data lives outside the repo. audit.log records actions and counts, never values, but it does reveal project and namespace names. Keep it out of git and off shared storage.
  • Plan the SDK v2 migration before v1 support ends (at least six months from 2026-07-27). Do it in codeAmani-Solutions/hazina first, since that is the live server, then mirror it in hazina-mcp, together with the adapter fix above.