Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e49c692
feat: add a2a agent card generation with the CLI
guillaumeblaquiere Nov 18, 2025
291a473
feat: add a2a agent card generation with the CLI
guillaumeblaquiere Nov 18, 2025
6051de6
Merge remote-tracking branch 'origin/add-generate-card-command' into …
guillaumeblaquiere Nov 18, 2025
921a203
Update src/google/adk/cli/cli_generate_agent_card.py
guillaumeblaquiere Nov 18, 2025
0e97442
Update src/google/adk/cli/cli_generate_agent_card.py
guillaumeblaquiere Nov 18, 2025
3141abc
chore: remove useless line
guillaumeblaquiere Nov 18, 2025
6044144
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Nov 19, 2025
3557f02
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Nov 19, 2025
2d49d1d
chore: fix format
guillaumeblaquiere Nov 21, 2025
67a6739
Merge remote-tracking branch 'origin/add-generate-card-command' into …
guillaumeblaquiere Nov 21, 2025
b06f74d
fix: remove useless test
guillaumeblaquiere Nov 23, 2025
d0a7b90
test: add tests on new CLI entry point
guillaumeblaquiere Nov 23, 2025
5fa7105
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Nov 23, 2025
7fe4931
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Nov 25, 2025
10202f1
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Nov 25, 2025
c1de9a7
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Nov 25, 2025
191a5ea
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Nov 26, 2025
d9dcce1
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Nov 26, 2025
b5ef552
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Nov 28, 2025
9c65fdc
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Dec 1, 2025
8e56456
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Dec 3, 2025
803c9cb
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Dec 4, 2025
14042c6
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Dec 12, 2025
294781f
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Dec 15, 2025
ee4d6ce
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Dec 26, 2025
2c57fca
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Jan 5, 2026
1965b30
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Jan 11, 2026
ebdc00c
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Jan 17, 2026
ca03f5f
Merge branch 'main' into add-generate-card-command
guillaumeblaquiere Jan 24, 2026
abc3d80
chore: pyink & isort
guillaumeblaquiere Jan 24, 2026
d42a74d
chore: fix unit test and local link
guillaumeblaquiere Jan 24, 2026
a15267f
chore: fix unit test
guillaumeblaquiere Jan 24, 2026
308734e
chore: fix unit test
guillaumeblaquiere Jan 24, 2026
30ee45d
Update src/google/adk/cli/cli_generate_agent_card.py
guillaumeblaquiere Jan 26, 2026
a0fad41
test: improvement
guillaumeblaquiere Jan 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ known_third_party = ["google.adk"]

[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = "src"
asyncio_default_fixture_loop_scope = "function"
asyncio_mode = "auto"

Expand Down
1 change: 1 addition & 0 deletions src/google/adk/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from ..sessions.session import Session
from ..utils.context_utils import Aclosing
from ..utils.env_utils import is_env_enabled
from .cli_generate_agent_card import generate_agent_card
from .service_registry import load_services_module
from .utils import envs
from .utils.agent_loader import AgentLoader
Expand Down
97 changes: 97 additions & 0 deletions src/google/adk/cli/cli_generate_agent_card.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations

import asyncio
import json
import os

import click

from .utils.agent_loader import AgentLoader


@click.command(name="generate_agent_card")
@click.option(
"--protocol",
default="https",
help="Protocol for the agent URL (default: https)",
)
@click.option(
"--host",
default="127.0.0.1",
help="Host for the agent URL (default: 127.0.0.1)",
)
@click.option(
"--port",
default="8000",
help="Port for the agent URL (default: 8000)",
)
@click.option(
"--create-file",
is_flag=True,
default=False,
help="Create agent.json file in each agent directory",
)
def generate_agent_card(
protocol: str, host: str, port: str, create_file: bool
) -> None:
"""Generates agent cards for all detected agents."""
asyncio.run(_generate_agent_card_async(protocol, host, port, create_file))


async def _generate_agent_card_async(
protocol: str, host: str, port: str, create_file: bool
) -> None:
try:
from ..a2a.utils.agent_card_builder import AgentCardBuilder
except ImportError:
click.secho(
"Error: 'a2a' package is required for this command. "
"Please install it with 'pip install google-adk[a2a]'.",
fg="red",
err=True,
)
raise click.Abort()

cwd = os.getcwd()
loader = AgentLoader(agents_dir=cwd)
agent_names = loader.list_agents()
agent_cards = []

for agent_name in agent_names:
try:
agent = loader.load_agent(agent_name)
# If it's an App, get the root agent
if hasattr(agent, "root_agent"):
agent = agent.root_agent
builder = AgentCardBuilder(
agent=agent,
rpc_url=f"{protocol}://{host}:{port}/{agent_name}",
)
card = await builder.build()
card_dict = card.model_dump(exclude_none=True)
agent_cards.append(card_dict)

if create_file:
agent_dir = os.path.join(cwd, agent_name)
agent_json_path = os.path.join(agent_dir, "agent.json")
with open(agent_json_path, "w", encoding="utf-8") as f:
json.dump(card_dict, f, indent=2)
except Exception as e:
# Log error but continue with other agents
# Using click.echo to print to stderr to not mess up JSON output on stdout
click.echo(f"Error processing agent {agent_name}: {e}", err=True)

click.echo(json.dumps(agent_cards, indent=2))
5 changes: 5 additions & 0 deletions src/google/adk/cli/cli_tools_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
from ..evaluation.constants import MISSING_EVAL_DEPENDENCIES_MESSAGE
from ..features import FeatureName
from ..features import override_feature_enabled
from ..sessions.migration import migration_runner
from .cli import generate_agent_card
from .cli import run_cli
from .fast_api import get_fast_api_app
from .utils import envs
Expand Down Expand Up @@ -2084,3 +2086,6 @@ def cli_deploy_gke(
)
except Exception as e:
click.secho(f"Deploy failed: {e}", fg="red", err=True)


main.add_command(generate_agent_card)
Loading
Loading