Skip to main content

Petstore/Template Agent

  • ๐Ÿค– Petstore Agent is an LLM-powered agent built using the LangGraph ReAct Agent workflow and Petstore MCP Server.
  • ๐ŸŒ Protocol Support: Compatible with A2A protocol for integration with external user clients.
  • ๐Ÿ›ก๏ธ Secure by Design: Enforces API token-based RBAC and supports secondary external authentication for strong access control.
  • ๐Ÿญ MCP Server: The MCP server is generated by our first-party openapi-mcp-codegen utility, ensuring version/API compatibility and software supply chain integrity.
  • ๐Ÿ”Œ MCP Tools: Uses langchain-mcp-adapters to glue the tools from Petstore MCP server to LangGraph ReAct Agent Graph.
  • ๐Ÿงช Mock Server: Includes a built-in mock server for testing and development purposes.

๐Ÿ—๏ธ Architectureโ€‹

Detailed Sequence Diagram with Agentgateway

System Diagramโ€‹

Sequence Diagramโ€‹


โš™๏ธ Local Development Setupโ€‹

Use this setup to test the agent against the Petstore mock server.

โ–ถ๏ธ Start Petstore Mock Serverโ€‹

The Petstore agent includes a built-in mock server for testing:

# Start the mock server
docker run -d -p 8080:8080 swaggerapi/petstore3

๐Ÿ”‘ Configure Environmentโ€‹

Create a .env file with your configuration:

# Agent Configuration
AGENT_NAME=petstore_agent
LLM_PROVIDER=azure-openai

# Petstore API Configuration
PETSTORE_API_URL=http://localhost:8080
PETSTORE_API_KEY=test-key

# A2A Configuration
A2A_AGENT_HOST=localhost
A2A_AGENT_PORT=8000

# MCP Configuration
MCP_HOST=localhost
MCP_PORT=9000

Local Developmentโ€‹

# Navigate to the Template agent directory
cd ai_platform_engineering/agents/template

# Run the MCP server in stdio mode
make run-a2a

๐Ÿš€ Test Petstore Operationsโ€‹

# Test basic pet operations
curl -X GET "http://localhost:8080/api/v3/pet/findByStatus?status=available"
curl -X GET "http://localhost:8080/api/v3/pet/1"

Run Petstore Sanity testsโ€‹

make petstore-sanity

โœจ Featuresโ€‹

  • Pet Management: Create, read, update, and delete pet records
  • Pet Search: Find pets by status, tags, or other criteria
  • Pet Store Operations: Manage pet store inventory and operations
  • Mock Server Integration: Built-in mock server for testing and development
  • API Testing: Test REST API operations with sample data
  • Development Template: Use as a template for creating new agents
  • MCP Server: Full Petstore API coverage through MCP tools

๐ŸŽฏ Example Use Casesโ€‹

Ask the agent natural language questions like:

  • Pet Operations: "Add a new dog named 'Buddy' to the pet store"
  • Pet Search: "Find all available cats in the store"
  • Pet Management: "Update the status of pet ID 123 to 'sold'"
  • Inventory Management: "Show me all pets with the tag 'premium'"
  • Store Operations: "List all pets that need to be fed today"
  • API Testing: "Test the pet creation endpoint with sample data"

๐ŸŽฏ Customization Guideโ€‹

Agent-Specific Configurationโ€‹

  1. Update Agent Name: Replace "template" with your agent name
  2. Configure API Integration: Add your specific API endpoints and authentication
  3. Customize Prompts: Modify system prompts and user interactions
  4. Add Tools: Implement agent-specific tools and utilities
  5. Update Documentation: Customize README and documentation

MCP Server Customizationโ€‹

  1. API Specification: Provide your OpenAPI specification
  2. Tool Selection: Choose which API endpoints to expose as tools
  3. Authentication: Configure authentication methods
  4. Error Handling: Implement custom error handling logic

Testing and Evaluationโ€‹

  1. Unit Tests: Add tests for your specific functionality
  2. Integration Tests: Test against your API endpoints
  3. Evaluation Suite: Create evaluation prompts and expected outputs
  4. Performance Testing: Test agent performance and response times

๐Ÿ“š Documentationโ€‹

For more detailed information about creating agents, please refer to: