Skip to content

Agent Runtime, MCP, A2A & Workflows

vertebra.agent provides the agent execution runtime, Model Context Protocol (MCP) and Agent-to-Agent (A2A) services, identity verification, protocol bridges, task planning trees, and DAG workflows. See OKF v0.2 & Knowledge Catalog for bundle serialization and Dataplex sync, and Agent Protocols Usage Guide for walkthroughs.

Section Responsibility
Agent Plugin & Harness Runtime Mount MCP, A2A, and chat routes on App, run bounded LLM tool-calling loops, and gate destructive tools behind single-use human approval.
Model Context Protocol Negotiate current and legacy MCP protocol versions, stream SSE notifications, serve SKILL.md and UI resources, verify IAP JWTs, and track async tool tasks.
Agent-to-Agent Protocol & Bridges Serve JWS-signed /.well-known/agent-card.json descriptors, stream A2A task updates, and bridge MCP tools with A2A agents.
PlanTree, Workflows & Session Stores Break goals into dependency trees, run parallel DAG waves with checkpointing, and store multi-turn conversation state.

Agent Plugin & Harness Runtime

AgentPlugin mounts MCP, A2A, and SSE chat routes onto App. AgentRuntime coordinates multi-turn LLM generation, approval checks, and tool invocation.

AgentPluginConfig

Bases: Struct

Configuration options for mounting the agentic harness.

Attributes:

Name Type Description
mcpMCPConfig | None

Model Context Protocol server configuration, or None to disable MCP endpoints.

a2aA2AConfig | None

Agent-to-Agent 1.0 protocol configuration, or None to disable A2A endpoints.

runtimeAgentRuntime | None

Pre-configured AgentRuntime instance executing multi-turn agent requests.

agent_base_pathstr

HTTP route prefix for chat, turn streaming, confirmation, and session endpoints.

observabilityAgentTelemetryRecorder | None

OpenTelemetry gen_ai.* span and audit recorder attached to protocol services.

queue_serviceAny

Optional background QueueService for durable async turn execution.

session_storeAny

Optional AgentSessionStore backend persisting multi-turn conversation history.

skillsMCPSkillsConfig | SkillCatalog | None

Optional MCP skills configuration or pre-built SkillCatalog.

AgentPlugin

Agentic harness plugin mounting protocols on native App and Litestar.

mount_native

mount_native(app)

Mount agent routes and discovery endpoints on native vertebra App.

on_app_init

on_app_init(app_config)

Litestar InitPluginProtocol callback auto-discovering handlers and mounting routes.

AgentRuntime

Multi-turn execution runtime with parallel tools, confirmation gates, and retry backoff.

run_turn

run_turn(request, *, context=None)

Run a conversation turn to completion or until a confirmation is required.

stream_turn

stream_turn(request, *, context=None)

Stream real-time frames during turn execution.

ConfirmationGate

Human-in-the-loop gate controlling execution of sensitive mutating operations.

request_confirmation
request_confirmation(
    tool_name, call_id, arguments, *, owner_id=None, reason=""
)

Issue a new confirmation ticket for a pending mutating tool invocation.

approve
approve(token, *, owner_id=None, target=None, payload=None)

Approve a pending ticket or register a single-use target/payload approval ticket.

Returns:

Type Description
bool

True when approval succeeds; False on unknown, expired, non-pending, or wrong-owner tokens.

reject
reject(token, *, owner_id=None, reason='')

Reject a pending, unexpired confirmation ticket.

Returns:

Type Description
bool

True when the ticket is pending, unexpired, and owner_id matches; False otherwise.

Tool

Method and function descriptor encapsulating callable logic and a frozen ToolSpec.

invoke
invoke(arguments, context=None)

Authorize and invoke the tool with validated arguments and context injection.

Provider Tools

build_tools adapts a vertebra.typing.ToolProvider into validated Tool objects. Adapters own their operations and policies, and constructing tools opens no database connection. Operations use named parameters; positional-only and variadic signatures are rejected.

from vertebra.agent import ConfirmationGate, build_tools
from vertebra.db.adapters.bigquery import BigQueryConfig, BigQueryToolProvider

gate = ConfirmationGate()
tools = build_tools(
    BigQueryToolProvider(
        config=BigQueryConfig(project_id="my-project"),
        maximum_bytes_billed=1_000_000,
    ),
    confirmation_gate=gate,
)
rows = await tools["bigquery_query"].invoke(
    {"sql": "SELECT @id AS id", "params": {"id": 1}}
)

Spanner's adapter exports SpannerToolProvider with optional read-only snapshot staleness. Each provider accepts a driver, config, or registry alias resolved at invocation. Mutations and ambiguous SQL, including WITH, require approval; retry with the approved confirmation_token input. Approval tickets bind to the operation, validated arguments (including defaults), and caller identity. BigQuery enforces the lowest of the provider, per-call, and configured billing caps even when the dry-run guard is disabled.

build_tools

build_tools(provider, *, confirmation_gate=None, exposure=None)

Adapt named provider operations into validated tools sharing one confirmation gate.

Raises:

Type Description
ValueError

If an operation declares reserved, positional-only, or variadic parameters.

Model Context Protocol

MCPCore

Transport-agnostic MCP HTTP and JSON-RPC protocol engine.

Attributes:

Name Type Description
stream_brokerSseStreamBroker
Default: resolved_broker
task_storeMCPTaskStore
Default: resolved_task_store
skill_catalogSkillCatalog | None
Default: SkillCatalog.coerce(skill_catalog, telemetry=self.telemetry)
session_storeMCPSessionStore | CacheMCPSessionStore
Default: resolved_session_store

MCPConfig

Bases: FrozenBaseStruct

Server configuration for Model Context Protocol handlers.

Attributes:

Name Type Description
server_namestr

Server identifier returned in server/discover and /.well-known/mcp.json responses.

server_versionstr

Semantic version string advertised during MCP capability discovery.

instructionsstr

System-level usage instructions provided to connecting MCP clients.

allowed_originstuple[str, ...]

Allowed HTTP Origin header patterns for Streamable HTTP requests; empty enforces same-origin.

max_blob_bytesint

Maximum decoded payload size in bytes for binary resource and tool blobs.

tools_enabledbool

Advertise and serve tools/list and tools/call capabilities.

resources_enabledbool

Advertise and serve resources/list, resources/read, and resources/templates/list.

prompts_enabledbool

Advertise and serve prompts/list and prompts/get capabilities.

skills_enabledbool

Expose progressive skill:// resource catalogs and discovery tools.

tasks_enabledbool

Enable io.modelcontextprotocol/tasks durable async task execution.

pathstr

HTTP path where the Streamable HTTP MCP endpoint is mounted.

expose_well_knownbool

Whether to expose the well-known discovery manifest route.

well_known_pathstr

HTTP path for the well-known MCP discovery document.

webmcpAny | None

Optional WebMCPConfig controlling browser WebMCP manifest generation.

trust_proxy_identitybool

Trust proxy identity only with an explicitly configured identity source.

identity_sourceIdentitySource | None

Trusted IAP, mTLS, or application identity source from agent.core.identity.

session_ttl_secondsfloat

Time-to-live in seconds for legacy stateful MCP sessions.

max_sessionsint

Maximum number of concurrent legacy MCP sessions retained in memory.

loggingbool

Advertise and serve MCP logging capabilities and logging/setLevel.

default_log_levelMCPLogLevel

Default minimum log severity assigned to newly created MCP sessions.

enable_get_ssebool

Allow legacy GET /mcp Server-Sent Events notification streams.

sse_heartbeat_secondsfloat

Interval in seconds between SSE keepalive comments on idle streams.

max_streams_per_ownerint

Maximum concurrent SSE streams allowed per authenticated owner key.

resource_subscriptionsbool

Advertise and serve resources/subscribe and resources/unsubscribe.

max_subscriptions_per_sessionint

Maximum number of active resource URI subscriptions permitted per session.

subscription_authorizerCallable[..., Any] | None

Optional sync or async callable authorizing resource subscription requests.

ui_mime_typestuple[str, ...]

Allowed MIME types for SEP-1865 ui:// app resources; empty disables the UI extension.

hide_app_only_toolsbool

Hide app-only tools from tools/list when caller capabilities lack the UI extension.

cache_urlstr | None

Optional vertebra.cache backend URL for distributed sessions, tasks, and SSE replay.

session_storeAny | None

Optional pre-configured MCP session store overriding cache_url and in-memory defaults.

task_storeAny | None

Optional pre-configured MCP task store overriding cache_url and in-memory defaults.

