CTFd — Claude Code MCP server: setup and use
Connects an AI agent to CTFd v3 to browse challenges, inspect details, submit flags, and query instance state.
claude mcp add --env CTFD_BASE_URL=<CTFD_BASE_URL> --env CTFD_ADMIN_TOKEN=<CTFD_ADMIN_TOKEN> --env CTFD_SESSION_COOKIE=<CTFD_SESSION_COOKIE> --env CTFD_USERNAME=<CTFD_USERNAME> --env CTFD_PASSWORD=<CTFD_PASSWORD> --transport stdio ctfd -- uvx ctfd-mcp-serverWhat CTFd does
CTFd gives an agent MCP access to a CTFd v3 instance. It can fetch challenge pages with category, name-search, and solved-state filters, inspect an individual challenge, check instance health, and submit a flag. Flag submission requires an explicit confirm=True value.
The package exposes MCP tools through a shared CTFd client. Authentication can use an API token, a session cookie, or a username and password; credentials remain in memory. The default MCP transport is stdio, while an optional FastAPI REST interface is available for scripts and Docker deployments.
Python 3.10+ is required. Set CTFD_BASE_URL to the CTFd instance root, without /api/v1, and provide authentication through environment variables. Without Python 3.10+, the server will not start.
What it helps with
- list CTFd challenges with filters
- inspect a challenge and its details
- submit a flag after confirmation
- check instance health and access
- query the scoreboard and instance state
Example prompts for the agent
- Connect to CTFd and list unsolved challenges in the
webcategory. - Inspect the challenge named
SQL Injectionand summarize the fields available to the agent. - Verify this flag, then submit it to CTFd only with explicit
confirm=True.
How to install CTFd
Platform CLI
claude mcp add --env CTFD_BASE_URL=<CTFD_BASE_URL> --env CTFD_ADMIN_TOKEN=<CTFD_ADMIN_TOKEN> --env CTFD_SESSION_COOKIE=<CTFD_SESSION_COOKIE> --env CTFD_USERNAME=<CTFD_USERNAME> --env CTFD_PASSWORD=<CTFD_PASSWORD> --transport stdio ctfd -- uvx ctfd-mcp-serverReplace <…> with your own values. 1 more environment variable is in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from ctfd-mcp-server <command>
Platform CLI
codex mcp add ctfd --env CTFD_BASE_URL=<CTFD_BASE_URL> --env CTFD_ADMIN_TOKEN=<CTFD_ADMIN_TOKEN> --env CTFD_SESSION_COOKIE=<CTFD_SESSION_COOKIE> --env CTFD_USERNAME=<CTFD_USERNAME> --env CTFD_PASSWORD=<CTFD_PASSWORD> -- uvx ctfd-mcp-serverReplace <…> with your own values. 1 more environment variable is in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from ctfd-mcp-server <command>
Config file
{
"mcpServers": {
"ctfd": {
"command": "uvx",
"args": [
"ctfd-mcp-server"
],
"env": {
"CTFD_BASE_URL": "<CTFD_BASE_URL>",
"CTFD_ADMIN_TOKEN": "<CTFD_ADMIN_TOKEN>",
"CTFD_SESSION_COOKIE": "<CTFD_SESSION_COOKIE>",
"CTFD_USERNAME": "<CTFD_USERNAME>",
"CTFD_PASSWORD": "<CTFD_PASSWORD>"
}
}
}
}Replace <…> with your own values. 1 more environment variable is in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from ctfd-mcp-server <command>
Config file
{
"servers": {
"ctfd": {
"type": "stdio",
"command": "uvx",
"args": [
"ctfd-mcp-server"
],
"env": {
"CTFD_BASE_URL": "<CTFD_BASE_URL>",
"CTFD_ADMIN_TOKEN": "<CTFD_ADMIN_TOKEN>",
"CTFD_SESSION_COOKIE": "<CTFD_SESSION_COOKIE>",
"CTFD_USERNAME": "<CTFD_USERNAME>",
"CTFD_PASSWORD": "<CTFD_PASSWORD>"
}
}
}
}Replace <…> with your own values. 1 more environment variable is in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from ctfd-mcp-server <command>
Platform CLI
gemini mcp add -e CTFD_BASE_URL=<CTFD_BASE_URL> -e CTFD_ADMIN_TOKEN=<CTFD_ADMIN_TOKEN> -e CTFD_SESSION_COOKIE=<CTFD_SESSION_COOKIE> -e CTFD_USERNAME=<CTFD_USERNAME> -e CTFD_PASSWORD=<CTFD_PASSWORD> ctfd uvx ctfd-mcp-serverReplace <…> with your own values. 1 more environment variable is in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from ctfd-mcp-server <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about CTFd
How do I install CTFd in Claude Code?
Run `claude mcp add ctfd-mcp-server -e CTFD_BASE_URL=<CTFD_BASE_URL> -e CTFD_ADMIN_TOKEN=<CTFD_ADMIN_TOKEN> -e CTFD_SESSION_COOKIE=<CTFD_SESSION_COOKIE> -e CTFD_PASSWORD=<CTFD_PASSWORD> -- uvx ctfd-mcp-server`. The environment variables provide the instance URL and authentication details.
What does CTFd do?
This MCP server connects an AI agent to CTFd v3 for challenge discovery, challenge inspection, flag submission, and instance-state queries.
Which authentication methods does CTFd support?
It supports an API token, a session cookie, or username-and-password form login with CSRF handling.