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.exebridge. It still runs on the v1 SDK (@modelcontextprotocol/sdk) and speaks the 2025-erainitializehandshake. MCP 2026-07-28 and SDK v2 are out, and v1 gets fixes only until about late January 2027, so plan the move toserveStdio.
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:
- 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/discoveris a mandatory RPC that returns supported versions, capabilities and server identity in one call.- Revisions
2025-11-25and earlier are now the legacy (initialize-based) era. On stdio, a dual-era client probes withserver/discoverand falls back toinitializeon 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 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:
- stdout is the protocol channel. All logging goes to stderr. A stray
console.logcorrupts 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)
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) andHAZINA_HOME, which defaults to$HOME/.codeamani/hazina - prepends the newest nvm Node to
PATHwhen~/.nvm/versions/nodeexists, because a non-loginwsl.exe -d Ubuntu --shell otherwise resolves Ubuntu's/usr/bin/node, often Node 18 - appends
/mnt/c/Windows/System32/WindowsPowerShell/v1.0toPATHifpowershell.exeis not reachable, because the master key is DPAPI-wrapped and is unwrapped through Windows execsnode --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.
| 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
envdoes not cross the WSL boundary. Anenvblock in a Windowsmcp.jsonsets variables on the Windowswsl.exeprocess. Linux only inherits whatWSLENVforwards, so aHAZINA_HOMEset 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. (Anenvblock 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 wroteC:/Program Files/Git/home/…into~/.claude.json, a config that parses but can never spawn. SetMSYS_NO_PATHCONV=1or 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. Comparewsl.exe -d Ubuntu -- node -vwithwsl.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.
doctorreportspowershellPath: nullfor exactly this case. - Distro name is load-bearing.
-d Ubuntumust matchwsl.exe -l -qexactly. - 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
--litliterals, 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.tscallsbindProject(kp, project, env, ref),pushProject(kp, project, host),importFromOsEnv(kp, scope, names),getBindingView(kp, project)andwiringSummary(kp, project). The 0.3.0 handlers take option objects, andgetBindingViewtakes onlyproject. If you run that server against the real vault,bind,pushandimport_from_os_envwill throw, andget_bindingandwiring_summarywill 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.hostvspush.provider,propose_binding.root?vsprojectDir,bindsingleenv/refvsadd[]/lit[]). This guide documents the live 0.3.0 names. packages/hazinain this repo still hasv.length > 0inassertNoValues, 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.tssends the value over stdin first. If that fails, it retries withvercel 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 a0600temp file. On a shared or monitored host, preferinjectplus the host's own import, or remove the fallback in the vault repo.
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
- Zero exposure is the product. Never add a tool that returns a secret value. If an agent
needs a value, it needs
injectwriting 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/hazinain 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.1only. - 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 incodeAmani-labs-projects/). Bind them by reference. A leaked Daraja credential is real money. - AI keys. Anthropic is primary and OpenAI secondary. Bind
anthropic/*andopenai/*refs per project rather than copying keys between.env.localfiles, so a rotation reaches every bound app with onehazina rotate. - Audit before shipping. Run
audit(stale refs) andwiring_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.logrecords 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/hazinafirst, since that is the live server, then mirror it in hazina-mcp, together with the adapter fix above.
Official docs:
- https://modelcontextprotocol.io/specification/2026-07-28
- https://modelcontextprotocol.io/docs/develop/build-server
- https://modelcontextprotocol.io/docs/develop/connect-local-servers
- https://github.com/modelcontextprotocol/typescript-sdk
- https://ts.sdk.modelcontextprotocol.io/v2/
- https://code.claude.com/docs/en/mcp
- https://cursor.com/docs/mcp
- https://learn.microsoft.com/en-us/windows/wsl/filesystems