git404hub

what is mcp_safety_training fr?

johnhalloran321/mcp_safety_training — explained in plain English

Analysis updated 2026-05-18

4PythonAudience · researcherComplexity · 5/5LicenseSetup · hard

tl;dr

Research code that trains and evaluates methods for teaching tool-using AI models to refuse harmful requests disguised as ordinary, harmless-sounding ones.

vibe map

mindmap
  root((MCP Safety Training))
    What it does
      Detects disguised tool attacks
      Trains safer models
      Evaluates refusal rates
    Methods
      DPO and SafeDPO training
      OPAD decoding
      RAG-Pref retrieval
    Data
      Hugging Face preference dataset
      Held out attack prompts
      Held out benign prompts
    Tech stack
      Python
      PyTorch
      CUDA GPU
    Audience
      AI safety researchers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

what do people make with this?

VIBE 1

Train a tool-using language model with DPO or SafeDPO to refuse disguised harmful tool requests

VIBE 2

Evaluate how often a model refuses attacks versus genuinely benign requests using the included test sets

VIBE 3

Try the training-free RAG-Pref method to improve refusal rates without fine-tuning a model

VIBE 4

Reproduce the refusal-rate results reported in the accompanying research papers

what's the stack?

PythonPyTorchCUDAHugging Face

how it stacks up fr

johnhalloran321/mcp_safety_training1038lab/agnes-ai3eyedtiger/video2vrcemote
Stars444
LanguagePythonPythonPython
Setup difficultyhardeasyeasy
Complexity5/52/51/5
Audienceresearchervibe codervibe coder

Figures from each repo's GitHub metadata at analysis time.

how do i run it?

Difficulty · hard time til it works · 1day+

Requires a CUDA GPU, Python 3.11, matched PyTorch and flash-attention builds, and Hugging Face login for the gated dataset.

Use freely for any purpose, including commercial use, as long as you keep the copyright and license notices.

in plain english

This repository is the companion code for two research papers on making AI models that use external tools safer. It focuses on a specific problem: some requests to a tool-using AI model look completely harmless on the surface but are actually designed to trick the model into misusing its tools in a harmful way, a category the authors call falsely-benign MCP exploits, referring to attacks that use the Model Context Protocol that AI tools rely on to interact with files and other resources. The code trains and evaluates several methods for teaching a model to recognize and refuse these disguised attacks while still responding normally to genuinely harmless requests. It includes standard preference alignment training methods called DPO and SafeDPO, which fine-tune a model using pairs of good and bad example responses, plus two methods that need no training at all: OPAD, which changes how the model generates text on the fly based on stated safety principles, and RAG-Pref, which looks up similar past examples of attacks and safe requests at the moment of generation and feeds them into the model's instructions to guide its response. According to the README, models tested without any of these defenses refused fewer than 35 percent of the disguised attacks, standard DPO and SafeDPO training only raised that to about 48 percent, while RAG-Pref roughly tripled the refusal rate on its own and nearly quadrupled it when combined with DPO or SafeDPO training. The project includes its own training and evaluation dataset hosted on Hugging Face, containing preference pairs for training plus separate held-out sets of disguised attacks and genuinely benign prompts for measuring both refusal of attacks and over-refusal of safe requests. Running the training scripts requires a CUDA capable GPU, Python 3.11, and several machine learning libraries including PyTorch and a flash-attention build matched to that PyTorch version. The project is released under the Apache 2.0 license.

prompts (copy fr)

prompt 1
Explain what a falsely-benign MCP exploit is and why it is hard for models to refuse
prompt 2
Walk me through setting up the environment to run dpo.py or safedpo.py on a GPU
prompt 3
Compare how DPO, SafeDPO, OPAD, and RAG-Pref differ in this codebase
prompt 4
Help me understand the two-stage evaluation pipeline that scores model responses for refusal

Frequently asked questions

what is mcp_safety_training fr?

Research code that trains and evaluates methods for teaching tool-using AI models to refuse harmful requests disguised as ordinary, harmless-sounding ones.

What language is mcp_safety_training written in?

Mainly Python. The stack also includes Python, PyTorch, CUDA.

What license does mcp_safety_training use?

Use freely for any purpose, including commercial use, as long as you keep the copyright and license notices.

How hard is mcp_safety_training to set up?

Setup difficulty is rated hard, with roughly 1day+ to a first successful run.

Who is mcp_safety_training for?

Mainly researcher.

peek the repo → explain another one

This repo across BitVibe Labs

double-check against the repo, no cap.