stream_brokerAny | None

Optional pre-configured SSE stream broker overriding cache_url and in-memory defaults.

IapIdentitySource

Verify Google Cloud Identity-Aware Proxy ES256 JWT assertion headers.

Attributes:

Name Type Description
jwksdict[str, Any] | None
Default: dict(jwks) if jwks is not None else None

ToolRegistry

Central catalog of tools (ToolSpec + Tool), resources, resource templates, and prompts.

register_tool

register_tool(tool_or_fn)

Register a Tool descriptor (or callable) and cache its ToolSpec digest.

register_provider

register_provider(provider, *, confirmation_gate=None)

Adapt and register all operations from a neutral ToolProvider.

list_tools

list_tools(*, exposure=None)

Return registered Tool descriptors sorted by name, optionally filtered by exposure.

list_specs

list_specs(*, exposure=None)

Return registered ToolSpec items sorted by name, optionally filtered by exposure.

register_controller

register_controller(controller)

Discover and register all tools, prompts, and resources from a controller.

MCPSkillsConfig

Bases: Struct

Configuration for MCP progressive skill discovery.

Attributes:

Name Type Description
pathstuple[str | Path, ...]

Filesystem directories scanned for <skill>/SKILL.md packages.

sourcestuple[Any, ...]

Additional SkillSource providers supplying programmatic skills.

directory_readbool

Allow clients to list relative file paths inside skill://<name>/ directories.

expose_as_promptsbool

Project discovered skills into prompts/list and prompts/get when true.

list_changedbool

Advertise and emit notifications/skills/list_changed when the catalog mutates.

max_files_per_skillint

Maximum number of files indexed per skill directory.

max_bytes_per_skillint

Maximum cumulative byte budget (2 MiB default) allowed per skill package.

MCPTaskConfig

Bases: Struct

Configuration options for MCP tasks execution.

Attributes:

Name Type Description
enabledbool

Enable durable tasks/get, tasks/list, tasks/update, and tasks/cancel methods.

default_ttl_msint

Default retention TTL in milliseconds (5 minutes) for newly created tasks.

max_ttl_msint

Maximum allowed task TTL in milliseconds (1 hour).

poll_interval_msint

Default polling interval hint in milliseconds returned to MCP clients.

Agent-to-Agent Protocol & Bridges

AgentCard

Bases: FrozenCamelizedStruct

A2A 1.0 Agent Card discoverable at /.well-known/agent-card.json.

Attributes:

Name Type Description
namestr

Human-readable agent name.

descriptionstr

Summary of the agent's purpose and domain expertise.

versionstr

Version string of the published agent card.

supported_interfacestuple[AgentInterface, ...]

Transport endpoints (JSONRPC, GRPC, HTTP+JSON) exposed by the agent.

capabilitiesAgentCapabilities

Feature flags indicating streaming, push notification, and extended card support.

default_input_modestuple[str, ...]

Default input part modalities accepted across skills.

default_output_modestuple[str, ...]

Default output part modalities emitted across skills.

skillstuple[AgentSkill, ...]

Skills advertised by this agent for peer discovery and tool bridging.

providerAgentProvider | None

Organization metadata for the agent operator.

signaturestuple[AgentCardSignature, ...]

Detached RFC 7515 JWS signatures proving card integrity.

A2AConfig

Bases: Struct

Configuration options for the A2A 1.0 service.

Attributes:

Name Type Description
pathstr

HTTP route path where the A2A JSON-RPC endpoint is mounted.

base_urlstr | None

