SecureFlag MCP Server: A Quick Guide

SecureFlag MCP Server: A Quick Guide

The SecureFlag MCP Server lets you use SecureFlag directly from your AI coding assistant. By connecting assistants such as Claude Code or OpenAI Codex to SecureFlag over the open Model Context Protocol (MCP), you can create and evolve ThreatCanvas threat models, inspect their risks and controls, and get personalized training recommendations without leaving your terminal or IDE.

How It Works

MCP is an open standard that lets AI assistants call external tools. The SecureFlag MCP Server is a remote server (Streamable HTTP): you register its URL once with your assistant, sign in with your SecureFlag account, and the assistant gains a set of SecureFlag tools it can call on your behalf.

When you ask your assistant to threat model the project you are working on, it examines the repository structure and creates an architectural description of the components, how they connect, and where the trust boundaries are. It sends that description to ThreatCanvas. ThreatCanvas then builds the diagram and derives the trust boundaries, data flows, threats, and security controls, just as if the model had been created in the portal.

Data Protection & Privacy

  1. Your source code is not sent to SecureFlag: Only the component-level architectural description composed by your assistant reaches ThreatCanvas, the same class of information you would type into the scenario field in the portal.

  2. You control the AI: The reasoning about your code happens inside your own assistant, under your own AI provider account. SecureFlag only receives tool calls.

  3. Requests run as you: Every tool call is authenticated with your SecureFlag identity and honors your account's permissions, so the assistant can only do what you can do.

Quick Start

Prerequisites

  1. A SecureFlag account with access to the features you plan to use. ThreatCanvas for threat modeling and Training for training recommendations.
  2. Any MCP-capable agent. The examples below use Claude Code and Codex.

Connect Claude Code

Register the server:

claude mcp add --transport http 'SecureFlag'
https://mcp.secureflag.com \
  --client-id sf-claude --callback-port 8765

The first time the server is used, Claude Code opens the SecureFlag Portal in your browser to sign in. On the authorization screen, select the scopes to grant (threat modeling and/or training) so the assistant only gets the access you intend. Then run /mcp inside Claude Code to confirm the SecureFlag server is connected and see its tools.

Connect Codex

Register the server, then sign in:

codex mcp add secureflag --url https://mcp.secureflag.com
codex mcp login secureflag

codex mcp login opens your browser for the SecureFlag sign-in and stores the resulting credentials securely; refreshes happen automatically. On the authorization screen, select the scopes to grant (threat modeling and/or training) so the assistant only gets the access you intend.


Usage Examples

The prompts below work the same way in any connected assistant. Phrase them in your own way, and the assistant will select the right SecureFlag tools.

Manage Threat Models

Create a threat model from your repository

With your coding agent open, ask:

Create a SecureFlag threat model of this application. 

The assistant explores the repository, identifies the components and how they connect, and sends that description to ThreatCanvas. For example, it might identify a React front end, a Spring Boot API, a PostgreSQL database, and an S3 bucket, along with context you provide such as whether it's internet-facing or handles personal data.

ThreatCanvas analyzes the scenario asynchronously. The assistant reports that the model was created, re-checks it until the analysis is complete, then summarizes the identified threats and recommended controls for each component, with a direct link to open the model in ThreatCanvas.


Keep the model in sync as the code evolves

Threat models drift when the architecture changes; with the MCP server connected, updating the model is part of the same conversation as the code change:

We received pull request #203 (branch feature/redis-cache) to add a cache mechanism - investigate the changes and update the threat model accordingly.

The assistant sends only the incremental change; ThreatCanvas merges the new component into the existing diagram and re-derives the affected data flows, threats, and controls. Your existing risk assessments are preserved.

Review the risks in a model

Ask about the current state at any time:

What are the highest risks in our threat model, and are the controls on the API component implemented?

The assistant retrieves a compact summary of the model, including threats and controls grouped by component and trust boundary, plus the data flows between them, and answers from it. You can also ask questions across models, such as “Which of my threat models has the highest risk score?”

Create a model for a teammate (admins) 

Create a model on behalf of a teammate (admins). Administrators can create a model on behalf of another user, who becomes its owner from the start:

Create a threat model for the payments service on behalf of jane.doe@acme.com.

The model is created directly under the named user, who must be an active member of the same organization. Ownership can only be set this way at creation time; if the request isn't permitted, the model is still created (owned by you), and the assistant explains exactly why.

Get Contextual Training

Train for the feature you are about to build

Before starting a security-sensitive task, ask for the training that matches it:

I have to implement an image upload functionality. Which SecureFlag training should I take first?

The assistant recognizes the security topics the task involves and knows your project's technology and framework, so the recommendations are matched to your stack. They include knowledge-base articles and relevant hands-on labs, weighted toward the categories where your recent training accuracy is lowest, with each provided as a direct link to the SecureFlag platform.

Turn threat-model risks into a training plan

Combine both products in one prompt:

Take the top three risks from our threat model and recommend SecureFlag training for each.

The assistant reads the model, extracts the highest-rated threats, and requests training recommendations topic by topic. The result is a ready-made, prioritized practice plan grounded in your actual architecture.

Recommend training for a teammate (admins)

Administrators can personalize recommendations for someone else:

Recommend XSS training for jane.doe@acme.com (she will work on this project React front end)

The recommendations are weighted by that user's training history instead of yours, so they prioritize the areas where the teammate needs the most practice.

Tips & Troubleshooting

  1. Threat modeling is asynchronous: Model creation and updates can take some time; the assistant re-checks the model and reports when the results are in. If it presents results as pending, ask it to check again.

  2. Permission errors: A message like "This tool requires the 'threat-models:write' scope" means your SecureFlag account doesn't grant that permission. Ask your administrator.

  3. Authentication expired or rejected: Sign in again: in Claude Code, open /mcp and re-authenticate the SecureFlag server; in Codex, run codex mcp login secureflag.

  4. Be specific in prompts: The best models come from prompts that state the deployment context the code can't show, such as whether the system is internet-facing and whether it handles payment, personal, or health data.

With the MCP server connected, valuable training and threat modeling becomes part of the development process. The agents building in your SDLC code keeps the threat model and your security training in step with it.