Agent Opfor logo

Agent Opfor

Organization
KeyValueSoftwareSystems

Open-source adversary emulation for AI agents and MCP servers.

PublisherKeyValueSoftwareSystems
Repositoryagent-opfor
LanguageTypeScript
Forks
33
Stars
582
Available tools
0
Transport typestdio
Links
  • Connect tools to AI workflows

    Agent Opfor exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    582 stars and 33 forks from the linked repository.

OPFOR is short for Opposition Force — a military term for the unit that plays the enemy in training, so the rest of the army learns what real attacks feel like before they come. We named the tool after that idea: to defend AI agents better, you have to attack them first.

Why KeyValue built this

We've shipped 130 products for 90 startups over the last ten years. In the last 18 months, almost every one of them had an AI agent in it — and every one of those teams hit the same wall when it came to testing.

So we built OPFOR. For ourselves first. Now open source.

Apache 2.0. Built from India.

Quick Start

bash
npm install -g @keyvaluesystems/agent-opfor-cli
export OPENAI_API_KEY=your-key    # or GEMINI_API_KEY, ANTHROPIC_API_KEY, etc.

One-shot — runs the setup wizard and immediately starts the scan:

bash
opfor run

Two-step — save a config you can reuse or commit to CI:

bash
opfor setup                               # wizard saves a config to .opfor/configs/
opfor run --config .opfor/configs/<file>  # run any time against the saved config

https://github.com/user-attachments/assets/a6a3cff2-2cf9-4486-944e-ac0163e7ea04

What opfor does

Opfor red-teams the full AI agent surface — prompts, tools, MCP servers, memory, and multi-turn reasoning. It generates targeted attacks for OWASP LLM Top 10, OWASP Agentic AI Top 10, OWASP MCP Top 10, OWASP API Security, and EU AI Act bias suites, fires them at your target, and judges each response with an LLM.

Most red-team tooling in this space is excellent at one thing — a probe library, a developer evaluator, a programmatic framework. Opfor covers more ground in one tool:

  • Browser extension for non-developers — anyone on your team can red-team a deployed chatbot, no code, no env vars, no YAML
  • Run opfor as an MCP server — let your AI coding agent in Cursor or Claude Desktop red-team your other agents through natural language
  • Full OWASP coverage in one tool — LLM Top 10, Agentic AI Top 10, MCP Top 10, API Security Top 10
  • No black box — every attack prompt, request, response, and judge verdict is logged; reproducible, auditable, forkable
  • Built for agents, not just models — designed for tool calls, MCP, memory, and multi-turn state from day one
  • Trace-aware — integrates with Langfuse and Netra so the LLM judge sees what your agent did internally, not just what it said

Five ways to run opfor

Different people on your team need different entry points. Opfor ships five.

ModeHowBest for
🖥️ CLIopfor setup → opfor runEngineers, CI/CD, terminal-first workflows
🌐 Browser extensionInstall the extension, click the icon on any chat interfaceProduct managers, designers, QA, security analysts — anyone who can't or won't write code
🤖 MCP serverRegister opfor in Cursor or Claude Desktop, then ask in chatAI coding agents that test your other agents
⚡ Skills/opfor-setup · /opfor-run · /opfor-mcp-setup · /opfor-mcp-runDevelopers who want one-command testing inside their IDE
📦 SDKnpm install @keyvaluesystems/agent-opfor-sdk, then call run / hunt from your codeProgrammatic red-teaming and custom workflows

All five share the same evaluators, attack templates, and judge logic.

→ CLI reference · Browser extension setup · MCP setup · Skills setup · SDK reference · Session handling

How it works

When you run a scan, opfor:

  1. Fetches target info — connects to your agent, detects available tools, MCP endpoints, capabilities
  2. Plans attacks per category — generates targeted prompts for each evaluator in your selected suite
  3. Emulates the attack — runs multi-turn adversarial conversations (real requests, real responses)
  4. Evaluates with a judge — an LLM judge classifies each response with pass/fail + reasoning
  5. Generates a report — HTML for browsing, JSON for CI/CD, all artifacts logged for reproducibility

Each run lands in its own subfolder under .opfor/reports/run-report-<compactTs>-<slug>-<shortId>/ containing <slug>-report.html and <slug>-report.json. Autonomous opfor hunt runs use the same layout under hunt-report-<compactTs>-<slug>-<shortId>/.

Testing cost

Every run reports what its instrumented LLM calls cost, broken down by model:

text
Token usage: 51,323 input / 6,057 output (57,380 total)
Testing cost: $0.18
   deepseek/deepseek-v4-pro [attacker]: $0.037
   anthropic/claude-opus-5 [judge]: $0.14

This is opfor's own spend — the attacker and judge LLMs. It excludes your target's inference cost, which opfor cannot see from the outside. The per-model split is the useful part: the judge is often the bigger share, and pointing it at a cheaper model is usually the easiest saving.

