Keiko
Enables AI agents to securely use secrets by running commands with environment-injected credentials and sanitizing output to prevent leakage.
README
Keiko
Secure secrets manager for AI agents. Keiko lets AI tools like Claude Code use API tokens, passwords, and credentials without ever seeing the actual values.
The Problem
AI agents need API tokens to do useful work — calling APIs, deploying code, managing infrastructure. But passing secret values through an AI's context window is a security risk: they appear in conversation logs, tool responses, and potentially in training data.
How Keiko Solves It
Keiko uses a proxy pattern. The AI agent tells Keiko what command to run and which secrets it needs, but never sees the secret values themselves:
AI Agent ──► Keiko MCP Server ──► Keiko Backend
│ │
resolves secrets ◄── HTTPS ──┘
│
spawns: bash -c "your command"
with secrets as env vars
│
captures output
sanitizes (redacts leaked values)
│
AI Agent ◄── clean output only
The AI says "run this curl command with my API token" — Keiko injects the token as an environment variable, runs the command, scans the output for any leaked values, redacts them, and returns clean output.
Quick Start
1. Deploy the backend
The backend stores secrets encrypted (AES-256-GCM) and serves them over HTTPS. Deploy with Docker to any platform with persistent storage:
# Generate an encryption key
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# Deploy (Railway, Render, Fly, Docker Compose, etc.)
# See docs/setup-guide.md for full instructions
2. Set up the MCP server
The MCP server runs on each machine that needs access to secrets. It's a standalone package with only 2 dependencies — no native compilation needed.
cd packages/mcp
npm install
npm run build
node dist/index.js --store-token YOUR_TOKEN
3. Connect to Claude Code
Add to ~/.mcp.json:
{
"mcpServers": {
"keiko": {
"command": "node",
"args": ["/absolute/path/to/keiko/packages/mcp/dist/index.js"],
"env": {
"KEIKO_URL": "https://your-keiko-backend.example.com"
}
}
}
}
Restart Claude Code. Ask "Check Keiko session status" to verify.
How the AI Uses It
Once connected, the AI discovers available secrets and uses them in commands — without ever seeing the values:
AI: list_secrets
→ my_api_token [Bearer token in Authorization header]
AI: run_with_secrets
command: curl -s -H "Authorization: Bearer $API_TOKEN" https://api.example.com/data
secrets: [{env: "API_TOKEN", name: "my_api_token"}]
→ {"data": [...]} (secret values redacted from output)
Each secret includes auth_pattern and auth_instructions metadata, so the AI knows how to use it without external documentation.
MCP Tools
| Tool | Purpose |
|---|---|
run_with_secrets |
Run a command with secrets injected as env vars |
list_secrets |
Discover available secrets (names and auth patterns only) |
session_status |
Check authentication state |
lock |
Kill switch — revoke all active sessions |
set_ttl |
Configure session expiry (0.5–24 hours) |
add_secret |
Create a new secret |
update_secret |
Replace an existing secret's value |
get_guide |
Fetch the usage guide |
Security
- Encryption at rest — AES-256-GCM with per-secret random IV, plus versioned keys (
ENCRYPTION_KEY,ENCRYPTION_KEY_V2, …) and an in-place rotation endpoint so the key can be rotated without downtime - Hashed auth tokens — 64-char hex tokens, SHA-256 hashed in the database, plaintext shown once
- Token scoping — each token is restricted to a set of secret-name glob patterns (e.g.
railway_*), so a leaked token only exposes the slice of the vault it actually needs - Output sanitization — command output scanned for secret values in raw, base64, base64url, URL-encoded, hex, JSON-string-escaped, and HTML-entity-escaped forms
- Per-token rate limit — independent of per-IP, caps abuse from a single token routed through multiple IPs
- CSRF protection —
X-CSRF-Tokenheader required on every mutating admin-UI endpoint - Session management — configurable TTL, auto-refresh, global kill switch
- Audit trail — every action logged with token ID, session ID, IP, and timestamp
Secret values never appear in AI tool responses, conversation logs, or on disk on client machines. See GET /api/guide for the full threat model — what the proxy pattern does and does not prevent.
Architecture
keiko/
├── packages/mcp/ # MCP server (runs on your machine)
│ ├── src/
│ │ ├── server.ts # 7 tool registrations
│ │ ├── client.ts # HTTPS client to backend
│ │ ├── executor.ts # Shell spawner + env var injection
│ │ ├── sanitizer.ts # Output redaction
│ │ └── keychain.ts # OS keychain (Win/Mac/Linux)
│ └── package.json # 2 deps: @modelcontextprotocol/sdk + zod
│
├── src/ # Backend API (runs on your server)
│ ├── api/ # Express routes, auth, crypto
│ └── ui/ # EJS admin templates
│
└── Dockerfile # Multi-stage production build
The MCP server and backend are fully independent packages. The MCP server has zero native dependencies — npm install works everywhere without compilers or --ignore-scripts.
Platform Support
| Environment | Token Storage | Notes |
|---|---|---|
| Windows | Windows Credential Manager | Commands run via Git Bash (not WSL) |
| macOS | macOS Keychain | System bash |
| Linux | libsecret | Requires secret-tool |
| Docker / CI | KEIKO_TOKEN env var |
No keychain needed |
Documentation
- Setup Guide — Full setup instructions for all environments, backend deployment, troubleshooting, API reference, and configuration options
Tech Stack
Backend: Node.js 20, TypeScript, Express, SQLite (better-sqlite3), EJS, Google OAuth
MCP Server: Node.js 20, TypeScript, MCP SDK v1.x, Zod
Deployment: Docker (multi-stage build), any platform with persistent volumes. Tested with Railway.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。