AgentVault Server SDK - Basic A2A Server Example¶
This example demonstrates the minimal setup required to create an A2A-compliant agent server using the agentvault-server-sdk and FastAPI.
Components¶
requirements.txt: Defines Python dependencies (fastapi,uvicorn,agentvault-server-sdk).main.py:- Defines a simple
MySimpleAgentclass inheriting fromBaseA2AAgent. - Implements basic logic for the required A2A methods (
handle_task_send,handle_task_get,handle_task_cancel,handle_subscribe_request). - Uses the SDK's
create_a2a_routerto automatically generate the/a2aJSON-RPC endpoint. - Includes necessary FastAPI exception handlers required by the router.
- Sets up a FastAPI application.
- Serves the agent's
agent-card.jsonat/agent-card.json. - Includes a
uvicornrunner block.
- Defines a simple
agent-card.json: A minimal, valid Agent Card describing this example agent.
Setup¶
- Navigate: Open your terminal in this directory (
examples/basic_a2a_server). - Install Dependencies: Create and activate a virtual environment, then install the requirements. This will install the local SDK package.
Note: This assumes the
# Create venv (optional, recommended) # python -m venv .venv # source .venv/bin/activate # On Linux/macOS # .venv\Scripts\activate # On Windows pip install -r requirements.txtagentvault-server-sdkandagentvault_librarydirectories are located correctly relative to this example as specified inrequirements.txt. Adjust the-e ../../...paths if your structure differs.
Running the Server¶
Start the FastAPI server using Uvicorn:
--reload: Enables auto-reloading when code changes (useful for development).--port 8000: Specifies the port to run on (matches the defaulturlinagent-card.json).
You should see Uvicorn startup messages indicating the server is running on http://127.0.0.1:8000.
Testing with AgentVault CLI¶
Once the server is running, you can interact with it using the agentvault-cli:
-
Check Agent Card: Open
http://localhost:8000/agent-card.jsonin your browser or usecurlto verify the card is served correctly. -
Run a Task: Use the
agentvault runcommand, pointing the--agentflag to the card URL.
You should see output similar to this:
SUCCESS: Successfully loaded agent: SDK Basic Echo Agent (examples/simple-agent)
INFO: Agent A2A Endpoint: http://localhost:8000/a2a
INFO: Initiating task with agent...
SUCCESS: Task initiated successfully. Task ID: simple-xxxxxxxx
INFO: Waiting for events... (Press Ctrl+C to request cancellation)
INFO: Task Status: WORKING
┌ Message from Assistant ───────────────────────────────────────────────────┐
│ Echo: Hello SDK Agent! │
└───────────────────────────────────────────────────────────────────────────┘
INFO: Task Status: COMPLETED
INFO: Task reached terminal state.
INFO: --------------------
INFO: Final Task State: COMPLETED
SUCCESS: Task completed.
This confirms the CLI can load the card, initiate a task via the SDK-generated router, stream the status updates and the echo message, and recognize task completion.