Classes
GlobalOption
6
▼
A CLI-wide option available to all commands via Context.
GlobalOption
6
▼
A CLI-wide option available to all commands via Context.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str
|
— |
short |
str
|
— |
option_type |
type
|
— |
default |
Any
|
— |
description |
str
|
— |
is_flag |
bool
|
— |
ResourceDef
5
▼
A registered MCP resource.
ResourceDef
5
▼
A registered MCP resource.
Attributes
| Name | Type | Description |
|---|---|---|
uri |
str
|
— |
name |
str
|
— |
description |
str
|
— |
handler |
Callable[..., Any]
|
— |
mime_type |
str
|
— |
PromptDef
4
▼
A registered MCP prompt.
PromptDef
4
▼
A registered MCP prompt.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str
|
— |
description |
str
|
— |
handler |
Callable[..., Any]
|
— |
arguments |
tuple[dict[str, Any], ...]
|
— |
CommandDef
9
▼
A registered CLI command.
CommandDef
9
▼
A registered CLI command.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str
|
— |
description |
str
|
— |
handler |
Callable[..., Any]
|
— |
schema |
dict[str, Any]
|
— |
aliases |
tuple[str, ...]
|
— |
tags |
tuple[str, ...]
|
— |
hidden |
bool
|
— |
examples |
tuple[dict[str, Any], ...]
|
— |
confirm |
str
|
— |
LazyCommandDef
4
▼
A command whose handler is imported on first use.
Stores a dotted import path (``module:attribute`…
LazyCommandDef
4
▼
A command whose handler is imported on first use.
Stores a dotted import path (module:attribute) and defers the
actual import until the command is invoked. This keeps CLI startup
fast even with dozens of commands.
If schema is provided upfront, MCPtools/listand llms.txt
can be generated without importing the handler module at all.
Methods
schema
0
dict[str, Any]
▼
Return pre-computed schema or resolve to get it.
property
schema
0
dict[str, Any]
▼
def schema(self) -> dict[str, Any]
Returns
dict[str, Any]
handler
0
Callable[..., Any]
▼
Resolve and return the handler function.
property
handler
0
Callable[..., Any]
▼
def handler(self) -> Callable[..., Any]
Returns
Callable[..., Any]
resolve
0
CommandDef
▼
Import the handler and cache as a full CommandDef. Thread-safe.
resolve
0
CommandDef
▼
def resolve(self) -> CommandDef
Returns
CommandDef
Internal Methods 1 ▼
__init__
9
▼
__init__
9
▼
def __init__(self, name: str, import_path: str, description: str = '', *, schema: dict[str, Any] | None = None, aliases: tuple[str, ...] | list[str] = (), tags: tuple[str, ...] | list[str] = (), hidden: bool = False, examples: tuple[dict[str, Any], ...] | list[dict[str, Any]] = (), confirm: str = '') -> None
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
|
import_path |
— |
|
description |
— |
Default:''
|
schema |
— |
Default:None
|
aliases |
— |
Default:()
|
tags |
— |
Default:()
|
hidden |
— |
Default:False
|
examples |
— |
Default:()
|
confirm |
— |
Default:''
|
InvokeResult
5
▼
Result of CLI.invoke() for testing.
InvokeResult
5
▼
Result of CLI.invoke() for testing.
Attributes
| Name | Type | Description |
|---|---|---|
output |
str
|
— |
exit_code |
int
|
— |
result |
Any
|
— |
exception |
Exception | None
|
— |
stderr |
str
|
— |
Functions
_make_command_def
8
CommandDef
▼
Build a CommandDef from a function and decorator kwargs.
_make_command_def
8
CommandDef
▼
def _make_command_def(name: str, func: Callable, *, description: str = '', aliases: tuple[str, ...] = (), tags: tuple[str, ...] = (), hidden: bool = False, examples: tuple[dict[str, Any], ...] = (), confirm: str = '') -> CommandDef
Parameters
| Name | Type | Description |
|---|---|---|
name |
str |
|
func |
Callable |
|
description |
str |
Default:''
|
aliases |
tuple[str, ...] |
Default:()
|
tags |
tuple[str, ...] |
Default:()
|
hidden |
bool |
Default:False
|
examples |
tuple[dict[str, Any], ...] |
Default:()
|
confirm |
str |
Default:''
|
Returns
CommandDef
_is_context_param
1
bool
▼
Check if a parameter is a Context injection point.
_is_context_param
1
bool
▼
def _is_context_param(param: inspect.Parameter) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
param |
inspect.Parameter |
Returns
bool