Skip to content

Conversation

dandye
Copy link
Collaborator

@dandye dandye commented Jul 3, 2025

Summary

This PR introduces a major restructuring of the ADK (Agent Development Kit) agent architecture to improve organization, maintainability, and user experience:

  • Directory reorganization: Logical groupings with agents/, scripts/, ui/, and libs/ directories
  • Comprehensive documentation: New Google ADK documentation section with quickstart guides for Cloud Run and AgentSpace deployment
  • Automation tools: Makefile with deployment, testing, and management commands
  • Integration scripts: OAuth, AgentSpace, and Cloud Run deployment automation
  • Enhanced structure: Better separation of concerns and cleaner codebase organization

Key Changes

Directory Structure

  • agents/ - Contains agent implementations (google_mcp_security_agent, sample_agents)
  • scripts/ - Deployment and management scripts
  • ui/ - Web UI components
  • libs/adk_utils/ - Shared utility functions

Documentation

  • Added comprehensive ADK documentation with quickstart guides
  • Cloud Run and AgentSpace deployment paths
  • Local setup instructions
  • Makefile reference guide
  • Advanced topics and configuration options

Automation

  • Complete Makefile with 30+ commands for deployment and management
  • OAuth configuration and AgentSpace integration scripts
  • Environment variable management tools
  • Agent testing and monitoring utilities

Test Plan

  • Verify directory structure is correct
  • Test local agent setup with new structure
  • Validate Cloud Run deployment path
  • Test AgentSpace integration workflow
  • Verify documentation accuracy
  • Test Makefile commands
  • Ensure backward compatibility where needed

This restructuring provides a solid foundation for the ADK agent ecosystem while maintaining all existing functionality.

❯ make
Available targets:

Environment Management:
  env-setup       - Create .env from .env.sample
  env-check       - Validate required environment variables
  config-show     - Display current configuration (masks secrets)
  env-update      - Update environment variable

OAuth Management:
  oauth-client    - Guide for creating OAuth client
  oauth-uri       - Generate OAuth authorization URI
  oauth-link      - Link OAuth to AgentSpace
  oauth-verify    - Verify OAuth configuration
  oauth-setup     - Complete OAuth setup workflow

Agent Management:
  agents-list     - List all deployed Agent Engine instances
  agents-delete   - Delete Agent Engine instance by index
  adk-deploy      - Deploy agent to Agent Engine
  adk-redeploy    - Redeploy agent to existing Agent Engine resource
  test-agent      - Test deployed agent with a message

AgentSpace Integration:
  agentspace-register - Register agent with AgentSpace
  agentspace-update   - Update existing AgentSpace registration
  agentspace-verify   - Verify AgentSpace integration
  agentspace-delete   - Remove agent from AgentSpace
  agentspace-url      - Get AgentSpace UI URL

Cloud Run Deployment:
  cloudrun-deploy - Deploy agent to Cloud Run
  cloudrun-run    - Run Cloud Run service locally
  cloudrun-test   - Test deployed Cloud Run service
  cloudrun-logs   - View Cloud Run service logs
  cloudrun-url    - Get Cloud Run service URL
  cloudrun-delete - Delete Cloud Run service

Development Tools:
  docs            - Build documentation
  gcloud-proxy    - Proxy to Cloud Run service locally

Multi-Agent System:
  multi-agent-setup - Set up multi-agent environment
  multi-agent-run - Run the manager agent
  multi-agent-web - Run the multi-agent web UI

Agent Templates:
  cookiecutter-setup - Set up cookiecutter agent builder
  cookiecutter-run - Run the cookiecutter web builder
  cookiecutter-new-agent - Create new agent from template

Environment variables from .env will be automatically loaded.

Examples:
  make env-check
  make config-show
  make env-update KEY=GOOGLE_CLOUD_PROJECT VALUE=my-project
  make oauth-setup
  make agents-list
  make adk-deploy AGENT_DIR=. DISPLAY_NAME='Security Agent'
  make test-agent MSG='List security tools'
  make agentspace-register
  make agentspace-verify
  make agentspace-url

ToDo

  1. De-dupe the 2 requirements.txt files:
run-with-google-adk/requirements.txt
run-with-google-adk/agents/google_mcp_security_agent/requirements.txt
  1. Test MCP Tools in Agentspace

Blocked on the scope: https://www.googleapis.com/auth/generative-language.retriever in oauth_manager.py. ToDo: test without that scope.

  1. Consider incorporating VeerMuchandi's tools from https://github.com/VeerMuchandi/agent_registration_tool
    3.1 Create Makefile targets for those tools

  2. Document the complete workflow:

This is a first draft (needs review):

  make env-check
  make config-show
  make env-update KEY=GOOGLE_CLOUD_PROJECT VALUE=my-project
  make adk-deploy AGENT_DIR=. DISPLAY_NAME='Security Agent'
  make agents-list
  make test-agent MSG='List security tools'
  make oauth-setup
  make agentspace-register
  make agentspace-verify
  make agentspace-url

