Skip to content

API Reference parrot.a2a.server

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.a2a.server

View source

A2A Server - Wraps an AI-Parrot Agent as an A2A-compliant HTTP service.

Identity contract (FEAT-260 / TASK-1643)

Copilot Studio's low-code A2A connection delivers the authenticated end-user's identity inside the A2A message metadata. The canonical claim path (in order of precedence) is:

  1. message.metadata["user_id"] — explicitly set by callers or parrot-internal routing.
  2. message.metadata["from"]["email"] — A2A-spec sender object (Copilot sets from dict).
  3. message.metadata["from"]["id"] — fallback when email is absent (OID / UPN from Entra token).
  4. message.metadata["sender"] — alternate flat form.
  5. message.metadata["x-ms-user-email"] — Microsoft-injected header mirror (some Copilot configs).

If none of these are present the request is rejected — A2AServer never falls back to a service identity (OQ#1 is resolved: identity IS present in Copilot A2A messages; absence means an unexpected client).

Class A2AEnabledMixin

Mixin to add A2A server capabilities to an agent class.

Similar to MCPEnabledMixin, this adds A2A methods directly to your agent.

Method A2AEnabledMixin.setup_a2a

Setup A2A server for this agent.

setup_a2a(app: web.Application, url: Optional[str] = None, base_path: str = '/a2a', **kwargs) -> A2AServer

Parameter Type Default Description
app web.Application aiohttp Application to mount routes on
url Optional[str] None Public URL for AgentCard
base_path str '/a2a' URL prefix for A2A endpoints
**kwargs {} Additional A2AServer options

Returns: A2AServer — The A2AServer instance

Method A2AEnabledMixin.get_a2a_server

Get the A2A server instance if setup.

get_a2a_server() -> Optional[A2AServer]

Returns: Optional[A2AServer]

Method A2AEnabledMixin.get_agent_card

Get the AgentCard if A2A is setup.

get_agent_card() -> Optional[AgentCard]

Returns: Optional[AgentCard]

Class A2AServer

Wraps an AI-Parrot Agent (BasicAgent/AbstractBot) as an A2A HTTP service.

This server exposes your existing agent via the A2A protocol, automatically generating the AgentCard from the agent's properties and tools.

Parameter Type Default Description
agent 'AbstractBot' The AI-Parrot agent to expose (BasicAgent, etc.)
base_path str '/a2a' URL prefix for A2A endpoints (default: /a2a)
version str '1.0.0' Version string for the AgentCard
capabilities Optional[AgentCapabilities] None Override auto-detected capabilities
extra_skills Optional[List[AgentSkill]] None Additional skills beyond auto-discovered tools
tags Optional[List[str]] None Tags for the AgentCard
broker Optional[Any] None Optional :class:~parrot.auth.broker.CredentialBroker (FEAT-264). When supplied, per-user credentials are resolved through the broker; missing credentials suspend the task and return a consent link. Takes precedence over credential_resolvers.
identity_mapper Optional[Any] None Optional :class:~parrot.auth.identity.CanonicalIdentityMapper for cross-surface identity normalisation (FEAT-264 / TASK-1671).
credential_resolvers Optional[Dict[str, Any]] None Deprecated. Pass a :class:~parrot.auth.broker.CredentialBroker via broker= instead. If supplied a broker is built from these resolvers for backward compatibility (FEAT-260 / TASK-1644).
suspended_store Optional[Any] None Optional :class:~parrot.human.suspended_store.SuspendedExecutionStore for persisting suspended A2A executions (TASK-1644/1645).
audit_ledger Optional[Any] None Optional :class:~parrot.security.audit_ledger.AuditLedger for recording credentialed tool invocations (TASK-1642/1644).
push_store Optional['PushNotificationStore'] None
output_mode Union[OutputMode, str, None] OutputMode.TEXT :class:~parrot.models.outputs.OutputMode requested from the agent for every A2A turn. Defaults to OutputMode.TEXT (markdown-free plain text) because A2A consumers — notably Microsoft Copilot — render TextPart content literally, so markdown arrives as raw **bold** and pipe tables. Pass OutputMode.DEFAULT/None (or the string "default") to restore the agent's native (typically markdown) output.

Method A2AServer.setup

Register A2A routes on an aiohttp application.

setup(app: web.Application, url: Optional[str] = None, *, register_well_known: bool = True) -> None

Parameter Type Default Description
app web.Application The aiohttp Application
url Optional[str] None Public URL where this agent is accessible (for AgentCard)
register_well_known bool True When True (default), register the fixed GET /.well-known/agent.json discovery route serving this agent's card. Set to False when mounting additional agents on a shared app where the single well-known route has already been claimed by an earlier agent — those agents remain discoverable via a multi-agent directory endpoint. Prevents a redundant, unreachable duplicate route on the shared router.

Method A2AServer.get_agent_card

Generate AgentCard from the wrapped agent's properties.

get_agent_card() -> AgentCard

Returns: AgentCard

Method A2AServer.register_credential_resolver

Register a :class:~parrot.auth.credentials.CredentialResolver for provider.

Tools that declare credential_provider = "<provider>" are gated by the resolver for that provider. Missing credential → suspend + consent link; no service-identity fallback.

register_credential_resolver(provider: str, resolver: Any) -> None

Parameter Type Default Description
provider str Provider identifier, e.g. "jira", "stub".
resolver Any A :class:~parrot.auth.credentials.CredentialResolver implementation for this provider.

Method A2AServer.resume_from_oauth_callback

Resume a suspended A2A task after a successful OAuth callback.

Called by the OAuth callback hook (TASK-1645) once the per-user credential has been persisted to the vault. Loads the :class:~parrot.human.suspended_store.SuspendedExecution, calls agent.resume(session_id, user_input, state), and cleans up the suspended entry.

resume_from_oauth_callback(interaction_id: str, user_input: str = '') -> None

Parameter Type Default Description
interaction_id str The nonce that was embedded in the consent URL (a2a_state query parameter).
user_input str '' Optional user message to inject on resume (defaults to an empty string — agent re-runs the tool automatically).

Method A2AServer.process_message

Process an A2A message by delegating to the wrapped agent.

FEAT-260 / TASK-1643: extracts the per-user identity at the entry point and threads user_id through the processing pipeline.

FEAT-260 / TASK-1644: if the requested tool declares a credential_provider, the credential gate is engaged. A missing per-user credential suspends the task and returns a TEXT consent link; there is NEVER a service-identity fallback for per-user tools.

FEAT-272 / TASK-1714: an optional pre-created task may be supplied (used by the returnImmediately path so the caller and the background processor share the same task object). When omitted a new task is created and registered.

process_message(message: Message, task: Optional[Task] = None) -> Task

Parameter Type Default Description
message Message
task Optional[Task] None

Returns: Task

Alias A2A_ERROR_CODES

Re-exported from parrot.a2a.models.A2A_ERROR_CODES.

Alias A2UICallContext

Re-exported from parrot.outputs.a2ui.runtime.models.A2UICallContext.

Alias A2UIRuntime

Re-exported from parrot.outputs.a2ui.runtime.dispatch.A2UIRuntime.

Alias A2UI_EXTENSION_URI

Re-exported from parrot.a2a.models.A2UI_EXTENSION_URI.

Alias A2UI_MEDIA_TYPE

Re-exported from parrot.a2a.models.A2UI_MEDIA_TYPE.

Alias AbstractBot

Re-exported from parrot.bots.abstract.AbstractBot.

Alias AbstractTool

Re-exported from parrot.tools.abstract.AbstractTool.

Alias AgentCapabilities

Re-exported from parrot.a2a.models.AgentCapabilities.

Alias AgentCard

Re-exported from parrot.a2a.models.AgentCard.

Alias AgentInterface

Re-exported from parrot.a2a.models.AgentInterface.

Alias AgentSkill

Re-exported from parrot.a2a.models.AgentSkill.

Alias Artifact

Re-exported from parrot.a2a.models.Artifact.

Alias ConversationMemorySurfaceStore

Re-exported from parrot.outputs.a2ui.runtime.adapters.ConversationMemorySurfaceStore.

Alias DEFAULT_CATALOG_ID

Re-exported from parrot.outputs.a2ui.catalog.base.DEFAULT_CATALOG_ID.

Alias Message

Re-exported from parrot.a2a.models.Message.

Alias OutputMode

Re-exported from parrot.models.outputs.OutputMode.

Alias Part

Re-exported from parrot.a2a.models.Part.

Alias PushNotificationStore

Re-exported from parrot.a2a.push_notifications.PushNotificationStore.

Alias Role

Re-exported from parrot.a2a.models.Role.

Alias SendMessageConfiguration

Re-exported from parrot.a2a.models.SendMessageConfiguration.

Alias Task

Re-exported from parrot.a2a.models.Task.

Alias TaskPushNotificationConfig

Re-exported from parrot.a2a.models.TaskPushNotificationConfig.

Alias TaskState

Re-exported from parrot.a2a.models.TaskState.

Alias TaskStatus

Re-exported from parrot.a2a.models.TaskStatus.

Alias ToolManagerExecutor

Re-exported from parrot.outputs.a2ui.runtime.adapters.ToolManagerExecutor.

Alias markdown_to_plain

Re-exported from parrot.outputs.formats.text.markdown_to_plain.

Alias parse_task_state

Re-exported from parrot.a2a.models.parse_task_state.

Alias register_a2ui_extension

Re-exported from parrot.a2a.models.register_a2ui_extension.

Alias serialize_role

Re-exported from parrot.a2a.models.serialize_role.

Alias serialize_task_state

Re-exported from parrot.a2a.models.serialize_task_state.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally