Skip to content

Free, open source blog writer for Claude Code. Researches current sources, writes answer-first posts for Google and AI answers, has an independent reviewer score each one out of 100 and ships only after five delivery gates. 32 skills, 30 /blog commands, 5 agents. Active development at AI-Marketing-Hub/claude-blog; public releases ship here.

fix(security): close VULN-001 default-commit-secret + harden MCP setup

Danielf48a719e5ccd
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 9c909fe..ddf49fc 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -6,6 +6,8 @@ skills/ @AgriciDaniel
agents/ @AgriciDaniel
.claude-plugin/ @AgriciDaniel
.mcp.json @AgriciDaniel
+.mcp.example.json @AgriciDaniel
+.gitignore @AgriciDaniel
install.sh @AgriciDaniel
install.ps1 @AgriciDaniel
uninstall.sh @AgriciDaniel
diff --git a/.gitignore b/.gitignore
index 656c166..e929734 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,12 @@ yarn-error.log*
*.pem
credentials.json
+# MCP server configs (may carry inline credentials)
+# A tracked .mcp.example.json template lives alongside, with env-expansion only.
+.mcp.json
+.mcp.local.json
+**/.mcp.json
+
# IDE
.vscode/
.idea/
diff --git a/.mcp.json b/.mcp.example.json
similarity index 50%
rename from .mcp.json
rename to .mcp.example.json
index 18ff344..da47e96 100644
--- a/.mcp.json
+++ b/.mcp.example.json
@@ -1,8 +1,9 @@
{
+ "_comment": "Template for project-local .mcp.json. Copy to .mcp.json (gitignored) and set GOOGLE_AI_API_KEY in your shell env. NEVER commit a literal API key.",
"mcpServers": {
"nanobanana-mcp": {
"command": "npx",
- "args": ["-y", "@ycse/nanobanana-mcp"],
+ "args": ["-y", "@ycse/[email protected]"],
"env": {
"GOOGLE_AI_API_KEY": "${GOOGLE_AI_API_KEY}",
"NANOBANANA_MODEL": "gemini-3.1-flash-image-preview"
diff --git a/docs/MCP-INTEGRATION.md b/docs/MCP-INTEGRATION.md
index ff9f766..03f2159 100644
--- a/docs/MCP-INTEGRATION.md
+++ b/docs/MCP-INTEGRATION.md
@@ -56,18 +56,28 @@ photo sourcing from Pixabay/Unsplash/Pexels.
### Configuration
-The project `.mcp.json` is pre-configured. Set your API key:
+The setup script writes to Claude Code's user-private global settings by
+default (safer; never reaches git). To use project-local `.mcp.json`, opt in
+with `--project` (the script will refuse to write a literal key into a
+tracked file).
```bash
-# Option 1: Run the setup script
+# Recommended: writes ~/.claude/settings.json (user-private, mode 0600)
python3 skills/blog-image/scripts/setup_image_mcp.py --key YOUR_KEY
-# Option 2: Set environment variable
+# Project-local (env-expansion only, NEVER stores literal key)
+python3 skills/blog-image/scripts/setup_image_mcp.py --key YOUR_KEY --project
+# Then export the key in your shell so the env-expansion resolves:
export GOOGLE_AI_API_KEY="your-key-from-aistudio.google.com"
```
Get a free API key at: https://aistudio.google.com/apikey
+> **Security**: `.mcp.json` is gitignored as of 2026-04-27. A tracked
+> `.mcp.example.json` template lives alongside. The setup script pins the
+> nanobanana-mcp package version (`@ycse/[email protected]`) to mitigate
+> supply-chain risk on `npx -y` auto-update.
+
### Verify Setup
```bash
diff --git a/skills/blog-image/SKILL.md b/skills/blog-image/SKILL.md
index 066dc94..e32c37c 100644
--- a/skills/blog-image/SKILL.md
+++ b/skills/blog-image/SKILL.md
@@ -247,12 +247,15 @@ For `/blog image setup`:
1. Run `python3 scripts/setup_image_mcp.py` (interactive)
- Or: `python3 scripts/setup_image_mcp.py --key YOUR_KEY` (non-interactive)
- - Writes to project `.mcp.json` by default
- - Use `--global` flag for `~/.claude/settings.json`
+ - Default writes to `~/.claude/settings.json` (user-private, mode 0600)
+ - `--project` flag opts into project `.mcp.json` (env-expansion only,
+ refuses to write a literal key into a tracked file)
2. Verify: `python3 scripts/validate_image_setup.py`
3. Requires:
- Node.js 18+ (npx)
- Google AI API key (free at https://aistudio.google.com/apikey)
+4. The script pins the package to `@ycse/[email protected]`. Update the
+ pin in `setup_image_mcp.py` (constant `PINNED_PACKAGE`) when bumping.
## Safety Filter Auto-Rephrase
diff --git a/skills/blog-image/scripts/setup_image_mcp.py b/skills/blog-image/scripts/setup_image_mcp.py
index 51fa67d..b438f99 100644
--- a/skills/blog-image/scripts/setup_image_mcp.py
+++ b/skills/blog-image/scripts/setup_image_mcp.py
@@ -2,15 +2,15 @@
"""
Setup script for nanobanana-mcp in claude-blog.
-Configures @ycse/nanobanana-mcp in the project's .mcp.json (default)
-or Claude Code's global settings.json (with --global flag).
+Configures @ycse/nanobanana-mcp in Claude Code's global settings.json
+(default) or the project's .mcp.json (with --project flag).
Usage:
- python3 setup_image_mcp.py # Interactive (prompts for key)
+ python3 setup_image_mcp.py # Interactive (writes global)
python3 setup_image_mcp.py --key YOUR_KEY # Non-interactive
python3 setup_image_mcp.py --check # Verify existing setup
python3 setup_image_mcp.py --remove # Remove MCP config
- python3 setup_image_mcp.py --global # Write to ~/.claude/settings.json
+ python3 setup_image_mcp.py --project # Write to project .mcp.json (env-expansion only)
python3 setup_image_mcp.py --help # Show usage
"""
@@ -22,30 +22,31 @@ from pathlib import Path
MCP_NAME = "nanobanana-mcp"
MCP_PACKAGE = "@ycse/nanobanana-mcp"
DEFAULT_MODEL = "gemini-3.1-flash-image-preview"
+PINNED_PACKAGE = "@ycse/[email protected]" # latest stable as of 2026-04-27
+ENV_PLACEHOLDER = "${GOOGLE_AI_API_KEY}"
+PLUGIN_NAME = "claude-blog"
GLOBAL_SETTINGS_PATH = Path.home() / ".claude" / "settings.json"
def find_project_mcp_json() -> Path:
- """Find the project-level .mcp.json by looking for .claude-plugin/plugin.json."""
- current = Path(__file__).resolve().parent
- for _ in range(10): # Max 10 levels up
- candidate = current / ".claude-plugin" / "plugin.json"
- if candidate.exists():
- return current / ".mcp.json"
- parent = current.parent
- if parent == current:
- break
- current = parent
- # Fallback: look from cwd
- current = Path.cwd()
- for _ in range(10):
- candidate = current / ".claude-plugin" / "plugin.json"
- if candidate.exists():
- return current / ".mcp.json"
- parent = current.parent
- if parent == current:
- break
- current = parent
+ """Find the project-level .mcp.json by locating .claude-plugin/plugin.json with name=='claude-blog'."""
+ def matches(plugin_path: Path) -> bool:
+ try:
+ import json as _json
+ with open(plugin_path) as f:
+ return _json.load(f).get("name") == PLUGIN_NAME
+ except (OSError, _json.JSONDecodeError):
+ return False
+ for start in (Path(__file__).resolve().parent, Path.cwd()):
+ current = start
+ for _ in range(5):
+ candidate = current / ".claude-plugin" / "plugin.json"
+ if candidate.exists() and matches(candidate):
+ return current / ".mcp.json"
+ parent = current.parent
+ if parent == current:
+ break
+ current = parent
return None
@@ -70,14 +71,31 @@ def load_config(path: Path) -> dict:
def save_config(path: Path, config: dict) -> None:
- """Save config file."""
+ """Save config file. Sets restrictive permissions if the file may contain secrets."""
path.parent.mkdir(parents=True, exist_ok=True)
- with open(path, "w") as f:
+ fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
+ with os.fdopen(fd, "w") as f:
json.dump(config, f, indent=2)
f.write("\n")
+ os.chmod(path, 0o600) # belt-and-braces if file pre-existed
print(f"Config saved to {path}")
+def _is_git_tracked(path: Path) -> bool:
+ """Return True if path is tracked by git in its containing repo."""
+ import subprocess
+ try:
+ result = subprocess.run(
+ ["git", "ls-files", "--error-unmatch", path.name],
+ cwd=path.parent,
+ capture_output=True,
+ text=True,
+ )
+ return result.returncode == 0
+ except (OSError, FileNotFoundError):
+ return False
+
+
def check_setup(use_global: bool) -> bool:
"""Check if MCP is already configured."""
# Check project-level first, then global
@@ -121,39 +139,62 @@ def remove_mcp(use_global: bool) -> None:
def setup_mcp(api_key: str, use_global: bool) -> None:
- """Configure MCP server."""
+ """Configure MCP server. Project mode uses env-expansion only (never literal key)."""
if not api_key or not api_key.strip():
print("Error: API key cannot be empty.")
sys.exit(1)
-
api_key = api_key.strip()
path = get_config_path(use_global)
+
+ # Safety: project mode must never write a literal key into a tracked file.
+ if not use_global and _is_git_tracked(path):
+ gitignore = path.parent / ".gitignore"
+ ignored = ".mcp.json" in gitignore.read_text() if gitignore.exists() else False
+ if not ignored:
+ print(f"REFUSING: {path} is tracked by git and .gitignore does not exclude .mcp.json.")
+ print("Either:")
+ print(f" 1. Add '.mcp.json' to {gitignore} and run: git rm --cached .mcp.json")
+ print(f" 2. Use --global to write to ~/.claude/settings.json instead (recommended).")
+ sys.exit(2)
+
config = load_config(path)
+ config.setdefault("mcpServers", {})
- if "mcpServers" not in config:
- config["mcpServers"] = {}
+ # Project mode: env-expansion only. Global mode: literal value (file is user-private + chmod 600).
+ key_value = ENV_PLACEHOLDER if not use_global else api_key
config["mcpServers"][MCP_NAME] = {
"command": "npx",
- "args": ["-y", MCP_PACKAGE],
+ "args": ["-y", PINNED_PACKAGE],
"env": {
- "GOOGLE_AI_API_KEY": api_key,
+ "GOOGLE_AI_API_KEY": key_value,
"NANOBANANA_MODEL": DEFAULT_MODEL,
},
}
-
save_config(path, config)
+
print(f"\nMCP server '{MCP_NAME}' configured successfully!")
- print(f" Package: {MCP_PACKAGE}")
+ print(f" Package: {PINNED_PACKAGE}")
print(f" Model: {DEFAULT_MODEL}")
print(f" Config: {path}")
- print(f"\nRestart Claude Code for changes to take effect.")
- print(f"Generated images will be saved to: ~/Documents/nanobanana_generated/")
+ if not use_global:
+ print()
+ print("Project mode uses env-expansion (never writes literal key).")
+ print("Add this line to your shell rc (~/.bashrc or ~/.zshrc):")
+ print(f" export GOOGLE_AI_API_KEY={api_key}")
+ print("Then restart your shell + Claude Code.")
+ else:
+ print()
+ print(f"File mode set to 0600 (user-private).")
+ print("Restart Claude Code for changes to take effect.")
+ print(f"Generated images saved to: ~/Documents/nanobanana_generated/")
def main() -> None:
args = sys.argv[1:]
- use_global = "--global" in args
+ # Safer default: --global (writes user-private ~/.claude/settings.json).
+ # --project opts in to project-local config (with safety guards).
+ use_global = "--project" not in args
if "--help" in args or "-h" in args:
print("Usage: python3 setup_image_mcp.py [OPTIONS]")
@@ -162,7 +203,7 @@ def main() -> None:
print(" --key KEY Provide API key non-interactively")
print(" --check Verify existing setup")
print(" --remove Remove MCP configuration")
- print(" --global Write to ~/.claude/settings.json (default: project .mcp.json)")
+ print(" --project Write to project .mcp.json (default: ~/.claude/settings.json)")
print(" --help, -h Show this help message")
print()
print("Get a free API key at: https://aistudio.google.com/apikey")
diff --git a/skills/blog-image/scripts/validate_image_setup.py b/skills/blog-image/scripts/validate_image_setup.py
index 3f5b703..c8ff66e 100644
--- a/skills/blog-image/scripts/validate_image_setup.py
+++ b/skills/blog-image/scripts/validate_image_setup.py
@@ -116,13 +116,23 @@ def main() -> int:
mcp.get("command", "(missing)"),
))
- # 5. Package is correct
+ # 5. Package is correct (accepts pinned versions like @ycse/[email protected])
args = mcp.get("args", [])
- has_pkg = "@ycse/nanobanana-mcp" in args
+ has_pkg = any(
+ isinstance(a, str) and a.startswith("@ycse/nanobanana-mcp")
+ for a in args
+ )
+ is_pinned = any(
+ isinstance(a, str) and a.startswith("@ycse/nanobanana-mcp@")
+ for a in args
+ )
+ pkg_detail = str(args)
+ if has_pkg and not is_pinned:
+ pkg_detail += " (WARNING: not version-pinned -- supply chain risk)"
results.append(check(
"Package is @ycse/nanobanana-mcp",
has_pkg,
- str(args),
+ pkg_detail,
))
# 6. API key present