aeat.entrypoints.mcp._toolsets module

Group the manifest-derived tools into domain toolsets.

Dumping the whole verb tree into tools/list crowds out the user’s question and degrades tool selection, so the console groups the common surfaces into a small closed set of domain toolsets (per ADR decision R2). The five toolsets - renta, iva, ledger, censo, modelo-lifecycle - are the curated common path; verbs outside them are reached through the search + execute meta-tool fallback, so a toolset is a curated subset, never a full partition.

Membership is DERIVED, never hand-listed. ledger and modelo-lifecycle map directly onto their live operator-surface manifest domains (MountedCommandDomain). The three tax-concept toolsets are finer than the family-granular manifest can express, so they key on the command tree’s own stable segment tokens - the census surface (Modelo 036 plus the censo profile sync), the IVA wallet surface, and the renta draft (borrador) surface. In every case the member set is computed against the live command keys, so a verb added to any of these surfaces joins its toolset automatically and the console cannot drift from the CLI.

This module owns no MCP protocol detail; it reads the manifest and the command keys and emits SDK-independent pydantic records, so it is unit-tested directly.

class Toolset(*values)[source]

Bases: StrEnum

The closed set of curated domain toolsets the console groups tools into.

RENTA
IVA
LEDGER
CENSO
MODELO_LIFECYCLE
class ToolsetGroup(**data)[source]

Bases: BaseModel

One toolset and the command keys derived into it from the live surface.

Parameters:
toolset: Toolset
command_keys: tuple[str, ...]
toolset_for_command(command_key, *, family_map)[source]

Classify one command key into its curated toolset, or None for the tail.

The tax-concept toolsets carve out of the modelo domain first (the census and IVA-wallet surfaces are Modelo verbs a client would expect grouped by tax concept, not lumped under the generic lifecycle), then the remaining domain families map through the manifest. A key that matches no curated toolset falls to the meta-tool fallback.

Return type:

Toolset | None

Returns:

The owning Toolset, or None when the key is long-tail.

Parameters:
MAX_ACTIVE_TOOLSETS

The hard cap on simultaneously-active toolsets. Activation is an enhancement that widens the advertised surface within the persona scope (ADR mcp-progressive-discovery P3); a cap keeps the surface from creeping back toward the flat listing the core surface exists to avoid.

command_keys_for_toolsets(active)[source]

Return every command key belonging to an active toolset.

The union of the member keys of the active groups, derived from the live toolset membership so it cannot drift from the manifest.

Return type:

frozenset[str]

Parameters:

active (frozenset[Toolset])

build_toolsets()[source]

Derive the toolset membership from the live manifest and command keys.

Every exposable command key is classified once through toolset_for_command(); the result is one ToolsetGroup per Toolset in declaration order, each carrying its sorted member keys. Long-tail keys belong to no group and are omitted.

Return type:

tuple[ToolsetGroup, ...]

Returns:

One ToolsetGroup per toolset, in Toolset order.