Skip to content

API reference

The reference is generated from portr's docstrings and type annotations. It documents each module's public API: the names in its __all__.

portr.core

portr's core: what an outside client is offered, made from the composed commands.

No I/O and no MCP SDK. offered turns lattice's commands (lattice-core's Command, lattice ADR-0041) into the tools and resource templates a client sees, for the toolsets its connection may use: each command offered on the mcp surface and exposed as a tool, a resource or both, in one of those toolsets. core is always among them (lattice RFC-0014). A tool's name is its command's tool name, <package>_<name>, and its annotations follow from the command's tier, reversibility and effects, so a client can tell a read from a change it can't undo. tiers says which tiers each toolset holds, as the consent page shows them.

CORE module-attribute

CORE: Final[Toolset] = 'core'

The toolset every connection may use, whatever else it was given.

SURFACE module-attribute

SURFACE: Final[Surface] = 'mcp'

The surface portr's MCP server offers commands on.

Annotations pydantic-model

Bases: BaseModel

What a tool tells a client of itself, as MCP's tool annotations say it.

Each is a hint, never a guarantee: the enforcer decides every call.

Config:

  • frozen: True
  • populate_by_name: True
  • use_attribute_docstrings: True

Fields:

read_only pydantic-field

read_only: bool

It changes nothing: its command's tier is read.

destructive pydantic-field

destructive: bool

A change it makes can't be undone: its command is irreversible.

idempotent pydantic-field

idempotent: bool

Calling it again with the same arguments changes nothing more: a read.

open_world pydantic-field

open_world: bool

It reaches beyond the deployment: it sends data out or reads untrusted content.

Tool pydantic-model

Bases: BaseModel

A tool a client is offered: one command, as MCP's tools/list names it.

Config:

  • frozen: True
  • use_attribute_docstrings: True

Fields:

name pydantic-field

name: str

The command's tool name, <package>_<name>.

command pydantic-field

command: str

The command's name, <package>.<name>, which every call goes through.

route pydantic-field

route: str | None

portalr's path that a result links to, its placeholders unfilled.

tenant_wide pydantic-field

tenant_wide: bool = False

It acts on the tenant as a whole, so a client names no workspace for it (lattice ADR-0044).

Resource pydantic-model

Bases: BaseModel

A resource template a client is offered: one read, by the URI its command names.

Config:

  • frozen: True
  • use_attribute_docstrings: True

Fields:

command pydantic-field

command: str

The read's command, which every read of a resource goes through.

name pydantic-field

name: str

The command's tool name.

Offered pydantic-model

Bases: BaseModel

What a client is offered: the tools and the resource templates, in the catalogs' order.

Config:

  • frozen: True

Fields:

offered

offered(
    commands: Iterable[Command],
    *,
    toolsets: Collection[Toolset] = (),
) -> Offered

Return the tools and resource templates a connection with these toolsets is offered.

Parameters:

Name Type Description Default
commands Iterable[Command]

Every command of the composed catalogs, as the registry lists them.

required
toolsets Collection[Toolset]

The toolsets the connection may use; core is added to them.

()

Raises:

Type Description
ValueError

If a toolset isn't one of lattice-core's.

tiers

tiers(
    commands: Iterable[Command],
) -> Mapping[Toolset, frozenset[Tier]]

Return the tiers each toolset's commands are of, among those offered on mcp.

The consent page shows them beside each toolset a person may let a client use. A toolset no command offered on mcp is in is left out.