Each step should indicate which env vars are required as input (in .env and/or in make command) and which are created. Indicate where the created ones should are required in the next step. If there are alternatives to using the make approach, (like cloud console clicking), then note that and point to relevant docs with screenshots.

- Reorganize directory structure with agents/, scripts/, ui/, and libs/ directories
- Add new Google ADK documentation section with quickstart guides
- Create Makefile with comprehensive deployment and management commands
- Add OAuth, AgentSpace, and Cloud Run integration scripts
- Restructure agents into logical groupings (google_mcp_security_agent, sample_agents)
- Move UI components to dedicated ui/ directory
- Create libs/adk_utils for shared utilities
- Add deployment scripts for agentspace, oauth, and environment management
- Include testing scripts for deployed agents
- Update documentation table of contents with new ADK section
@dandye dandye requested a review from a team July 3, 2025 13:45
dandye and others added 8 commits July 3, 2025 11:24
- Add env-setup target to Makefile for creating .env from .env.example
- Update .env.example with optimized model and timeout settings
- Enhance env_manager.py with better validation for UUIDs and URLs
- Fix server name reference from 'soar' to 'secops_soar' in env_manager
- Update .gitignore to exclude markdown library files
- Improve adk-deploy target in Makefile with better lib handling and bucket generation
- Fix agent.py initialization to avoid global variable issues
- Streamline env_manager.py by removing unnecessary agent_engine requirements
- Add automatic cleanup of copied libs after deployment
This commit fixes multiple deployment issues that prevented MCP tools from loading properly:

**Cloud Run Deployment:**
- Fixed cloudrun_deploy.py to point to correct agents directory structure
- Added Python path configuration for libs imports
- Updated cloudrun_deploy_run.sh to handle correct file paths and cleanup
- Fixed Makefile to read environment variables from .env file for deployment

**ADK Local Testing:**
- Updated run-adk-agent.sh to specify agents directory for adk web
- Added automatic libs copying for local testing
- Fixed Python path in agent.py to find local libs directory

**MCP Server Loading:**
- Fixed environment variable mapping for all MCP servers (secops, gti, soar, scc)
- Added proper server entry point handling (scc uses scc_mcp.py, others use server.py)
- Added comprehensive logging for debugging MCP server initialization
- Fixed BASE_DIR and SERVER_DIR path detection for both local and Cloud Run environments

**Agent Configuration:**
- Added default values for GOOGLE_MODEL and DEFAULT_PROMPT to prevent validation errors
- Improved .env file path detection for different deployment environments
- Added flexible path handling for both local development and container deployment

**Makefile Improvements:**
- Fixed cloudrun-logs target to properly read project/region from .env
- Updated adk-deploy target to read environment variables correctly
- Removed dangerous server directory cleanup that could delete original files

All MCP tools (SCC, SecOps, GTI, SOAR) now load correctly in both local and Cloud Run deployments.
Test branch for agentspace deployment
Replace custom MCPToolSetWithSchemaAccess with standard MCPToolset
to resolve 'TypeError: coroutine object is not callable' error.
The custom extensions were workarounds for ADK 1.3 issues that
are now fixed in ADK 1.5.0+.
- Add comprehensive .env file validation in ae_deploy_run.sh
- Enhanced error reporting in ae_remote_deployment_sec.py
- Improved MCP server status logging and validation
- Added server directory copying to Makefile for ADK deployments
- Enhanced agent response handling in test_deployed_agent.py

These changes provide better visibility into deployment issues
and ensure proper environment configuration for ADK agents.
- Add uv to requirements.txt for Agent Engine runtime
- Remove .venv directories from server copies to prevent architecture conflicts
- Clean up unused tool_set_name parameter
- Fixes 'Exec format error' caused by copying architecture-specific binaries
  - Add agentspace_app_setup.md: Complete guide for creating and configuring Agentspace applications, including API enablement, IAM setup, and environment
  configuration
  - Add oauth_agentspace_setup.md: Detailed OAuth setup guide with step-by-step instructions for client creation, authorization flow, and AgentSpace integration
  - Fix Path object issue in env_manager.py: Convert string to Path object to resolve AttributeError in oauth_manager.py
  - Update agentspace_manager.py: Improve force flag handling in agent registration

  The documentation provides clear workflows for users to set up AgentSpace apps and OAuth authentication, addressing the missing prerequisite steps for OAuth
  integration. Includes troubleshooting, security best practices, and complete environment variable reference.
@dandye dandye changed the title Restructure ADK agent architecture and add comprehensive documentation (WiP) Restructure ADK agent architecture and add comprehensive documentation Jul 9, 2025
@dandye dandye marked this pull request as draft July 9, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant