Skip to content

cayu.mcp.base

Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.

from cayu.mcp import McpClient

Factory for initialized MCP sessions.

Bases: ABC.

async McpClient.connect(server: McpServerSpec) -> McpSession

Connect to one MCP server.

Release source · Runtime guarantees · Capability guides

from cayu.mcp import McpInitializeResult

Validated server metadata established for an MCP connection.

Bases: BaseModel.

Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.

Name Type Default
protocol_version str required
server_name str | None None
server_version str | None None
instructions str | None None
capabilities dict[str, Any] Field(default_factory=dict)
McpInitializeResult.validate_protocol_version(value: str, info) -> str
McpInitializeResult.validate_optional_strings(value: str | None, info) -> str | None
McpInitializeResult.copy_capabilities(value)

Release source · Runtime guarantees · Capability guides

from cayu.mcp import McpResourceDefinition

Resource definition advertised by an MCP server.

Bases: BaseModel.

Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.

Name Type Default
uri str required
name str | None None
description str | None None
mime_type str | None None
metadata dict[str, Any] Field(default_factory=dict)
McpResourceDefinition.validate_uri(value: str, info) -> str
McpResourceDefinition.validate_optional_strings(value: str | None, info) -> str | None
McpResourceDefinition.copy_metadata(value)

Release source · Runtime guarantees · Capability guides

from cayu.mcp import McpResourceResult

Result returned by an MCP resources/read request.

Bases: BaseModel.

Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.

Name Type Default
contents list[dict[str, Any]] Field(default_factory=list)
McpResourceResult.copy_contents(value)

Release source · Runtime guarantees · Capability guides

from cayu.mcp import McpServerSpec

Configuration for an external MCP server.

Bases: BaseModel.

Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.

Name Type Default
name str required
connection_id str | None None
command list[str] | None None
url str | None None
env dict[str, str] Field(default_factory=dict)
secret_env dict[str, SecretRef] Field(default_factory=dict)
headers dict[str, str] Field(default_factory=dict)
secret_headers dict[str, SecretRef] Field(default_factory=dict)
metadata dict[str, Any] Field(default_factory=dict)
McpServerSpec.validate_secret_config_keys(value, info)
McpServerSpec.copy_secret_config_data(value)
McpServerSpec.copy_json_config_data(value, info)
McpServerSpec.validate_nonblank_name(value: str, info) -> str

validate_optional_nonblank_strings (method)

Section titled “validate_optional_nonblank_strings (method)”
McpServerSpec.validate_optional_nonblank_strings(value: str | None, info) -> str | None
McpServerSpec.validate_command_items(value: list[str] | None) -> list[str] | None
McpServerSpec.validate_transport() -> McpServerSpec

validate_secret_config_collisions (method)

Section titled “validate_secret_config_collisions (method)”
McpServerSpec.validate_secret_config_collisions() -> McpServerSpec

Release source · Runtime guarantees · Capability guides

from cayu.mcp import McpSession

Established connection to one MCP server.

Bases: ABC.

McpSession.secret_redactor() -> SecretRedactor

Redactor for secrets injected into this session (empty if none).

A hostile or buggy MCP server can echo injected secrets back through tool content, structured output, stderr, or protocol errors, so the toolset scrubs results with this before they reach model-visible context.

McpSession.initialize_result() -> McpInitializeResult

Validated metadata established for this MCP connection.

async McpSession.list_tools() -> tuple[McpToolDefinition, ...]

Return tools advertised by the server.

async McpSession.call_tool(name: str, arguments: dict[str, Any]) -> McpToolResult

Call one server tool.

async McpSession.list_resources() -> tuple[McpResourceDefinition, ...]

Return resources advertised by the server.

async McpSession.read_resource(uri: str) -> McpResourceResult

Read one server resource.

async McpSession.close() -> None

Close the server connection.

Release source · Runtime guarantees · Capability guides

from cayu.mcp import McpToolDefinition

Tool definition advertised by an MCP server.

Bases: BaseModel.

Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.

Name Type Default
name str required
description str ''
input_schema dict[str, Any] Field(default_factory=dict)
annotations dict[str, Any] Field(default_factory=dict)
McpToolDefinition.validate_name(value: str, info) -> str
McpToolDefinition.validate_description(value: str) -> str
McpToolDefinition.copy_json_data(value, info)

Release source · Runtime guarantees · Capability guides

from cayu.mcp import McpToolResult

Result returned by an MCP tools/call request.

Bases: BaseModel.

Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.

Name Type Default
content list[dict[str, Any]] Field(default_factory=list)
structured_content Any None
is_error StrictBool False
McpToolResult.copy_json_data(value, info)

Release source · Runtime guarantees · Capability guides