Skip to content

kevinpbuckley/MAF-Sitecore-Agent-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sitecore Agent API with Microsoft Agent Framework

Sample project demonstrating how to use the Microsoft Agent Framework with the Sitecore Agent API using OpenAPI specifications.

Features

  • Automatically generates function tools from Sitecore Agent API OpenAPI spec
  • Downloads latest API spec on each run
  • OAuth 2.0 authentication with Sitecore Cloud
  • Interactive chat interface for Sitecore operations
  • All 39 Sitecore API operations available (Sites, Pages, Content, Components, Assets, Jobs, etc.)

Prerequisites

  • Python 3.13+
  • Azure OpenAI account with deployment
  • Sitecore XM Cloud instance
  • Sitecore automation client credentials

Setup

  1. Clone the repository:
git clone https://github.com/kevinpbuckley/MAF-Sitecore-Agent-API.git
cd MAF-Sitecore-Agent-API
  1. Install dependencies:
pip install -r requirements.txt
  1. Create .env file from sample:
cp .env.sample .env
  1. Configure your environment variables in .env:
    • Azure OpenAI credentials
    • Sitecore client ID and secret (from XM Cloud Deploy automation credentials)

Sitecore Credentials Setup

  1. Go to Sitecore Cloud Portal
  2. Open XM Cloud Deploy
  3. Navigate to Credentials > Environment > Create credentials > Automation
  4. Copy the client ID and client secret to your .env file

Usage

Run the interactive agent:

python sitecore_agent.py

Example commands:

  • "list sites"
  • "show pages for nextjs-skate-park site"
  • "get site details for alaris"
  • "search for content items"

Type exit or quit to stop.

How It Works

The agent automatically:

  1. Downloads the latest Sitecore Agent API OpenAPI spec
  2. Generates Python function tools for all 39 operations
  3. Authenticates with Sitecore using OAuth 2.0
  4. Uses Azure OpenAI to understand natural language commands
  5. Calls appropriate Sitecore API operations based on user intent

Available Operations

  • Sites: List sites, get site details, list pages, get site ID from item
  • Pages: Create pages, add languages, add components, search, get HTML/screenshots
  • Content: Create, read, update, delete content items
  • Components: List components, create datasources, search datasources
  • Assets: Upload, search, get info, update metadata
  • Environments: Get available languages
  • Personalization: Create personalized variants
  • Jobs: View job details, revert operations

Project Structure

MAF-Sitecore-Agent-API/
├── sitecore_agent.py       # Main agent implementation
├── index.json              # Cached OpenAPI spec (auto-updated)
├── requirements.txt        # Python dependencies
├── .env.sample             # Environment variables template
├── .gitignore              # Git ignore file
└── README.md               # This file

License

MIT

Resources

About

Microsoft Agent Framework with Sitecore Agent API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages