# Ctxfw

> Ctxfw is an open-source MCP server for security. Local firewall for coding agents: AST context pruning and prompt-injection screening. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, self-hosted
- **Repository:** https://github.com/heuristicolab/ctxfw
- **MCP Registry name:** io.github.heuristicolab/ctxfw
- **Categories:** [security](https://ai-powered.com/categories/security), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-18

## About

CTXFW sits between a coding agent and your repository and works locally over stdio with no network telemetry, according to its README. Its two main jobs are trimming context and screening it. An in-memory polyglot syntax-tree pruner replaces the files around the one you are editing with interface signatures and stubs while leaving the focal file untouched, and the README reports token reductions between about 24 and 78 percent across tested repositories such as Zulip, PostHog and Airflow.

The security side includes a prompt-injection defense it calls SARA, an intake check that rejects architecture briefs lacking required invariants and governance for MCP tool calls. It compares itself with cloud runtime firewalls by operating before context leaves the developer machine.

The core is installed from PyPI as ctxfw. The author also sells paid standalone source capsules and a bundle, so the project is open-core.

## Features

- **AST context pruning:** Replaces nearby files with interface stubs to save tokens.
- **Focal file preserved:** The file you are editing stays byte-for-byte intact.
- **Prompt-injection defense:** SARA screens incoming context for injected instructions.
- **MCP governance:** Applies controls on MCP tool use.
- **Local only:** Runs over stdio with no telemetry egress.
- **Semantic cache:** Uses a SQLite cache for repeat requests.

## Good for

- Cut token use when an agent reads a large codebase
- Screen repository content for injected instructions
- Keep agent context local on a developer machine
- Verify architecture briefs before an agent acts

## Install

### Claude Code (Terminal)

```sh
claude mcp add ctxfw -- uvx ctxfw
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "ctxfw": {
      "command": "uvx",
      "args": [
        "ctxfw"
      ]
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "ctxfw": {
      "command": "uvx",
      "args": [
        "ctxfw"
      ]
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "ctxfw": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "ctxfw"
      ]
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "ctxfw": {
      "command": "uvx",
      "args": [
        "ctxfw"
      ]
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "ctxfw": {
      "command": "uvx",
      "args": [
        "ctxfw"
      ]
    }
  }
}
```

## Tools

- `ctxfw.resolve_context_bundle`: Builds a pruned context bundle for a target file and its dependencies.

## FAQ

### Does it send data anywhere?

The README says standard operation has zero network telemetry egress.

### How is it installed?

From PyPI as ctxfw.

### Is everything free?

The core is open; the author also sells paid capsules and bundles.

### Which languages does pruning cover?

The README describes polyglot syntax-tree grammars; the full list is not given.

### Is Ctxfw free?

Yes. Ctxfw is open source, so you can use and self-host it for free.

### How do I add Ctxfw to Claude Code?

Run this command in your terminal: claude mcp add ctxfw -- uvx ctxfw

### What are the best alternatives to Ctxfw?

The closest alternatives to Ctxfw are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Context7](https://ai-powered.com/mcp/context7): Context7 is a freemium MCP server for developer tools.
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): Chrome DevTools MCP is an open-source MCP server for browser automation.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github-2): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [awesome-mcp-servers](https://ai-powered.com/mcp/awesome-mcp-servers-2): awesome-mcp-servers is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.

---
Source: https://ai-powered.com/mcp/ctxfw
