Hazina MCP Integration Guide

Technology: hazina-mcp · Category: tooling · Last reviewed: 2026-10-20

Source: https://tech-stack.codeamanilabs.org/guide/hazina-mcp

Insight:

Hazina is codeAmani's own MCP server: a local stdio process over the encrypted secrets vault, not a hosted API. Its 14 tools are value-free. Agents can wire, audit and inject secrets by reference, but no tool returns a plaintext value. The vault lives in WSL, so Windows clients reach it through a wsl.exe bridge. It still runs on the v1 SDK (@modelcontextprotocol/sdk) and speaks the 2025-era initialize handshake. MCP 2026-07-28 and SDK v2 are out, and v1 gets fixes only until about late January 2027, so plan the move to serveStdio.

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.

Codebase Version MCP tools Role
codeAmani-Solutions/hazina (private), checked out at ~/projects/hazina in WSL 0.3.0 14 Live. 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-mcp 0.1.0 14 (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 repo 0.1.0 6 Historical 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

Topic URL
MCP specification (current: 2026-07-28) https://modelcontextprotocol.io/specification/2026-07-28
Versioning and backward compatibility https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning
stdio transport https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/stdio
Build an MCP server https://modelcontextprotocol.io/docs/develop/build-server
Connect local (stdio) servers https://modelcontextprotocol.io/docs/develop/connect-local-servers
TypeScript SDK (repo) https://github.com/modelcontextprotocol/typescript-sdk
TypeScript SDK v2 docs / v1 docs https://ts.sdk.modelcontextprotocol.io/v2/ · https://ts.sdk.modelcontextprotocol.io/
MCP Inspector https://modelcontextprotocol.io/docs/tools/inspector
MCP in Claude Code https://code.claude.com/docs/en/mcp
MCP in Cursor https://cursor.com/docs/mcp
WSL filesystem / interop / WSLENV https://learn.microsoft.com/en-us/windows/wsl/filesystems

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:

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 schema raw Zod shape { project: z.string() } (Zod 3 or 4) z.object({...}), Zod ^4.2 required
stdio entry server.connect(new StdioServerTransport()) serveStdio(createServer), which serves both eras
Support bug 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)

npm install @modelcontextprotocol/sdk@^1.29.0 zod@^3.23.8   # what Hazina pins today
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:

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)

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:

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

Setting Default Notes
HAZINA_HOME $HOME/.codeamani/hazina Vault directory: vault.enc, master.key.dpapi, bindings/, audit.log
HAZINA_PKG_ROOT the package root (parent of bin/) Where the code lives
HAZINA_POWERSHELL powershell.exe on PATH Override the PowerShell binary used for OS-env import
HAZINA_MCP_ADAPTER hazina hazina-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.

Tool Inputs What it returns
status none initialized, entry count, bound-project count
doctor none Readiness: HAZINA_HOME, vault/key presence, PowerShell DPAPI path, counts
list_refs none Every reference: path, type, tags, field names
list_projects none Project names that have a binding
get_binding project env-to-ref mappings, binding path, env file. Literals show as literal: true without their value
describe_project project Each env var, its ref, status ok / missing / stale / os-env
wiring_summary project?, maxEdges? (default 500) project → namespace edges, byNamespace counts, truncated flag
audit project? Catalog vs bindings: stale, unused, unresolved refs
propose_binding project, projectDir (absolute) Scans the first of .env.example / .env.local / .env, proposes refs by name match. Does not write
bind project, projectDir?, envFile?, add?: [{env, ref}], lit?: [{env, value}], detect? Creates or updates a binding. lit is for non-secrets only (ports, public URLs)
unbind project, env Removes one ENV name. Does not delete the vault secret
import_from_os_env namespace? (default windows-env), keys?, prefix?, scopes?: process|user|machine, overwrite? Imports from the OS / Windows env. Returns key names imported or skipped
inject project, check? Writes the gitignored env file. Returns which keys were written, missing or stale
push project, 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)

Command Purpose
hazina init Create 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 projects Paths, 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-all Launcher 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 FILE scrypt + 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.

Client Runs on Config file Command
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 bot Windows ~/.cursor/mcp.json wsl.exe bridge
Claude Code desktop Windows ~/.claude.json wsl.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

{
  "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

# ~/.grok/config.toml
[mcp_servers.hazina]
command = "/home/barnabas/.local/bin/hazina-mcp"
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:

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.

Symptom Cause
silent stdout, error on stderr launcher problem: no Node 20+, missing tsx, bad path
serverInfo but zero tools registration problem in src/mcp/server.ts
both correct, client still blind client config problem, wrong scope, or the client needs a restart

Gotchas

Known drift (as of 2026-10-20)

Hazina vs the vendor MCPs

Hazina Cloudflare / Vercel / xAI
Transport local stdio (child process) remote Streamable HTTP
Protocol era legacy (initialize, SDK v1) vendor-dependent
Config key command + args url + Authorization header
Auth filesystem + DPAPI-wrapped key bearer API token / OAuth
Ownership first-party, private vendor-hosted
Failure mode process will not spawn 401 / network
Secrets exposure none: value-free tools token 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

Official docs: