secure-api MCPサーバー
コミット 2026年11月12日実行時にコマンドやAPI呼び出しへシークレットを注入し、AIクライアントへの機密データ露出を防ぐために出力をサニタイズします。
別名 than/secure-api-mcp
- スター
- 5
- ツール
- 5
- ダウンロード数(30日間)
- —
- 最新バージョン
- —
- 最終コミット
- 2026年11月12日
- ライセンス
- —
secure-api MCPとは
実行時にコマンドやAPI呼び出しへシークレットを注入し、AIクライアントへの機密データ露出を防ぐために出力をサニタイズします。 5個のツールを提供しており、get_env_keys, run_with_env, api_callなどがあります。
プロジェクトのREADMEから生成された概要
secure-api MCP server について
このサーバーは、Claude CodeなどのAIクライアントによる機密情報のキャッシュや読み取りから、認証情報を保護します。開発者は、実際のシークレットの値を会話コンテキストに一切露出させることなく、AIエージェントに環境変数や設定ファイルを使用する権限を与えることができます。実行時にコマンドやHTTPリクエストへシークレットを注入し、その結果として得られる出力を編集(redact)することで、プライベートキーとLLMの間にセキュリティレイヤーを維持します。
ユーザーは、構造化されたHTTPリクエスト用の api_call や、シェルコマンド実行用の run_with_env といった特定のツールを通じてシークレットを管理できます。また、このサーバーは read_mycnf を介してMySQLの認証情報を処理し、sync_env_example を使用してドキュメントの維持を支援します。セキュリティを確保するため、api_call ツールにはSSRF保護が含まれており、SECURE_API_ALLOWED_HOSTS 環境変数によるホストの許可リスト(allowlist)をサポートしています。この構成は、ファイル履歴にプレーンテキストのシークレットが密かに保存されるのを防ぎつつ、Claude Codeを使用したいローカル開発環境を対象としています。
できること
- 1シークレットを含むシェルコマンドの実行AIに出力内容としての値を見せることなく、環境変数を必要とするターミナルコマンドを実行します。
- 2安全なAPIリクエストの実行送信先が承認されていることを確認しながら、Bearerトークンやカスタムヘッダーを含むHTTPコールを行います。
プロジェクトの README から作成されています。すべてのユースケースは、その引用と照らし合わせて確認されています。
secure-api MCPツール 5
READMEから検出get_env_keysrun_with_envapi_callread_mycnfsync_env_example
| get_env_keys | — | |
| run_with_env | — | |
| api_call | — | |
| read_mycnf | — | |
| sync_env_example | — |
設定
SECURE_API_ALLOWED_HOSTS
| 名前 | 説明 | 種類 |
|---|---|---|
| SECURE_API_ALLOWED_HOSTS | — |
自動チェック
実行日 2026年11月14日完全なレポート →まだ検証されていません。サーバーには80点のスコア、重大な問題がないこと、および検証に必要な十分なデータが必要です。 チェックの仕組み · 点数を上げるための改善点
- ソースリポジトリがリンクされており、アクセス可能than/secure-api-mcp is public and reachablegithub.com/than/secure-api-mcp ↗合格
- パッケージがこのリポジトリをソースとして指定未チェック
- ビルドの来歴 (Sigstore 証明)未チェック
- オープンソースライセンス (OSI)No license検出事項
- 過去1年以内にコミットまたはリリースありLast commit or release 2026-11-12github.com/than/secure-api-mcp ↗合格
- OpenSSF Scorecard未チェック
- パッケージ名が有名なパッケージに酷似していない未チェック
- パッケージおよびその依存関係に重大な勧告なし未チェック
- モデルへの隠れた指示がない5 tool descriptions and the README read; no override phrases, credential paths or hidden characters合格
- 破壊的なツールがラベル付けされているNo tool named like delete, drop or exec合格
- リモートエンドポイントが MCP ハンドシェイクに応答未チェック
README
GitHubで見るsecure-api-mcp
MCP server that lets Claude Code use secrets without seeing them.
Claude Code silently reads .env files and caches them in plaintext in ~/.claude/file-history/. This server injects secrets into commands and API calls at runtime, then sanitizes output to strip secret values before they reach Claude's context.
Threat model — read this. The strength of the guard differs by tool:
api_callhas the smallest attack surface: no shell, structured output, SSRF protection, and an optional destination allowlist (see below). Sanitization reliably covers its responses.run_with_envruns an arbitrary shell command. Output sanitization is best-effort, not a hard boundary — a command can re-encode, reverse, chunk, or otherwise transform a secret into a form the sanitizer won't recognize before printing it. Treat it as defense-in-depth.
A secret can only be protected if you control where it goes. Both tools can send a secret to an external destination by design; restrict that with deny rules, the api_call allowlist, and review of run_with_env commands.
Tools
get_env_keys(project_dir)— Returns key names from.env. No values exposed.run_with_env(project_dir, command, env_keys?, timeout_ms?, include_mycnf?)— Runs a shell command with.envvars injected. Output is sanitized — secret values replaced with[REDACTED:KEY_NAME]. Setinclude_mycnfto also sanitize MySQL credentials from.my.cnfin command output.api_call(project_dir, url, method?, headers?, body?, auth_env_key?, timeout_ms?)— HTTP request with secret injection.auth_env_keyadds a Bearer token. Headers support{{KEY_NAME}}template syntax. When a secret is injected, the destination host is checked againstSECURE_API_ALLOWED_HOSTS(see below). Redirects are followed manually, up to 5 hops, with the SSRF guard and the allowlist re-applied to every hop. Times out aftertimeout_ms(default 30s).read_mycnf(project_dir, section?)— Reads MySQL.my.cnfconfiguration. Returns section names and safe fields (port,database,socket) with credentials (user,password,host) redacted as[REDACTED:section.field]. Checks~/.my.cnfand project-local.my.cnf.sync_env_example(project_dir)— Generates/updates.env.examplefrom.env. Preserves comments and structure, strips values, uses smart placeholders.
Setup
npm install && npm run build
Register in Claude Code:
claude mcp add secure-api -- node /path/to/secure-api-mcp/dist/index.js
Pair with deny rules in ~/.claude/settings.json to block direct .env reads:
"deny": [
"Read(.env)", "Read(**/.env)",
"Read(.env.local)", "Read(**/.env.local)",
"Edit(.env)", "Edit(**/.env)"
]
Keeping .env.example in sync
Run sync_env_example to generate or update .env.example from your .env. It:
- Preserves comments and blank lines from
.env - Strips secret values, replacing them with smart placeholders (URLs stay URL-shaped, booleans stay as-is, numbers stay as-is, everything else blanked)
- Merges with any existing
.env.example— custom placeholders you've added won't be overwritten - Lets Claude read
.env.examplefreely (since deny rules only block.env) so it knows what config exists without seeing values
Pair this with get_env_keys and Claude has full awareness of your project's config without any secret exposure.
Restricting where api_call can send secrets
By default api_call will attach a secret to a request bound for any public host (internal/private IPs are always blocked for SSRF). To restrict this, set SECURE_API_ALLOWED_HOSTS to a comma-separated list of permitted hosts:
export SECURE_API_ALLOWED_HOSTS="api.stripe.com,api.github.com,*.internal.example.com"
- Set — a request that injects a secret is blocked unless its host matches.
*.example.commatches any subdomain and the apexexample.com. Matching is case-insensitive. - Unset — secrets are still sent (so existing setups keep working), but the response includes a
warningsentry naming the destination host.
Requests that inject no secret are never gated.
MySQL .my.cnf support
Claude can work with MySQL configs without seeing your credentials. read_mycnf exposes structural fields (port, database, socket) while redacting user, password, and host. When running MySQL commands via run_with_env, set include_mycnf: true to sanitize any credential values that appear in command output — the mysql CLI reads ~/.my.cnf natively, so no env var injection is needed.
Resolution order matches MySQL's own: ~/.my.cnf (global), then <project_dir>/.my.cnf (project-local overrides global per-field). !include and !includedir directives are followed. Includes in the project-local chain are contained to the project directory (resolved through symlinks) so a crafted project .my.cnf can't disclose files elsewhere on disk; the trusted global ~/.my.cnf chain is unrestricted.
How sanitization works
Secret values of 4 or more characters are replaced in all output, sorted longest-first to prevent partial matches. A value like sk-abc123xyz becomes [REDACTED:API_KEY]. The literal value, its base64 form, and its URL-encoded form are all matched, followed by a pattern pass for common token shapes (AWS, GitHub, Stripe, Slack, JWTs, private keys). Values transformed in other ways (hex, reversed, split across lines) are not caught — this is why run_with_env output is best-effort, not a guarantee.
License
MIT
secure-api MCPのよくある質問
secure-api MCPが提供するツールは
5個のツールを提供しており、get_env_keys, run_with_env, api_call, read_mycnf, sync_env_exampleなどがあります。
Claudeにシークレットを見られないように、サーバーはどのように保護しますか?
サーバーは実行時にコマンドやAPI呼び出しへシークレットを注入し、AIのコンテキストに到達する前に、出力からシークレットの値を削除するサニタイズ処理を行います。
シェルコマンドの出力のサニタイズは保証されていますか?
いいえ、シェルコマンドのサニタイズはベストエフォートです。コマンドによってシークレットが再エンコードまたは変換された場合、サニタイザーが認識できない可能性があります。
api_call ツールがシークレットを送信できるホストを制限できますか?
はい、SECURE_API_ALLOWED_HOSTS 環境変数に許可するホストをカンマ区切りで設定することで、シークレットを注入するリクエストを制限できます。