nat.plugins.a2a.cli.commands#
Attributes#
Functions#
A2A-related commands. |
|
A2A client commands. |
|
|
Discover A2A agent and fetch AgentCard. |
|
Format AgentCard for display. |
|
Discover A2A agent and display AgentCard information. |
|
Create bearer token auth configuration for CLI usage. |
|
Load auth provider from auth-only config file. |
|
Create auth provider from inline JSON config. |
|
Load A2A client as a function group with optional authentication. |
|
Format agent info for simple text display. |
|
Format agent skills for simple text display. |
|
Format agent call response for simple text display. |
|
Get agent metadata including name, version, provider, and capabilities. |
|
Get detailed list of agent skills and capabilities. |
|
Call an A2A agent with a message and get a response. |
Module Contents#
- logger#
- a2a_command()#
A2A-related commands.
- a2a_client_command()#
A2A client commands.
- async discover_agent(url: str, timeout: int = 30)#
Discover A2A agent and fetch AgentCard.
- Args:
url: A2A agent URL timeout: Timeout in seconds
- Returns:
AgentCard object or None if failed
- format_agent_card_display(agent_card, verbose: bool = False)#
Format AgentCard for display.
- Args:
agent_card: AgentCard object verbose: Show full details
- a2a_client_discover( )#
Discover A2A agent and display AgentCard information.
Connects to an A2A agent at the specified URL and fetches its AgentCard, which contains information about the agent’s capabilities, skills, and configuration requirements.
- Args:
url: A2A agent URL (e.g., http://localhost:9999) json_output: Output as JSON instead of formatted display verbose: Show full details including all skill information save: Save AgentCard JSON to specified file timeout: Timeout in seconds for agent connection
- Examples:
nat a2a client discover –url http://localhost:9999 nat a2a client discover –url http://localhost:9999 –json-output nat a2a client discover –url http://localhost:9999 –verbose nat a2a client discover –url http://localhost:9999 –save agent-card.json
- async _create_bearer_token_auth( )#
Create bearer token auth configuration for CLI usage.
- async _load_auth_from_config( )#
Load auth provider from auth-only config file.
Parses only the authentication section from YAML file. No other workflow sections are required.
- async _create_auth_from_json(builder, auth_json: str)#
Create auth provider from inline JSON config.
- async get_a2a_function_group( )#
Load A2A client as a function group with optional authentication.
- Args:
url: A2A agent URL timeout: Timeout in seconds auth_provider_name: Optional auth provider name (from builder) user_id: Optional user ID for authentication
- Returns:
Tuple of (builder, group, functions dict) or (None, None, None) if failed
- format_call_response_display( )#
Format agent call response for simple text display.
- a2a_client_get_info( )#
Get agent metadata including name, version, provider, and capabilities.
This command connects to an A2A agent and retrieves its metadata.
- Args:
url: A2A agent URL (e.g., http://localhost:9999) json_output: Output as JSON instead of formatted display timeout: Timeout in seconds for agent connection user_id: User ID for authentication (optional)
- Examples:
nat a2a client get_info –url http://localhost:9999 nat a2a client get_info –url http://localhost:9999 –json-output nat a2a client get_info –url http://localhost:9999 –user-id alice
- a2a_client_get_skills( )#
Get detailed list of agent skills and capabilities.
This command connects to an A2A agent and retrieves all available skills with their descriptions, examples, and tags.
- Args:
url: A2A agent URL (e.g., http://localhost:9999) json_output: Output as JSON instead of formatted display timeout: Timeout in seconds for agent connection user_id: User ID for authentication (optional)
- Examples:
nat a2a client get_skills –url http://localhost:9999 nat a2a client get_skills –url http://localhost:9999 –json-output nat a2a client get_skills –url http://localhost:9999 –user-id alice
- a2a_client_call(
- url: str,
- message: str,
- task_id: str | None,
- context_id: str | None,
- json_output: bool,
- timeout: int,
- bearer_token: str | None,
- bearer_token_env: str | None,
- auth_config: str | None,
- auth_provider: str | None,
- auth_json: str | None,
- user_id: str | None,
Call an A2A agent with a message and get a response.
This command connects to an A2A agent, sends a message, and displays the response. Use this for one-off queries or testing. For complex workflows with multiple agents and tools, create a NAT workflow instead.
Authentication is optional. If the agent requires authentication, use one of: - –bearer-token or –bearer-token-env for simple token auth - –auth-config and –auth-provider for config-based auth - –auth-json for inline JSON auth configuration
- Args:
url: A2A agent URL (e.g., http://localhost:9999) message: Message to send to the agent task_id: Optional task ID for continuing a conversation context_id: Optional context ID for maintaining context json_output: Output as JSON instead of formatted display timeout: Timeout in seconds for agent connection bearer_token: Bearer token for authentication bearer_token_env: Environment variable containing bearer token auth_config: Path to auth-only config file (YAML) auth_provider: Auth provider name from config auth_json: Inline auth provider config as JSON user_id: User ID for authentication
- Examples:
# Public agent (no auth) nat a2a client call –url http://localhost:9999 –message “Hello”
# Bearer token auth nat a2a client call –url http://localhost:9999 –message “Hello” –bearer-token “sk-abc123”
# Config-based auth nat a2a client call –url http://localhost:9999 –message “Hello” –auth-config auth.yml –auth-provider my_oauth –user-id alice
# Inline JSON auth nat a2a client call –url http://localhost:9999 –message “Hello” –auth-json ‘{“_type”: “api_key”, “raw_key”: “sk-abc123”, “auth_scheme”: “Bearer”}’