Prices come from a snapshot of LiteLLM's public price map that ships with the package, so runs work offline and a report re-rendered later produces the same figure. Cached input is billed at the provider's cache rate — multi-turn attacks re-send the conversation each turn, and that repeated prefix is often ~100× cheaper than fresh text, so the figure tracks the real bill rather than a worst case. Caveats worth knowing:

  • Caching is only credited when it's reported. A provider that doesn't break out cached tokens, or a model with no published cache rate, is charged at the full input rate — an over-estimate, chosen over quietly under-reporting.
  • Unknown models are never counted as free. A model missing from the price table is reported as unpriced and the total is marked a lower bound, rather than silently reading as $0.
  • A few helper calls aren't metered yet. Trace curation, session summarisation and one JSON helper don't report token usage, so their spend is missing from the total. Treat the figure as a floor.

→ Token usage and testing cost

Evaluator coverage

Opfor ships with curated suites that map to industry standards. Pick a suite or run individual evaluators.

Suite IDStandardFocus
owasp-llm-top10OWASP LLM Top 10 (2025)Prompt injection, jailbreaks, sensitive disclosure, system prompt leakage
owasp-agentic-aiOWASP Agentic AI Top 10Excessive agency, tool misuse, agent goal hijack, memory poisoning
owasp-mcp-top10OWASP MCP Top 10 (2025)Secret exposure, scope escalation, tool description injection, SSRF
owasp-apiOWASP API Security Top 10BOLA, BFLA, SQL injection
eu-ai-act-biasEU AI Act — BiasAge, gender, race, disability

→ Full evaluator reference and OWASP mapping

Trace-aware testing

Plug opfor into your observability stack and the LLM judge sees not just the final response — but every tool call, retrieval, and intermediate reasoning step. Out of the box, opfor integrates with Langfuse and Netra.

json
"telemetry": {
  "provider": "langfuse",
  "langfuse": { "baseUrl": "https://cloud.langfuse.com" }
}

This catches what input/output testing misses — PII that leaks into a tool call but never reaches the user, scope escalations in MCP that don't change the response text, agents that retrieve unauthorized data but render a clean reply.

→ Trace-aware testing guide

Autonomous Red-Teaming

opfor hunt skips the config file entirely. Give it an endpoint and an objective, and a multi-agent system — commander, operators, scout — runs an adaptive attack campaign on its own: recon, strategy, multi-turn probing, report. Unlike opfor run, the agents run on Claude only (via a Claude API key, claude setup-token, or your local claude login session) — your target can be anything.

bash
opfor hunt \
  --endpoint "https://your-agent.com/v1/chat" \
  --objective "Find jailbreaks, system-prompt leakage, and safety bypasses."

Add --ui to watch the attack tree unfold in a live dashboard.

→ Full reference

Browser extension — red-team a chatbot

The browser extension is opfor's no-code path. Install from the Chrome Web Store, open any chat interface, click the opfor icon, pick a suite, and watch it run.

https://github.com/user-attachments/assets/80c2692f-b18b-4899-99df-e7eb8d50b02a

It auto-detects the chat interface, sends attack prompts as if you were typing them, watches the responses, and downloads an HTML report when done. No CLI, no target setup, no YAML.

This is the path for the half of every product team that doesn't open a terminal.

→ Install from the Chrome Web Store · Setup guide

SDK — embed red-teaming in your code

The SDK is opfor's programmatic path. Install @keyvaluesystems/agent-opfor-sdk, call run or hunt, and get structured results back — no CLI, no config files, no subprocess.

typescript
import { Opfor } from "@keyvaluesystems/agent-opfor-sdk";

const opfor = new Opfor({ apiKey: process.env.ANTHROPIC_API_KEY });

const results = await opfor.run({
  target: { url: "https://api.example.com/chat" },
  suite: "owasp-llm-top10",
});

Use it in CI, in test suites, or anywhere you need red-teaming without leaving TypeScript.

→ SDK reference

Examples

ExampleDescription
vanilla-chatPlain customer support chatbot — test LLM-level vulnerabilities
customer-supportTool-calling agent with PostgreSQL — test BOLA, BFLA, RBAC, PII
vulnerable-serverSample MCP server with intentional vulnerabilities

Supported LLM providers

ProviderEnv varDefault model
GroqGROQ_API_KEYllama-3.3-70b-versatile
OpenAIOPENAI_API_KEYgpt-4o-mini
AnthropicANTHROPIC_API_KEYclaude-3-5-haiku-20241022
GoogleGOOGLE_GENERATIVE_AI_API_KEYgemini-2.0-flash
OpenAI-compatibleOPFOR_API_KEY + baseURLLiteLLM, OpenRouter, Azure, Ollama

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

 

Authors

Built by the team at KeyValue Software Systems. Contact contact@agentopfor.ai for all enquiries.

 

Security

Use opfor only on systems you own or are authorized to test. To report a vulnerability in opfor itself, see SECURITY.md — do not open a public issue.

 

License

Opfor is licensed under Apache 2.0 — see the LICENSE file for details.


Use Agent Opfor MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Agent Opfor is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Agent Opfor as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Agent Opfor MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "agent-opfor": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Agent Opfor MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Agent Opfor MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Agent Opfor to help me with this task?
Agent Opfor
Sure. I read it.
Here is what I found using Agent Opfor.

Frequently asked questions

What is the Agent Opfor MCP server used for?

Agent Opfor is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Agent Opfor MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Agent Opfor with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Agent Opfor MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Agent Opfor connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Agent Opfor MCP to TypingMind?

Agent Opfor runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Agent Opfor MCP provide in TypingMind?

Agent Opfor exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Agent Opfor MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Agent Opfor requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