Leveraging the Gemini CLI and the underlying Gemini LLM to build A2A Agent Applications with the Rust programming language. The A2A Rust Agent application was debugged and validated locally.
Rust A2A? Isn’t that a Python Thing?
The bulk of A2A Agents are in Python. The A2A protocol is language independent.
Python has traditionally been the main coding language for ML and AI tools. The goal of this article is to provide a test bed for building, debugging, and deploying cross language applications.
So is this the Real Deal(TM)?
So what is different about this lab compared to all the others out there?
This is one of the first deep dives into a Rust A2A agent leveraging the advanced tooling of Gemini CLI.
What is Rust?
Rust is a high performance, memory safe, compiled language:
Rust provides memory safe operations beyond C/C++ and also can provide exceptional performance gains as it is compiled directly to native binaries.
Rust Setup
Instructions to install Rust are available here:
For a Linux like environment the command looks like this:
curl — proto ‘=https’ — tlsv1.2 -sSf https://sh.rustup.rs | sh
Rust also depends on a working C compiler and OpenSSL setup. For a Debian 12 system — install the basic tools for development:
sudo apt install build-essential
sudo apt install libssl-dev
sudo apt install pkg-config
sudo apt-get install libudev-dev
sudo apt install make
sudo apt install git
Gemini CLI
If not pre-installed you can download the Gemini CLI to interact with the source files and provide real-time assistance:
npm install -g @google/gemini-cli
Testing the Gemini CLI Environment
Once you have all the tools and the correct Node.js version in place- you can test the startup of Gemini CLI. You will need to authenticate with a Key or your Google Account:
▝▜▄ Gemini CLI v0.33.1
▝▜▄
▗▟▀ Logged in with Google /auth
▝▀ Gemini Code Assist Standard /upgrade no sandbox (see /docs) /model Auto (Gemini 3) | 239.8 MB
Node Version Management
Gemini CLI needs a consistent, up to date version of Node. The nvm command can be used to get a standard Node environment:
Where do I start?
The strategy for starting Rust A2A development is a incremental step by step approach.
First, the basic development environment is setup with the required system variables, and a working Gemini CLI configuration.
Then, a Rust A2A agent is built, debugged, and tested locally.
This local agent is validated with test scripts and the A2A inspector.
Setup the Basic Environment
At this point you should have a working Python environment and a working Gemini CLI installation. All of the relevant code examples and documentation is available in GitHub.
The next step is to clone the GitHub repository to your local environment:
cd ~
git clone https://github.com/xbill9/a2a-hello-world
cd a2a-hello-world
cd poly-rust
Then run init.sh from the cloned directory.
The script will attempt to determine your shell environment and set the correct variables:
source init.sh
If your session times out or you need to re-authenticate- you can run the set_env.sh script to reset your environment variables:
source set_env.sh
Variables like PROJECT_ID need to be setup for use in the various build scripts- so the set_env script can be used to reset the environment if you time-out.
Rust A2A Libraries
There are several crates that provide A2A support. This project uses the a2a-rs crate:
crates.io: Rust Package Registry
Here is a sample Cargo.TOML:
[dependencies]
tokio = { version = "^1.37.0", features = ["full"] }
anyhow = "1.0.86"
a2a-rs = { version = "0.1.0", features = ["full"] }
futures = "0.3"
async-trait = "0.1.80"
Minimal System Information Tool Build
The first step is to build the basic tool directly with Rust. This allows the tool to be debugged and tested locally before adding the MCP layer.
First build the tool locally:
xbill@penguin:~/a2a-hello-world/poly-rust$ make
Building the Rust project...
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s
then lint check the code:
xbill@penguin:~/a2a-hello-world/poly-rust$ make lint
Linting code...
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.29s
Checking formatting...
and run local tests:
1 make test
The output confirms that the tests are being picked up and passing:
1 running 2 tests
2 test tests::test_simple_agent_handler_creation ... ok
3 test tests::test_task_creation ... ok
4
5 test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in
0.00s
The last step is to build the production version:
xbill@penguin:~/a2a-hello-world/poly-rust$ make release
Building Release...
Finished `release` profile [optimized] target(s) in 0.21s
xbill@penguin:~/a2a-hello-world/poly-rust$
The A2A server can be started locally:
xbill@penguin:~/a2a-hello-world/poly-rust$ make start
Starting the A2A Rust server on port 8080...
Compiling a2a-server-rust v0.2.0 (/home/xbill/a2a-hello-world/poly-rust)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.93s
Running `target/debug/a2a-server-rust`
🚀 Starting A2A Rust Server
==============================
🌐 Starting HTTP server on 0.0.0.0:8080...
🔗 HTTP server listening on http://0.0.0.0:8080
2026-05-17T20:45:52.176751Z INFO main ThreadId(01) start{server.address=0.0.0.0:8080 server.has_auth=false}: a2a_rs::adapter::transport::http::server: Starting HTTP server
2026-05-17T20:45:52.176972Z INFO main ThreadId(01) start{server.address=0.0.0.0:8080 server.has_auth=false}: a2a_rs::adapter::transport::http::server: HTTP server listening on 0.0.0.0:8080
Check The Local Agent Status
The project has a target to verify that the A2A server started:
xbill@penguin:~/a2a-hello-world/poly-rust$ make status
--- Project Configuration ---
Project ID: comglitn
Service: a2a-server-rust
Region: us-central1
--- Service Status ---
Local (8080): ONLINE (A2A Rust Agent)
A2A Inspector
The A2A Inspector provides a tool to verify A2A operations.
Background information is here:
Announcing the A2A Inspector: A UI tool for A2A protocol development
GitHub Repo is here:
GitHub - a2aproject/a2a-inspector: Validation Tools for A2A Agents
Verify The Local A2A Installation
Start the A2A Inspector and use localhost:8080:
You should see the details of the Agent Card:
{
"capabilities": {
"pushNotifications": false,
"stateTransitionHistory": false,
"streaming": true
},
"defaultInputModes": [
"text"
],
"defaultOutputModes": [
"text"
],
"description": "An A2A agent using the a2a-rs crate",
"documentationUrl": "https://example.org/docs",
"name": "A2A Rust Agent",
"preferredTransport": "JSONRPC",
"protocolVersion": "0.3.0",
"provider": {
"organization": "Example Organization",
"url": "https://example.org"
},
"skills": [
{
"description": "Echoes back the user's message",
"examples": [
"Echo: Hello World"
],
"id": "echo",
"inputModes": [
"text"
],
"name": "Echo Skill",
"outputModes": [
"text"
],
"tags": [
"echo",
"respond"
]
}
],
"url": "http://0.0.0.0:8080",
"version": "1.0.0"
}
Test the Local A2A Connection Locally
This step tests the A2A agent interactions with a test script:
xbill@penguin:~/a2a-hello-world/poly-rust$ make card
Fetching local agent card...
{
"name": "A2A Rust Agent",
"description": "An A2A agent using the a2a-rs crate",
"url": "http://0.0.0.0:8080",
"provider": {
"organization": "Example Organization",
"url": "https://example.org"
},
"version": "1.0.0",
"protocolVersion": "0.3.0",
"preferredTransport": "JSONRPC",
"documentationUrl": "https://example.org/docs",
"capabilities": {
"streaming": true,
"pushNotifications": false,
"stateTransitionHistory": false
},
"defaultInputModes": [
"text"
],
"defaultOutputModes": [
"text"
],
"skills": [
{
"id": "echo",
"name": "Echo Skill",
"description": "Echoes back the user's message",
"tags": [
"echo",
"respond"
],
"examples": [
"Echo: Hello World"
],
"inputModes": [
"text"
],
"outputModes": [
"text"
]
}
]
}
xbill@penguin:~/a2a-hello-world/poly-rust$
Run A Local A2A Skill
Next- a local skill is activated from a local test script.
So What Just Happened?
The Rust A2A agent was started locally. This agent provided a standard A2A agent card. Then, test scripts performed a A2A skills call against the locally running Rust A2A server. Because the A2A server in Rust provides standard tools- the A2A inspector could connect. The actual implementation language of the A2A code does not matter - as long as standard services are exposed.
Code Review with Gemini CLI
Gemini CLI was used to review the project:
✦ Here is a comprehensive code review of the a2a-server-rust project.
Overall, this is a well-structured, minimal example of an Agent-to-Agent (A2A) server. It makes
excellent use of Rust's type system, the tokio async runtime, and modern containerization
practices.
1. Architecture & Design
* A2A Framework Usage: The integration with a2a-rs is clean and idiomatic. Initializing the server
with HttpServer::new and using DefaultRequestProcessor sets up the standard A2A endpoints
(/agentcard, /tasks, /notifications) correctly.
* Handler Pattern: SimpleAgentHandler acts as a facade, intelligently delegating core capabilities
(message handling, task management, streaming) to InMemoryTaskStorage. This is an excellent
pattern for prototyping and testing, as it keeps the boilerplate low.
* Agent Metadata: The SimpleAgentInfo configuration in main.rs is thorough, properly defining the
agent's identity, capabilities, and the built-in echo skill.
2. Rust Best Practices & Code Quality
* Async Execution: Proper use of #[tokio::main] and #[async_trait] throughout the project.
* Observability: Calling observability::init_tracing() at the start of main is a great practice,
ensuring that logs and traces are captured immediately.
* Release Profile: The Cargo.toml includes an excellent [profile.release] section (lto = true,
strip = true, codegen-units = 1, panic = "abort"). This significantly reduces the size of the
final compiled binary, which is critical for cold-start times in serverless environments like
Cloud Run.
* Error Handling: The trait implementations in SimpleAgentHandler correctly map internal state to
A2AError, ensuring that the HTTP layer can respond with proper status codes.
3. Deployment & DevOps
* Multi-Stage Dockerfile: The Dockerfile is highly optimized.
* It caches dependencies effectively by copying Cargo.toml and Cargo.lock before the source
code.
* Using gcr.io/distroless/cc-debian12 for the final runtime image is a security best practice.
It removes unnecessary OS utilities (reducing the attack surface) and keeps the image
incredibly small.
* Cloud Build & Makefile: The Makefile is comprehensive, covering the entire lifecycle from local
formatting/linting to remote validation. cloudbuild.yaml correctly deploys the container to
Cloud Run.
4. Testing
* Cross-Language Validation: Having Python integration tests (echo_test.py, test_a2a_client.py) to
validate a Rust server is a strong approach for ensuring protocol compliance across different
language ecosystems.
* Unit Tests: The basic async unit tests in main.rs for SimpleAgentHandler provide a good
foundation for ensuring the storage delegation works as expected.
Summary
A complete A2A server was built using Rust. Basic validation was done with the A2A inspector. Next, test scripts was built that directly called the Rust A2A server. Finally, Gemini CLI was used for a complete project code review.
Future enhancements include using Google Cloud Run to deploy the various system components.



Top comments (0)