secure-usage-mcp
v2.0.1
Published
Model Context Protocol server for secure code guidance and high-risk tool mediation.
Downloads
11
Readme
Secure Usage MCP Server
This Model Context Protocol (MCP) server enforces secure-by-design guardrails for AI-assisted development.
Features
- Secure coding guidance (
secure-code-review) – Produces a NIST SSDF and OWASP-aligned remediation plan, stack-specific hardening tips, and verification checklist. Optional code snippets are scanned for common anti-patterns (hardcoded secrets, eval, weak crypto, etc.). - High-risk tool mediation (
tool-risk-gatekeeper) – Evaluates planned tool executions for destructive operations (filesystem, infrastructure, database). Flags commands that require human approval and emits a ready-to-display confirmation prompt. - Agent configuration hardening (
agent-configuration-hardener) – Builds an endpoint hardening blueprint for IDE, CLI, and vibe coding agents. Covers sandboxing, remote indexing controls, plugin/MCP inventories, reasoning guardrails, and monitoring playbooks. - Reusable guardrail prompt – Exposes the
secure-coding-governorprompt that IDEs/agents can apply as a baseline secure coding instruction set.
Getting Started
Runtime requirements
- Node.js 18.17.0 or newer.
Run with npx
Install and launch the compiled server directly from npm without cloning the repository:
npx -y secure-usage-mcp@latestThis resolves the published package, runs the compiled binary declared in the package manifest, and exposes the MCP server over STDIO. The shebang header ensures npx can execute it on all major platforms.
Run from source
npm install
npm run build
npm startThe server communicates over STDIO. Integrate it with an MCP-compatible client (e.g., Claude Desktop, Cursor, or custom tooling) by referencing the compiled binary secure-usage-mcp.
Configuration
SECURE_USAGE_LOG_LEVEL– Optional log level override (debug,info,warn, orerror). Logs are emitted to stderr so the MCP protocol payloads on stdout remain untouched.
Testing the MCP Server
Build the server output:
npm run buildRun the automated smoke test, which spawns the compiled server via the MCP SDK client and exercises both tools:
node scripts/smokeTest.mjsThe script prints the server instructions, a preview of the
secure-coding-governorprompt, and structured output from the two tools. It also verifies that high-risk tooling requires an explicit Yes/No confirmation.For a minimal verification that focuses on risk mediation, execute the included
test-client.jsscript:node test-client.jsThis script connects to the built server, prints the instructions, and runs a sample
tool-risk-gatekeeperrequest to confirm high-risk detection.For interactive debugging, you can also run the server manually and inspect it with the open-source MCP Inspector:
npm start # in one terminalFollow the Inspector README to point it at
node dist/index.jsvia stdio and explore prompts/tools in a GUI.
IDE Integration
Cursor
Open Settings → Experimental → MCP Servers (or edit
~/.cursor/config.json).Register the server with the published npm package so Cursor can resolve it via
npx:{ "mcpServers": { "secure-usage": { "command": "npx", "args": ["-y", "secure-usage-mcp@latest"], "env": {} } } }Restart Cursor. When a high-risk tool call is attempted, the chat panel will show a Yes/No confirmation. Answer No (or anything other than Yes) to halt execution.
Claude Code (Claude Desktop)
Claude Code supports MCP servers over STDIO via a JSON config. You can either reference the built script directly or use npx to always fetch the latest published version.
- Find your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- Recommended: configure via npx so Claude resolves the published package automatically:
{
"mcpServers": {
"secure-usage": {
"command": "npx",
"args": ["-y", "secure-usage-mcp@latest"],
"env": {}
}
}
}Alternatively, point directly at a local build (useful for development):
{
"mcpServers": {
"secure-usage": {
"command": "/usr/local/bin/node",
"args": ["/absolute/path/to/secure-usage-mcp/dist/index.js"],
"env": {}
}
}
}On Windows, adjust paths accordingly, for example:
{
"mcpServers": {
"secure-usage": {
"command": "C:/Program Files/nodejs/node.exe",
"args": ["C:/Users/<you>/projects/secure-usage-mcp/dist/index.js"],
"env": {}
}
}
}- Save and relaunch Claude Code. Open the MCP panel to confirm the server is connected. The guardrail prompt
secure-coding-governorbecomes available, and destructive tools will require a Yes/No confirmation.
Verify
- Ask Claude to run a risky command (e.g., mention
rm -rf /tmp/demo) after connecting. You should see a risk assessment and a Yes/No prompt fromtool-risk-gatekeeper. - Call the secure guidance tool by asking Claude to use
secure-code-reviewwith your request and a short code snippet.
Troubleshooting
- If the server does not appear: ensure Node ≥ 18.17.0 is installed and on PATH inside Claude.
- If you see permission errors with npx: pre-install globally with
npm i -g secure-usage-mcpand setcommandtosecure-usage-mcp(no args). - If stdout looks noisy: this server logs to stderr by default. Ensure your config does not redirect stderr to stdout.
- If high-risk prompts aren’t shown: your client must surface the
userPromptand block execution until the operator answers "Yes". Treat any other response as "No".
The guardrail policy requires explicit human approval. If an IDE cannot surface a Yes/No prompt, treat that as a No and halt.
Workflow Recommendations
- Wrap AI code generation by calling
secure-code-reviewwith the request context and candidate code. Adopt the returned mitigations before accepting any changes. - Guard destructive tooling by routing every mutation command through
tool-risk-gatekeeper. IfrequiresApprovalistrue, surface the provideduserPromptto the operator and block execution until they explicitly approve. - Lock down agent configurations using
agent-configuration-hardenerbefore enabling new plugins, MCP servers, or vibe coding agents. Apply the per-agent runtime controls, sandbox requirements, and monitoring hooks it prescribes. - Apply the secure prompt
secure-coding-governoras a system/assistant message to keep large language models aligned with NIST and OWASP requirements.
Tool Reference
secure-code-review– Request/response schema, response structure, and usage tips for the secure guidance generator.tool-risk-gatekeeper– Input parameters, output contract, and operator workflow for high-risk tooling mediation.agent-configuration-hardener– Inventory format, policy coverage, and sample outputs for IDE/CLI/vibe agent hardening.
Development
npm run dev– Start the TypeScript server with hot reload usingts-node.npm run build– Compile TypeScript to JavaScript (output indist/).npm start– Run the compiled server.
License
This project is licensed under the MIT License. See LICENSE.
