Code Firewall MCP logo

Code Firewall MCP

Structural code filter that compares normalized code with blacklisted patterns before execution.

Install Code Firewall MCP

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "code-firewall-mcp": {
      "command": "uvx",
      "args": [
        "code-firewall-mcp"
      ],
      "env": {
        "FIREWALL_DATA_DIR": "YOUR_VALUE_HERE",
        "OLLAMA_URL": "YOUR_VALUE_HERE",
        "EMBEDDING_MODEL": "YOUR_VALUE_HERE",
        "SIMILARITY_THRESHOLD": "YOUR_VALUE_HERE",
        "NEAR_MISS_THRESHOLD": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings β†’ Developer β†’ Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

Install not yet sandbox-testedβ€” we haven't run this command through our automated sandbox yet. Not a red flag; we're working through the catalog.

Overview

code-firewall-mcp MCP server checks code files and strings for structural similarity to known dangerous patterns before they reach execution tools. It parses and normalizes code, creates embeddings with Ollama, and compares them against patterns stored in ChromaDB. Reach for it when an MCP workflow needs a pre-execution safety gate, especially alongside execution tools such as rlm_exec. It also provides tools for configuring Ollama and maintaining blacklist and near-miss data.

Use cases

  • Check generated code before sending it to an execution tool
  • Inspect inline code without creating a file
  • Add organization-specific dangerous patterns to the blacklist
  • Record legitimate near-miss examples for classifier refinement
  • Verify Ollama and embedding availability on macOS

Key features

  • Structural similarity checks for code files and strings
  • Ollama-based code embeddings
  • ChromaDB pattern storage
  • Blacklist and near-miss management
  • Configurable similarity thresholds
  • Ollama setup and status tools

Tools11

What Code Firewall MCP lets your agent do. Expand a tool for its parameters.

Self-reported~187 tokens of context

Security & health

What it can reach and how reliably it runs β€” from our own checks, not the maintainer’s claims.

ActiveLast checked Today

Recent health check succeeded.

9/9 checks healthy over the last 45d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 4d ago via OSV.dev Β· code-firewall-mcp (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks β€” not a rating.

Last commit9mo agoMost recent push to the default branch.
Tools exposed11Callable tools this server registers over MCP.

How Code Firewall MCP works

What code-firewall-mcp MCP server does

code-firewall-mcp MCP server acts as a pre-execution filter for code supplied by an agent workflow. It accepts either a file path or an inline code string and returns a safety decision with fields such as whether the code was allowed or blocked and its similarity score.

The filter is based on code structure rather than exact text. During normalization, identifiers and literals are generally removed so variations of the same operation can be compared. Security-sensitive names, including terms associated with evaluation, shell access, and subprocess execution, remain available to help distinguish risky structures.

The project is intended for workflows that pass generated or user-provided code to execution tools. The README specifically describes using it before rlm_exec, and it can also be enabled through the firewall integration for massive-context-mcp.

How it works

The processing pipeline parses code into a concrete syntax tree when tree-sitter parsing is available, creates a normalized structural representation, and sends that representation to Ollama for embedding. ChromaDB stores the blacklist and supports similarity comparisons against known patterns.

A similarity result at or above the configured block threshold is treated as blocked; a lower result is allowed. Near-miss examples can be recorded separately to help refine the classifier boundary. The default block threshold is 0.85, while the default near-miss threshold is 0.70.

Because the decision uses similarity rather than a fixed list of literal strings, changing command arguments does not necessarily avoid a match. The system still depends on its stored patterns, embedding model, thresholds, and parsing behavior, so it should be treated as a filter rather than a complete security analysis system.

Setup and configuration

Install the package with uvx code-firewall-mcp, install it with pip, or build it from source using the repository's uv workflow.

Ollama is required for embeddings, and the configured embedding model defaults to nomic-embed-text. The MCP configuration can set FIREWALL_DATA_DIR for local data and OLLAMA_URL for the Ollama endpoint. The server defaults to a local Ollama service at http://localhost:11434.

On macOS with Apple Silicon, setup tools can check system requirements and install Ollama either through Homebrew or a direct download. Both setup paths can start the service and pull the embedding model. firewall_ollama_status verifies whether Ollama and the embeddings are available.

Tools and capabilities

The server exposes tools for two main areas:

  • firewall_check evaluates a code file.
  • firewall_check_code evaluates an inline code string.
  • firewall_blacklist adds a dangerous pattern with a reason and severity.
  • firewall_record_delta stores a near-miss variant and related notes.
  • firewall_list_patterns lists blacklist or delta entries.
  • firewall_remove_pattern deletes entries from those collections.
  • firewall_status reports firewall status and statistics.
  • firewall_system_check, firewall_setup_ollama, firewall_setup_ollama_direct, and firewall_ollama_status support environment setup and diagnostics.

A typical flow checks code first, stops when the result is blocked, and forwards only allowed code to an execution tool. With the documented massive-context-mcp firewall integration enabled, rlm_exec performs that check automatically.

Limitations and notes

The documented automatic setup targets macOS and Apple Silicon. Ollama, ChromaDB, and an embedding model are part of the runtime requirements, while tree-sitter is optional for improved parsing. Storage location, Ollama endpoint, model, and thresholds are configurable through environment variables. The project is released under the MIT license.

Reviews

No reviews yet β€” be the first to share how it worked for you.

Frequently Asked Questions about Code Firewall MCP

code-firewall-mcp is an MCP server that connects agent workflows to Ollama embeddings and ChromaDB-backed pattern storage. Its main tools check code files or strings, manage blacklist and near-miss patterns, report status, and help install or verify Ollama on supported macOS Apple Silicon systems.

Install it with `uvx code-firewall-mcp` or `pip install code-firewall-mcp`. You can also clone the repository and run its `uv` setup, or install the packaged `.mcpb` release in Claude Desktop.

Configure Ollama by running the setup tools, installing it manually, or pointing `OLLAMA_URL` at an existing service. The embedding model defaults to `nomic-embed-text`, and `firewall_ollama_status` checks whether embeddings are ready.

Call `firewall_check_code` with the code and its language. The tool evaluates the string without requiring a file and returns information including whether it was allowed or blocked and its similarity result.

Call `firewall_check_code` or `firewall_check` before `rlm_exec`, and stop when the result is blocked. The documented `massive-context-mcp[firewall]` integration can make `rlm_exec` perform this check automatically.

Related MCP servers

Add a badge to your READMEShow it’s listed β€” live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewCode Firewall MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/code-firewall-mcp?style=directory)](https://allmcps.com/mcp/code-firewall-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/code-firewall-mcp"><img src="https://allmcps.com/api/badge/code-firewall-mcp?style=directory" alt="Code Firewall MCP on AllMCPs" /></a>