Skip to main content
Glama
umbra2728

CTFd MCP Server

start_container

Detects the active plugin (whale, ctfd-owl, or k8s) and starts a container for the specified challenge ID, enabling dynamic competition environments.

Instructions

Unified start: detects plugin (whale/ctfd-owl/k8s) and starts container.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
challenge_idYes

Implementation Reference

  • MCP tool endpoint for start_container - the async function decorated with @mcp.tool that receives challenge_id and calls client.start_container(challenge_id).
    @mcp.tool(
        description="Unified start: detects plugin (whale/ctfd-owl/k8s) and starts container."
    )
    async def start_container(challenge_id: int):
        client = await _get_client()
        try:
            return await client.start_container(challenge_id)
        except Exception as exc:  # noqa: BLE001
            raise _format_error(exc)
  • Unified start_container implementation on CTFdClient - detects the challenge type (dynamic_docker, dynamic_check_docker, k8s) and dispatches to the appropriate backend handler (start_k8s_container, start_dynamic_container, start_owl_container).
    async def start_container(self, challenge_id: int) -> dict[str, Any]:
        """
        Unified start: detects challenge type and calls the appropriate backend.
        - dynamic_docker -> ctfd-whale /api/v1/containers
        - dynamic_check_docker -> ctfd-owl /plugins/ctfd-owl/container
        - k8s-backed -> /api/v1/k8s (form-based)
        """
        details = await self.get_challenge(challenge_id)
        ctype = (details.get("type") or "").lower()
        if self._is_k8s_type(ctype):
            return await self.start_k8s_container(challenge_id)
        if ctype == "dynamic_docker":
            try:
                return await self.start_dynamic_container(challenge_id)
            except NotFoundError:
                # Some events expose dynamic challenges via /api/v1/k8s while keeping the same type.
                return await self.start_k8s_container(challenge_id)
        if ctype == "dynamic_check_docker":
            return await self.start_owl_container(challenge_id)
        raise CTFdClientError(
            f"Unsupported challenge type '{ctype}' for container start."
        )
  • Schema/return shape for dynamic_docker container start (start_dynamic_container) - returns connection_info, ip, port, host, container_id, etc.
    return self._trim_none(
        {
            "id": data.get("id"),
            "challenge_id": data.get("challenge_id"),
            "state": data.get("state"),
            "connection_info": connection_info,
            "ip": data.get("ip"),
            "port": port,
            "host": host,
            "container_id": data.get("container_id"),
            "created": data.get("created"),
            "raw": data,
        }
    )
  • Schema/return shape for k8s container start (start_k8s_container) - returns connection_info, instance_running, expires_at, etc.
    return {
        "challenge_id": challenge_id,
        "connection_info": connection_info,
        "connection_url": connection_url,
        "connection_port": port,
        "expires_at": expires_at,
        "instance_running": data.get("InstanceRunning"),
        "is_current_instance": data.get("ThisChallengeInstance"),
        "extend_available": data.get("ExtendAvailable"),
        "state": state,
        "raw": data,
    }
  • Schema/return shape for ctfd-owl container start (start_owl_container) - returns connection_info, ip, port, remaining_time, container_id, etc.
    return {
        "id": data.get("id") or container_info.get("id"),
        "challenge_id": data.get("challenge_id") or challenge_id,
        "state": data.get("state") or container_info.get("state"),
        "connection_info": connection_info,
        "ip": ip,
        "port": port,
        "host": host,
        "conntype": conntype,
        "remaining_time": container_info.get("remaining_time")
        or data.get("remaining_time"),
        "container_id": container_info.get("container_id")
        or data.get("container_id"),
        "created": data.get("created") or container_info.get("created"),
        "raw": data,
    }
  • Helper method _is_k8s_type used by start_container to detect k8s-backed challenges.
    @staticmethod
    def _is_k8s_type(ctype: str | None) -> bool:
        if not ctype:
            return False
        lowered = ctype.lower()
        return "k8s" in lowered or "kube" in lowered
  • Helper method _trim_none used by start_container to remove None values from responses.
    @staticmethod
    def _trim_none(values: dict[str, Any]) -> dict[str, Any]:
        """Drop keys with None to keep responses compact."""
        return {k: v for k, v in values.items() if v is not None}
  • Registration of start_container as an MCP tool via @mcp.tool decorator with description.
    @mcp.tool(
        description="Unified start: detects plugin (whale/ctfd-owl/k8s) and starts container."
    )
    async def start_container(challenge_id: int):
        client = await _get_client()
        try:
            return await client.start_container(challenge_id)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the burden. It mentions plugin detection behavior but does not disclose what happens on failure, permissions, or consequences beyond starting.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, front-loaded with key action and plugin detection, and contains no extraneous information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema is provided, and the description omits crucial details such as return values, side effects, prerequisites (e.g., challenge existence), and error conditions, making it incomplete for a start action.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The single required parameter 'challenge_id' has 0% schema description coverage, and the description does not explain its meaning, format, or how to obtain it, leaving the agent without guidance.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the verb 'start' and resource 'container', and explicitly mentions unified detection of plugins (whale, ctfd-owl, k8s), distinguishing it from sibling tools like stop_container.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by stating it is a unified start, but does not provide explicit guidance on when to use this tool versus alternatives, nor does it mention prerequisites or context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/umbra2728/ctfd-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server