Skip to main content
Glama

Label Encode

label_encode

Encodes categorical columns into integer codes in alphabetical order, ideal for high-cardinality features and tree-based models. Unseen test categories map to -1.

Instructions

Label encode categorical columns: every category becomes an integer (alphabetical order). Best for high-cardinality columns (e.g. brand) and tree-based models. Categories that only appear in the test data become -1. Args: dataset_id (str): ID of a dataset or of a split. columns (list[str], optional): Categorical columns to encode. If omitted, all categorical columns. Returns: dict: Encoded columns and the category -> integer mapping.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "dataset_id": "<dataset_id>"
    },
    "name": "label_encode"
  }
}

Input Schema

NameRequiredDescriptionDefault
columnsNo
dataset_idYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

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

With no annotations supplied, the description carries the full burden and does disclose meaningful behavior beyond the signature: alphabetical integer assignment, and the critical edge case that test-only categories map to -1. It does not state whether the source dataset is mutated in place or a new dataset/columns are produced, which matters for a transformation tool.

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

Conciseness4/5

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

Front-loaded with the transformation and its use case, followed by compact Args/Returns blocks. The docstring formatting is slightly heavier than prose would be, but every line carries information and nothing is redundant.

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

Completeness4/5

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

A simple two-parameter tool with no output schema, and the Returns note plus mapping behavior covers what the agent needs to call and interpret it. The only material gap is the in-place vs. copy semantics of the transformation, which is not addressed.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate, and it does: an Args block defines dataset_id (dataset or split ID) and columns, including the default semantics 'If omitted, all categorical columns.' That resolves the main ambiguity an agent would face, though it does not state behavior for non-categorical names passed in columns.

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 gives a specific verb and resource ('Label encode categorical columns') and goes further by stating the exact transformation rule: every category becomes an integer in alphabetical order. It is clear what the tool does, but it does not name or differentiate from the sibling encoders (encode_categorical, one_hot_encode).

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?

It offers a positive selection heuristic ('Best for high-cardinality columns (e.g. brand) and tree-based models'), which is real guidance for choosing it. However, there is no explicit when-not condition and no named alternative to use instead for low-cardinality or linear-model cases, so the agent must infer the routing.

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

Deploy Server

Other Tools