Skip to main content
Glama

task_fingerprint

Converts natural-language task descriptions into COV tokens for architecture-aware analysis.

Instructions

Translate natural-language task text into COV tokens.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYes
max_tokensNo

Implementation Reference

  • Core implementation of the task_fingerprint method. Maps a natural-language task description into COV (code-operation vocabulary) tokens by matching terms against _TASK_TOKEN_TERMS, scoring them, and returning a fingerprint dict with tokens, confidence, and status.
    def task_fingerprint(self, task: str, max_tokens: int = 8) -> dict[str, Any]:
        """Map a natural-language task into a COV token fingerprint."""
        max_tokens = max(1, min(max_tokens, 16))
        key = ("task_fingerprint", task, max_tokens)
    
        def _build() -> dict[str, Any]:
            text = task.strip()
            low = text.lower()
            scored: list[dict[str, Any]] = []
            evidence_weight = 0
    
            for token, terms in self._TASK_TOKEN_TERMS.items():
                matched_terms = [term for term in terms if self._match_term(low, term)]
                if not matched_terms:
                    continue
                evidence_weight += len(matched_terms)
                score = min(0.98, 0.35 + (0.12 * len(matched_terms)))
                scored.append(
                    {
                        "token": token,
                        "score": round(score, 3),
                        "matched_terms": matched_terms,
                    }
                )
    
            scored.sort(key=lambda row: (row["score"], len(row["matched_terms"]), row["token"]), reverse=True)
            selected = scored[:max_tokens]
            task_cov = [row["token"] for row in selected]
    
            vague_hits = [term for term in self._VAGUE_TASK_TERMS if self._match_term(low, term)]
            confidence = 0.1
            if selected:
                confidence = 0.28 + (0.08 * len(selected)) + (0.05 * (evidence_weight / max(1, len(selected))))
            if vague_hits and len(selected) <= 2:
                confidence -= 0.12
            confidence = round(max(0.05, min(0.95, confidence)), 2)
    
            if not selected or confidence < 0.35:
                status = "insufficient_signal"
            elif confidence < 0.55:
                status = "ambiguous"
            else:
                status = "ok"
    
            return {
                "task": task,
                "tokens": task_cov,
                "scored_tokens": selected,
                "confidence": confidence,
                "status": status,
                "vague_terms_detected": vague_hits,
                "interpretation": f"interpreted as COV tokens: {task_cov}" if task_cov else "could not infer clear COV tokens",
            }
    
        return self._cached(key, _build)
  • MCP tool registration for task_fingerprint using the @mcp.tool() decorator. Defines the tool's name, docstring, parameters (task, max_tokens), and delegates to service.task_fingerprint().
    @mcp.tool()
    def task_fingerprint(task: str, max_tokens: int = 8):
        """Convert a natural-language task description into COV (code-operation vocabulary) tokens.
    
        Use this to extract the structured intent of a task before searching for
        behavioral twins. COV tokens represent the canonical operations implied by
        the task (e.g. "validate", "persist", "emit-event"). Do NOT use this for
        symbol search — use search_symbols instead.
    
        Args:
            task: Natural-language task description (e.g. "add retry logic to the HTTP client").
            max_tokens: Maximum number of COV tokens to return (default 8).
    
        Returns:
            A list of COV token strings ranked by relevance to the task.
        """
        return service.task_fingerprint(task=task, max_tokens=max_tokens)
  • Vague task terms list and the _TASK_TOKEN_TERMS dictionary defining all COV token categories and their matching keywords (e.g., INTAKE, OUTPUT, VALIDATE, PERSIST) used by task_fingerprint.
    _VAGUE_TASK_TERMS = ("fix", "bug", "issue", "problem", "improve", "optimize", "refactor", "clean up")
    _TASK_TOKEN_TERMS: dict[str, tuple[str, ...]] = {
        "INTAKE": ("input", "request", "payload", "parameter", "param", "args", "ingest", "receive"),
        "OUTPUT": ("output", "response", "return", "render", "reply"),
        "TRANSFORM": ("transform", "map", "convert", "normalize", "format"),
        "MUTATE": ("mutate", "update", "modify", "change state"),
        "SANITIZE": ("sanitize", "escape", "clean", "scrub"),
        "CONDITIONAL": ("if", "condition", "branch", "switch"),
        "LOOP": ("loop", "iterate", "for each", "batch"),
        "GUARD": ("guard", "check", "prevent", "reject"),
        "ROUTE": ("route", "endpoint", "handler", "controller", "api"),
        "SCOPE": ("scope", "local", "global", "nested"),
        "FETCH": ("fetch", "read", "load", "query", "get"),
        "PERSIST": ("persist", "save", "store", "write", "commit", "insert"),
        "EMIT": ("emit", "publish", "notify", "send event", "dispatch"),
        "SUBSCRIBE": ("subscribe", "listener", "consumer", "watch"),
        "DELEGATE": ("delegate", "forward", "proxy", "handoff"),
        "CONTRACT": ("interface", "protocol", "contract", "schema"),
        "COMPOSE": ("compose", "assemble", "aggregate", "combine"),
        "INIT": ("init", "initialize", "setup", "boot"),
        "TEARDOWN": ("teardown", "cleanup", "shutdown", "close"),
        "RAISE": ("raise", "throw", "fail", "error"),
        "RECOVER": ("recover", "retry", "fallback", "handle error"),
        "DEFER": ("defer", "finally", "after", "ensure"),
        "AUTHENTICATE": ("authenticate", "login", "sign in", "identity"),
        "AUTHORIZE": ("authorize", "permission", "access control", "policy"),
        "VALIDATE": ("validate", "verify", "check input", "assert"),
        "LOG": ("log", "audit", "trace"),
        "MEASURE": ("measure", "metric", "latency", "timing", "telemetry"),
        "ASYNC": ("async", "await", "goroutine", "concurrent", "background"),
        "TEST": ("test", "assertion", "unit test", "integration test"),
    }
  • The _match_term helper used by task_fingerprint to match individual terms against the lowercased task text, supporting both single words and multi-word phrases.
    @staticmethod
    def _match_term(text_lower: str, term: str) -> bool:
        if " " in term:
            return term in text_lower
        return re.search(rf"(?<![\\w]){re.escape(term)}(?![\\w])", text_lower) is not None
  • The _cached method used by task_fingerprint to cache results based on a key tuple (task_fingerprint, task, max_tokens) to avoid recomputation.
    def _cached(self, key: tuple[Any, ...], builder) -> Any:
        if key in self._response_cache:
            return self._response_cache[key]
        value = builder()
        self._response_cache[key] = value
        return value
Behavior2/5

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

Without annotations, the description must disclose behavioral traits. It only says 'translate' without specifying side effects, determinism, or prerequisites. This is minimal transparency.

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

Conciseness3/5

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

The description is very concise with a single sentence, which is efficient. However, it is so brief that it omits important details, making it less helpful than it could be.

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 low schema coverage, no annotations, and no output schema, the description is insufficient. It fails to explain what COV tokens are, the nature of the translation, or the output format, leaving major gaps.

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 field names. 'task' and 'max_tokens' are not explained, leaving the agent unsure about valid input formats or constraints.

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 verb 'translate' and the resource 'natural-language task text into COV tokens', which distinguishes it from sibling tools like 'classify_prompt' or 'cluster_of_file'. However, it could be more specific about the scope.

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?

The description provides no guidance on when to use this tool versus alternatives. There is no mention of when it is appropriate or when to avoid it, leaving the agent without usage 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/ahmedxuhri/bigindexer'

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