Skip to main content
Glama
umbra2728

CTFd MCP Server

submit_flag

Submit a flag for a challenge ID in CTFd Capture The Flag competitions to verify your solution and earn points.

Instructions

Submit a flag for a challenge ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
challenge_idYes
flagYes

Implementation Reference

  • MCP tool registration and handler for submit_flag. Decorated with @mcp.tool, accepts challenge_id (int) and flag (str), delegates to CTFdClient.submit_flag, and wraps errors.
    @mcp.tool(description="Submit a flag for a challenge ID.")
    async def submit_flag(challenge_id: int, flag: str):
        client = await _get_client()
        try:
            return await client.submit_flag(challenge_id, flag)
        except Exception as exc:  # noqa: BLE001 - map to user-friendly MCP error
            raise _format_error(exc)
  • Core handler implementation in CTFdClient class. Sends POST to /api/v1/challenges/attempt with challenge_id and submission, returns status and message from response.
    async def submit_flag(self, challenge_id: int, flag: str) -> dict[str, Any]:
        """Attempt a flag submission for a challenge."""
        payload = await self._request(
            "POST",
            "/api/v1/challenges/attempt",
            json={"challenge_id": challenge_id, "submission": flag},
        )
        data = payload.get("data") or {}
        return {
            "status": data.get("status"),
            "message": data.get("message"),
        }
  • Schema definition: takes challenge_id (int) and flag (str) as parameters, no explicit return typing but returns dict with status and message.
    @mcp.tool(description="Submit a flag for a challenge ID.")
    async def submit_flag(challenge_id: int, flag: str):
        client = await _get_client()
        try:
            return await client.submit_flag(challenge_id, flag)
        except Exception as exc:  # noqa: BLE001 - map to user-friendly MCP error
            raise _format_error(exc)
  • Error formatting helper used by submit_flag to convert exceptions to RuntimeError with user-friendly messages.
    def _format_error(exc: Exception) -> RuntimeError:
        if isinstance(exc, ConfigError):
            message = f"Configuration error: {exc}"
        elif isinstance(exc, AuthError):
            message = f"Auth failed: {exc}"
        elif isinstance(exc, NotFoundError):
            message = f"Not found: {exc}"
        elif isinstance(exc, RateLimitError):
            retry = (
                f" Retry-After={exc.retry_after}."
                if getattr(exc, "retry_after", None)
                else ""
            )
            message = f"Rate limited.{retry}".strip()
        elif isinstance(exc, CTFdClientError):
            message = f"CTFd API error: {exc}"
        else:
            message = f"Unexpected error: {exc}"
        return RuntimeError(message)
Behavior1/5

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

No annotations are present, and the description provides no behavioral details. It does not disclose whether flag submission is idempotent, what the side effects are (e.g., scoring), or any error conditions. The agent has no insight into tool behavior.

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

Conciseness2/5

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

The description is extremely short but fails to convey necessary information. While brevity is valued, this description is under-specified and does not earn its place as an informative guide for an AI agent.

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

Completeness1/5

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

Given the lack of annotations, output schema, and parameter descriptions, the description is completely inadequate. It does not provide enough context for the agent to know when to use the tool, what the return value looks like, or how it fits into the challenge lifecycle.

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?

Schema description coverage is 0%, and the description adds no meaning beyond the property names. It does not explain what 'flag' format is expected, how to obtain challenge_id, or any constraints like case sensitivity. The description fails to compensate for the missing schema descriptions.

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

Purpose4/5

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

The description clearly states the action (submit) and resource (flag for a challenge ID). It is specific enough to distinguish from sibling tools like list_challenges and start_container, which have different purposes.

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

Usage Guidelines2/5

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

No usage guidelines are provided. The description does not mention when to use this tool, any prerequisites (e.g., must have a started container), or when to avoid it. No alternatives are listed compared to siblings.

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