Skip to main content

Core Python client library for A2A protocol, MCP, and secure local key management.

Project description

AgentVault Core Library (agentvault)

This directory contains the source code for the core agentvault Python library.

Purpose:

This library provides the foundational components for interacting with the AgentVault ecosystem:

  • Implementation of the client-side Agent-to-Agent (A2A) protocol (AgentVault A2A Profile v0.2 - JSON-RPC/SSE).
  • Support for formatting and embedding Model Context Protocol (MCP) payloads within A2A messages.
  • Secure utilities for managing local API keys and OAuth 2.0 Client Credentials needed for authenticating with remote agents (via Environment Variables, Secure Files, or OS Keyring).
  • Tools for parsing and validating A2A Agent Cards.

Key Modules:

  • client.py: Contains the main AgentVaultClient class for managing A2A connections and task lifecycles.
  • key_manager.py: Implements the KeyManager class for secure local API key and OAuth credential handling.
  • agent_card_utils.py: Provides functions for loading and validating Agent Card JSON.
  • mcp_utils.py: Contains helpers for formatting MCP context data.
  • models/: Pydantic models defining Agent Card structure, A2A protocol messages/events, and internal data structures.
  • exceptions.py: Defines custom exception classes used throughout the library.

Protocol Considerations (AgentVault A2A Profile v0.2)

  • A2A Protocol Version: This version implements the AgentVault A2A Profile v0.2, which uses JSON-RPC 2.0 over HTTPS POST for requests (tasks/send, tasks/get, tasks/cancel, tasks/sendSubscribe) and Server-Sent Events (SSE) for receiving asynchronous updates from the agent via the tasks/sendSubscribe endpoint. Clients should check AgentCard.capabilities.a2aVersion.
  • Task States: Uses the defined TaskState enum (SUBMITTED, WORKING, INPUT_REQUIRED, COMPLETED, FAILED, CANCELED).
  • Authentication: Supports apiKey (via X-Api-Key header), oauth2 (Client Credentials Grant flow using tokenUrl from Agent Card), and none. The AgentVaultClient handles retrieving credentials via the KeyManager based on the authSchemes in the Agent Card.
  • Push Notifications: The client can optionally provide a webhook_url during task initiation if the agent declares supportsPushNotifications in its capabilities. The client is responsible for handling incoming requests to this webhook.
  • MCP Support: Includes basic support for embedding Model Context Protocol data. The mcp_utils.py module provides initial formatting, and the AgentVaultClient embeds the resulting dictionary into message.metadata['mcp_context']. This implementation will be refined to align with the official MCP specification as it stabilizes.

Installation:

This library is intended to be used as a dependency by applications like agentvault-cli or your own custom integrations.

# Install from PyPI (once published)
pip install agentvault

# Install optional OS Keyring support
# pip install agentvault[os_keyring]

# Install locally for development (from the agentvault_library directory)
# Ensure root .venv is created and activated first (see main project README)
pip install -e ".[os_keyring,dev]"

Usage:

See the main project documentation and user guides for detailed usage examples. Basic interaction involves:

  1. Instantiating KeyManager to load necessary API keys or OAuth credentials.
  2. Loading/Fetching an AgentCard model using agent_card_utils.
  3. Instantiating AgentVaultClient.
  4. Calling methods like client.initiate_task (optionally providing webhook_url), client.send_message, client.receive_messages using the loaded AgentCard and KeyManager.

Development:

See the main project README.md for contribution guidelines and development setup. Tests are located in agentvault_library/tests/library/.

Future Enhancements (Ideas):

  • Full alignment with finalized A2A and MCP specifications.
  • Support for additional authentication schemes (e.g., other OAuth flows).
  • Client-side configuration file support (e.g., ~/.config/agentvault/config.toml) for setting defaults like registry URL, timeouts, etc.
  • Helper functions for common agent interaction patterns.
  • WebRTC support for multimodal interaction (Phase 3).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentvault-0.2.0.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentvault-0.2.0-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file agentvault-0.2.0.tar.gz.

File metadata

  • Download URL: agentvault-0.2.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.11.0 Windows/10

File hashes

Hashes for agentvault-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2fcc3b4ea4115d0c27dadeb01920e16f03b26c4e67ab9ad1c6e1550ff9341016
MD5 553edc35be104dea5337922a0bd49126
BLAKE2b-256 7fb30a8f842ab18ec9783cf0120b708890b870e4359b77dad8458fefbd09922a

See more details on using hashes here.

File details

Details for the file agentvault-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: agentvault-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.11.0 Windows/10

File hashes

Hashes for agentvault-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19dd58957ca6613278cc23333ac0055852910eff571b2591c507feda920b7de7
MD5 a616eab1819b58cf844dacc82e12ea98
BLAKE2b-256 cac16b6be9aebac51112dc8acb48d42f3dec38645bd580b5a56b8e61c909c040

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page