RedTeam ML API MCP
Enables security teams to run controlled adversarial penetration tests against authorized ML/LLM API endpoints, scoring responses and generating evidence for compliance frameworks such as SOC 2, ISO 27001, and GDPR.
README
RedTeam ML API MCP
Professional AI/ML API penetration testing and red-team simulation over MCP.
RedTeam ML API MCP is a defensive red-team simulator for ML and LLM APIs.
It exposes MCP tools and a CLI that let a security team run controlled test packs against an authorized AI/ML API endpoint, score the responses, generate evidence, and align results to SOC 2, ISO 27001, and GDPR control areas.
Mindset Shift
This project is designed as an adversarial validation plane for AI systems.
The mindset shift is:
- From prompt lists to measurable security controls.
- From one-time red-team demos to continuous adversarial regression.
- From model safety only to full AI system safety: model, prompt, RAG, tools, identity, UI, and deployment.
- From guardrails as a checkbox to guardrails as evidence-backed controls.
- From pass/fail reports to release decisions with owners, evidence, and remediation.
For AWS-facing work, position it as:
RedTeam ML API MCP validates whether Bedrock Guardrails, application policies, RAG boundaries, and agent tool controls are working before release.
AI API Pentest Mode
The red-team value is the pentest workflow:
- Define authorized scope and rules of engagement.
- Perform safe endpoint recon without infrastructure exploitation.
- Run adversarial AI test campaigns.
- Capture evidence for each case.
- Calculate bypass rate by category.
- Map failures to guardrail and architecture controls.
- Align results to SOC 2, ISO 27001, and GDPR control areas.
- Produce JSON and HTML artifacts for security review.
This is designed for authorized AI/ML API penetration testing. It does not perform credential attacks, destructive actions, third-party scanning, or infrastructure exploitation.
Low-Impact Safety
The runner is built to avoid unnecessary pressure on target systems:
- Default delay between test cases.
- Per-request timeout.
- Optional max-case limit.
- Dry-run mode that validates scope without sending prompts.
- Explicit
--authorizedgate for pentest mode.
Example low-impact run:
redteam-ml-api pentest \
--target-url http://127.0.0.1:8765/chat \
--pack aws_2026_professional \
--authorized \
--delay-seconds 1.0 \
--max-cases 5
Core Idea
Many ML APIs are deployed with weak safety, privacy, or operational controls. This project tests those controls before production by simulating realistic but safe adversarial requests.
The simulator focuses on:
- Prompt-injection resilience.
- Sensitive data leakage.
- Unsafe model behavior.
- Excessive confidence or hallucinated policy claims.
- Weak API contract behavior.
- Regression testing between model versions.
Infrastructure Diagram
flowchart LR
Operator["Security / MLOps Operator"] --> Client["MCP Client\n(Codex, Claude, Cursor, etc.)"]
Client --> Server["RedTeam ML API MCP Server\nstdio JSON-RPC"]
Server --> Packs["Attack Packs\nJSON test cases"]
Server --> Runner["Test Runner\nrate limits + request templates"]
Runner --> Target["Authorized ML API\n/score, /chat, /predict"]
Target --> Runner
Runner --> Evaluator["Response Evaluator\nleakage + refusal + policy checks"]
Evaluator --> Store["Local Evidence\nJSON reports"]
Store --> Client
Client --> Report["Risk Summary + Remediation Plan"]
Workflow
sequenceDiagram
participant U as Operator
participant C as MCP Client
participant M as RedTeam MCP Server
participant A as Attack Pack
participant T as Target ML API
participant E as Evaluator
U->>C: Run red-team pack against staging API
C->>M: tools/call run_red_team
M->>A: Load prompt-injection / leakage cases
loop Each test case
M->>T: Send authorized HTTP request
T-->>M: Return model/API response
M->>E: Score response
end
E-->>M: Findings + risk score
M-->>C: Structured report
C-->>U: Summary and fixes
MCP Tools
list_attack_packs
Lists available local test packs.
run_red_team
Runs an attack pack against an authorized target.
Input:
{
"target_url": "http://localhost:8000/chat",
"pack": "baseline_safe",
"method": "POST",
"timeout_seconds": 10
}
evaluate_text
Scores a single response for risk signals.
Input:
{
"text": "model response here"
}
generate_report
Creates a compact remediation report from a previous run result.
generate_operating_model
Creates a strategic operating-model brief for security teams, red teams, AI architects, platform teams, and executive sponsors.
It maps red-team categories to guardrail controls, architecture controls, owners, and release decisions.
run_ai_api_pentest
Runs an authorized AI/ML API pentest workflow with scope, recon, campaign execution, evidence, metrics, release decision, and saved report artifacts.
Quick Start
cd "/Users/r.jqaim/renad-repo/RedTeam-ML-PenTest-MCP"
python3 -m venv .venv
. .venv/bin/activate
pip install -e ".[dev]"
python -m pytest
Run the demo API:
scripts/start_mock_api.sh
Open the browser health check:
http://127.0.0.1:8765/
Try a sample browser request:
http://127.0.0.1:8765/chat?input=hello
Stop the demo API when finished:
scripts/stop_mock_api.sh
Run the simulator in another terminal:
redteam-ml-api run --target-url http://127.0.0.1:8765/chat --pack baseline_safe
Run the professional 2026 AWS-facing pack:
redteam-ml-api run --target-url http://127.0.0.1:8765/chat --pack aws_2026_professional --report
Generate the mindset-shift operating model:
redteam-ml-api brief --target-url http://127.0.0.1:8765/chat --pack aws_2026_professional
Run a pentest engagement:
redteam-ml-api pentest \
--target-url http://127.0.0.1:8765/chat \
--pack aws_2026_professional \
--tester "Red Team" \
--environment "staging" \
--authorized
Run from a reusable config file:
redteam-ml-api pentest --config examples/pentest_scope.json
Authenticated API example:
redteam-ml-api pentest \
--target-url https://api.example.com/chat \
--authorized \
--bearer-token "$API_TOKEN" \
--header "X-Environment: staging" \
--input-field message \
--delay-seconds 1.0
Reports are saved under:
reports/
Or run the full demo:
scripts/demo_pentest.sh
More details:
Start the MCP server:
redteam-ml-api-mcp
MCP Client Config
{
"mcpServers": {
"redteam-ml-api": {
"command": "python",
"args": ["-m", "redteam_ml_api_mcp.server"],
"cwd": "/Users/r.jqaim/renad-repo/RedTeam-ML-PenTest-MCP"
}
}
}
Safety Boundary
This project is for authorized defensive testing only. It does not exploit infrastructure, bypass authentication, scan third-party systems, or generate malware. Attack packs are plain JSON so teams can review exactly what is being sent.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。