Optional public origin (https://agents.example.com) for AgentCard interfaces; derived dynamically from request headers when None.

agent_card_pathstr

Well-known discovery route serving the public AgentCard JSON.

agent_cardAgentCard | None

Public AgentCard advertised at agent_card_path.

card_secretstr | None

Optional signing secret or key material used to verify/sign the AgentCard.

extended_cardAgentCard | None

Authenticated extended AgentCard returned by agent/authenticatedExtendedCard.

enable_streamingbool

Allow message/stream and tasks/resubscribe SSE event streams.

enable_push_notificationsbool

Enable webhook registration and delivery via PushNotificationDispatcher.

allow_insecure_webhooksbool

Allow plain HTTP or loopback/private-network webhook URLs (for local testing only).

max_tasksint

Maximum number of tasks retained in A2ATaskStore before LRU eviction.

task_ttl_secondsint

Time-to-live in seconds (24 hours default) for retained task records.

cache_urlstr | None

Optional vertebra.cache backend URL for distributed A2A tasks, push configs, and SSE replay.

task_storeAny | None

Optional pre-configured A2A task store overriding cache_url and in-memory defaults.

push_dispatcherAny | None

Optional pre-configured push notification dispatcher overriding cache_url and defaults.

stream_brokerAny | None

Optional pre-configured SSE stream broker overriding cache_url and in-memory defaults.

A2AService

Coordinates JSON-RPC dispatch, SSE event streaming, and durable execution for A2A 1.0.

handle_payload

handle_payload(body, context=None)

Process incoming raw JSON-RPC body and return response bytes.

execute_task_flow

execute_task_flow(message, context_id, task_id, owner_id)

Run task execution lifecycle, transitioning states and publishing SSE events.

handle_message_send

handle_message_send(params, context=None)

A2A 1.0 message/send RPC handler.

handle_message_stream

handle_message_stream(params, context=None)

A2A 1.0 message/stream RPC handler for initial task creation.

stream_message

stream_message(params, context=None)

Stream SSE frames for a message execution until completion.

MCPToolBridge

Translates A2A 1.0 skills into callable MCP Tool instances.

from_a2a_service
from_a2a_service(service, *, prefix=None)

Convert skills of an in-process A2AService into callable MCP Tool instances.

from_agent_card
from_agent_card(card, transport, *, prefix=None)

Synthesize callable MCP Tool instances for all skills declared on an AgentCard.

A2AAgentBridge

Projects an MCP core engine and registry into an A2A 1.0 compliant agent service.

from_mcp_service
from_mcp_service(
    mcp_service, *, base_url=None, path="/a2a", name=None, description=""
)

Create an A2AService wrapping an MCPCore instance.

PlanTree, Workflows & Session Stores

PlanTree

Hierarchical task planner managing parent-child goals and checkpoint snapshots.

add_node
add_node(node)

Register a PlanNode in the PlanTree, linking to its parent if present.

add_step
add_step(
    id,
    title=None,
    *,
    description="",
    parent_id=None,
    depends_on=(),
    assigned_agent=None,
    metadata=None,
)

Create and register a PlanNode, attaching to the root node when present.

ready_nodes
ready_nodes()

Return all pending or ready leaf nodes whose dependencies are all completed.

to_workflow
to_workflow(agents=None)

Compile this PlanTree into an executable Workflow DAG.

Workflow

Directed acyclic graph (DAG) workflow specification.

add
add(step)

Register a pre-constructed WorkflowStep.

add_step
add_step(
    name,
    fn,
    *,
    depends_on=(),
    description="",
    timeout_seconds=None,
    condition=None,
)

Add a step callable to the workflow.

topological_waves
topological_waves()

Compute execution waves via Kahn's topological sort algorithm.

WorkflowEngine

Executes Workflow DAGs with parallel waves, telemetry, and live HLC broadcasting.

MemorySessionStore

Process-local monotonic-TTL LRU OrderedDict session store with per-session locking.

load

load(owner, session_id)

Load and deserialize conversation history for owner and session.

save

save(owner, session_id, messages)

Serialize and save conversation history with monotonic TTL.

delete

delete(owner, session_id)

Remove a session from memory.

SQLSpecSessionStore

Session store persisting conversation history via parameterized SQL statements or ADK store.

load
load(owner, session_id)

Load session messages from the database table or ADK store.

save
save(owner, session_id, messages)

Upsert conversation history in the database table or ADK store.

delete
delete(owner, session_id)

Delete session row from the database table or ADK store.

AlchemySessionStore

Session store persisting session rows via an SQLAlchemy async session factory.

load
load(owner, session_id)

Load conversation messages using SQLAlchemy async session.

save
save(owner, session_id, messages)

Upsert conversation messages using SQLAlchemy async session.

delete
delete(owner, session_id)

Delete conversation row using SQLAlchemy async session.

ObjectStoreSessionStore

Session store persisting session objects in S3, GCS, or Vertebra storage.

load
load(owner, session_id)

Load session object from bucket store.

save
save(owner, session_id, messages)

Write session object to bucket store.

delete
delete(owner, session_id)

Delete session object from bucket store.