Preface
Who This Course Is For
What You’ll Build
How This Course Is Organized
A Note on the Rapidly Evolving Landscape
Acknowledgments to the Community
Part I: Foundation
Chapter 1: The AIOps Revolution
The Limits of Traditional Automation
What AIOps Really Means
Exercise 1
The Infrastructure Context Problem
Exercise 2
Enter MCP and AI Agents
Real-World Impact and Case Studies
Exercise 3
Why This Matters Now
What You’ll Learn in This Course
Quiz 1
3 attempts allowed
Chapter 2: AI Fundamentals for DevOps Engineers
Understanding Large Language Models for Infrastructure Work
Exercise 4
The Context Window and Memory Limitations
Exercise 5
Prompt Engineering for Infrastructure Automation
Exercise 6
AI Capabilities and Limitations in Operations
Exercise 7
Security Considerations for AI-Powered Infrastructure
Exercise 8
Integration Patterns with Existing Tools
Exercise 9
Choosing the Right AI Models and Providers
Exercise 10
Building Reliable AI Systems
Exercise 11
What’s Next
Quiz 2
3 attempts allowed
Chapter 3: Model Context Protocol Deep Dive
What MCP Is and Why It Matters
Exercise 12
MCP Architecture and Core Concepts
Exercise 13
Protocol Specifications and Communication Patterns
Exercise 14
MCP vs REST APIs and GraphQL
Exercise 15
Real-World MCP Use Cases in DevOps
Exercise 16
The MCP Ecosystem and Tooling
Exercise 17
Security and Trust in MCP Implementation
Exercise 18
Protocol Evolution and Future Directions
What’s Next
Quiz 3
3 attempts allowed
Chapter 4: Setting Up Your Development Environment
Go Development Environment for MCP
Installing and Configuring Go
Essential Go Tools for MCP Development
Setting Up Your First MCP Project
Adding Essential Dependencies
AWS CLI and SDK Configuration
Installing AWS CLI v2
Configuring AWS Credentials
Setting Up AWS Permissions for MCP Development
AI Tools Integration
GitHub Copilot Setup and Configuration
VS Code Extensions for MCP Development
Development Workflow Automation
What’s Next
Chapter 5: Your First MCP Server in Go
Project Structure and Dependencies
Basic MCP Protocol Implementation
Type Definitions
Understanding ResourceInfo Fields
JSON-RPC Examples
Design Patterns for Resource URIs
Configuration Management
Logging Setup
Exercise 19
AWS SDK Integration
AWS Client Wrapper
Understanding AWS Client Functions
HealthCheck Function
ListEC2Instances Function
GetEC2Instance Function
convertEC2Instance Function
Error Handling Patterns
Logging and Observability
Integration with MCP Protocol
Resource Discovery and Formatting
MCP Resource Implementation
Understanding the ResourceHandler Implementation
ResourceHandler Structure
ReadResource Function - The Main Router
readEC2InstancesList Function - Collection Data
readEC2Instance Function - Detailed Instance Data
formatInstancesForAI Function - Data Optimization
formatInstanceForAI Function - Single Instance Details
Error Handling Examples
Complete Request/Response Flow
Testing Your MCP Server
Main Application
Building and Testing
What’s Next
Quiz 4
3 attempts allowed
Chapter 6: MCP Tools for Infrastructure Actions
Understanding MCP Tools vs Resources
Resources: The “What Is” Interface
Tools: The “Make It Happen” Interface
Why This Distinction Matters
Exercise 20
Project Structure for Tools
Implementing MCP Tools
Tool Handler Structure
Understanding the Tool Handler Architecture
How Tool Routing Works
EC2 Instance Creation Tool
Deep Dive: EC2 Instance Creation Logic
Parameter Validation Strategy
Why This Validation Approach Works
The AWS Client Integration
Response Formatting for AI Consumption
Real-World Parameter Handling Examples
Example 1: Complete Valid Request
Example 2: Minimal Valid Request
Example 3: Invalid Request - Missing Required Field
Example 4: Invalid Request - Wrong Type
Example 5: Mixed Valid/Invalid Optional Parameters
Instance Management Tools
Understanding Instance Lifecycle Management
Real-World Usage Scenarios
Response Formatting Helpers
Understanding Response Standardization
Deep Dive: JSON Formatting for AI Consumption
Response Pattern Benefits
Exercise 21
Extending the AWS Client
Understanding the AWS Client Design Pattern
Deep Dive: Instance Creation Flow
Lifecycle Operation Patterns
Tag Management Design
Tool Registration in MCP Server
Understanding MCP Tool Registration Architecture
Deep Dive: Parameter Schema Design
Request Routing Pattern
AI Tool Discovery Flow
Exercise 22
Real-World Example: Complete AI-to-Infrastructure Flow
Step 1: User Question
Step 2: AI Analysis and Intent Recognition
Step 3: AI Structures JSON-RPC Request
Step 4: MCP Client Sends Request
Step 5: MCP Server Processing
Step 6: AWS API Execution
Step 7: Success Response Back to AI
Step 8: AI Formats Human-Readable Response
Chapter Summary
Key Achievements
What’s Next
Understanding the Complete Flow
Quiz 5
3 attempts allowed
Chapter 7: Advanced AWS Operations
The Production Infrastructure
Exercise 23
AWS Infrastructure Fundamentals
Virtual Private Cloud
Auto Scaling Groups
Application Load Balancer
Relational Database Service
Operational Excellence Through Automation
Exercise 24
Enhanced MCP Server Architecture
Extended Project Structure
Core Parameter Structures
Understanding the Parameter Design Philosophy
VPC and Networking Tools Implementation
VPC Creation Flow
Subnet Management Strategy
Exercise 25
Auto Scaling Group Tools Implementation
Launch Template Creation Flow
Auto Scaling Group Creation Strategy
ASG Integration Patterns
Exercise 26
Application Load Balancer Tools Implementation
Load Balancer Architecture
Load Balancer Creation Flow
Health Check Strategy
Exercise 27
RDS Tools Implementation
Database Infrastructure Management
Tool Registration and MCP Integration
Exercise 28
Real-World Example: Complete Production Deployment
Phase 1: VPC Infrastructure Foundation
Phase 2: Security Group Configuration
Phase 3: Load Balancer Infrastructure
Phase 4: Auto Scaling Application Tier
Phase 5: Database Infrastructure
Understanding the Complete Infrastructure Flow
1. Dependency Management
2. Resource Coordination
3. Security Integration
4. Operational Excellence
Chapter Summary
Key Achievements
What’s Next
Quiz 6
3 attempts allowed
Chapter 8: Refactoring for Production-Ready Architecture
Understanding the Current Architecture’s Limitations
Monolithic Tool Management
Lack of Interface Abstractions
Mixed Responsibilities
Refactoring Goals and Vision
Key Refactoring Steps
Step 1: Introducing Interface Abstractions
AWS Resource Management Interface
MCP Tool Interface
Tool Management Interfaces
Step 2: Implementing the Adapter Pattern
Base Adapter Implementation
Service-Specific Adapters
Step 3: Creating the Tool Registry System
Tool Registry Implementation
Tool Factory Implementation
Step 4: Implementing Concrete Tools
Step 5: Refactoring the Server Architecture
Step 6: Adding Utility Functions
Exercise 29
Challenges and Solutions
Challenge 1: Backward Compatibility
Challenge 2: Complex Parameter Validation
Challenge 3: Testing Complex Interactions
Challenge 4: Performance Impact
Preparation for Chapter 9
Enhanced AI Agent Integration
Plugin Architecture Foundation
Advanced Workflow Capabilities
GitHub Copilot Integration Readiness
Conclusion
Quiz 7
3 attempts allowed
Chapter 9: GitHub Copilot and MCP Integration for Infrastructure Automation
GitHub Copilot and MCP
Why GitHub Copilot for Infrastructure Automation
VS Code MCP Configuration Deep Dive
MCP Server Configuration
VS Code Settings Integration
Understanding the JSON-RPC Protocol Flow
Real-World Scenario: Three-Tier Application with GitHub Copilot
Setting Up the Development Environment
Complete Infrastructure Deployment
Phase 1: VPC Infrastructure Foundation
Phase 2: Security Group Architecture
Phase 3: Load Balancer Infrastructure
Phase 4: Auto Scaling Application Tier
Phase 5: Database Infrastructure
Understanding Copilot’s AI Decision Process
1. Context Analysis
2. Resource Dependency Resolution
3. Parameter Intelligence
4. Error Handling and Resilience
Advanced Copilot Integration Patterns
Interactive Infrastructure Refinement
Infrastructure Status and Monitoring
Debugging and Troubleshooting MCP with GitHub Copilot
Common Integration Issues
Chapter Summary
Technical Integration Mastery
Production Infrastructure Deployment
Advanced Capabilities
Enterprise Readiness
Part III: AI Agents for DevOps
Chapter 10: AI Agents Architecture
From Stateless Tools to Stateful Agents
The MCP Model: Powerful but Limited
The Agent Model: Intelligence with Memory
AI Agent Foundation
Core Agent Capabilities
Agent vs. Traditional Automation
Exercise 30
Quiz 8
3 attempts allowed
Agent Architecture Patterns
Reflection Pattern
Tool Use Pattern
ReAct Pattern
Planning Pattern
Multi-Agent Pattern
How Patterns Work Together
Agent Components Deep Dive
AI Model
Role
Tasks and Focus
Tools
Memory
Enterprise Agent Considerations
Guardrails and Safety Controls
Security and Authorization
Reliability and Fault Tolerance
Observability and Debugging
Human Oversight
What You’ve Learned
What’s Next
Chapter 11: Understand What You Will Build
The Evolution from Automation to Intelligence
Core Principles of AI Infrastructure Agents
State Awareness
Natural Language Processing
Dependency Intelligence
Conflict Resolution
AI Agent Architecture Overview
Request Analysis Layer
State Management Layer
AI Planning Engine
Execution Orchestrator
The Agent Execution Flow
Discovery and Analysis Phase
Planning Phase
Execution Phase
What You Will Build
The Strategic Advantage
What’s Next
Chapter 12: Introduction to LangChain Framework
What is LangChain?
Why LangChain for Infrastructure Agents?
LangChain Core Concepts
1. Models: The Intelligence Layer
2. Prompts: Structuring Agent Communication
3. Tools: Connecting to Infrastructure
4. Chains: Sequential Reasoning
5. Memory: Maintaining Context
6. Agents: Autonomous Decision Makers
Mapping LangChain to Your Agent Architecture
Agent Patterns in LangChain
ReAct Pattern in LangChain
Planning Pattern in LangChain
LangChain in Go vs Python
Why This Matters for Infrastructure Automation
What You’ve Learned
What’s Next
Chapter 13: Building the Models Layer
AI Infrastructure Agent Codebase
Project Structure
Understanding the Models Layer
A Simple Example: Using langchaingo
The langchaingo Model Interface
Your Implementation Strategy
Exercise 31
Stage 1: Configuration System
Exercise 32
Stage 2: Provider Initialization
Testing LLM Connectivity
Stage 3: Agent Integration
Agent Structure
Agent Creation
Agent Initialization
Using the Agent
Testing the Models Layer
Handling Provider Differences
Token Limits
Temperature Ranges
API Method Differences
API Rate Limits
Exercise 33
What You’ve Built
Next Steps
Quiz 9
3 attempts allowed
Chapter 14: Building the Prompts Layer
What You’re Building
The Three-Part Prompt Architecture
Project Files for This Chapter
How Prompts Flow Through the System
Understanding the Prompts Layer
The Challenge: From General AI to Infrastructure Specialist
The Prompt Anatomy
Why Templates?
Prompt Engineering Principles for Infrastructure
Exercise 34
Understanding Retrieval-Augmented Generation (RAG)
What “RAG” Means in This Context
The Infrastructure State Problem
How Our Implementation Works
The State Collection and Prompt Structuring Pipeline
Future Enhancement: Advanced RAG Strategies
When RAG Matters Most
RAG vs Vector Databases
Exercise 35
Stage 1: Building System Prompts
What Are System Prompts?
The Template File Structure
Loading Templates in Code
Using System Prompts in Request Processing
System Prompt Best Practices
What You’ve Built So Far
Exercise 36
Stage 2: Context Injection with RAG Implementation
Building Context-Aware Prompts
Understanding the Five-Part Prompt Structure
Property Filtering: The RAG Technique in Action
Token Reduction Mathematics
Nested Property Extraction from MCP Responses
Why Not Full RAG with Entity Extraction?
Example: Prompt with RAG-Filtered Context
Future Enhancement: Full RAG with Entity Extraction
Exercise 37
Stage 3: Tool Descriptions and Schemas
Why Tool Schemas Matter
Generating Dynamic Tool Schemas
Example Generated Schema
Tool Templates with Patterns
Loading Tools Context with Placeholders
Tool Categorization
Complete Tools Section Example
What You’ve Built
What Your Agent Can Do Now
What’s Next
Quiz 10
3 attempts allowed
Chapter 15: Building the Tools Layer
What You’re Building
Project Files for This Chapter
How It All Fits Together
Understanding Retrieval-Augmented Generation (RAG)
What Is RAG?
The Four Pillars of RAG for AI Agents
How Tools Enable RAG
Exercise 38
Stage 1: MCP Connection
The stdio Architecture
The MCPProcess Struct
Starting the MCP Server
The MCP Protocol Handshake
The JSON-RPC Wire Protocol
Exercise 39
Stage 2: Tool Discovery
Discovering MCP Tools
Lazy Discovery with ensureMCPCapabilities
Generating Tool Schemas for the LLM
The RAG Connection: Tools Feed Prompts
Exercise 40
Stage 3: Tool Execution
Calling MCP Tools
The executeNativeMCPTool Pipeline
Phase 3: Dependency Resolution
Phase 6: Post-Processing Pipeline
Exercise 41
Stage 4: Plan Execution
The Execution Loop
Step Dispatching
A Complete Execution Example
Exercise 42
The Request Processing Pipeline
Parsing the LLM Response
Exercise 43
Putting It All Together: The Complete Pipeline
What’s Next
Quiz 11
3 attempts allowed
Chapter 16: Understanding AI Memory
The Stateless Reality
Exercise 44
The Context Window
Exercise 45
Why Infrastructure Memory Is Different
Chatbot Memory vs. Infrastructure Memory
The Terraform Analogy
Exercise 46
Types of AI Agent Memory
Conversation Buffer Memory
Sliding Window Memory
Summary Memory
Token-Aware Memory
Semantic Memory
Exercise 47
The State File: Your Agent’s Core Memory
How State Memory Works in Your Agent
The State File Structure
Atomic State Updates
Exercise 48
Short-Term vs. Long-Term Memory
Your Agent’s Current Memory Map
Exercise 49
The Drift Problem: When Memory Lies
Exercise 50
The Forgetting Problem
Exercise 51
Memory in the Infrastructure Context
High-Value Memory (Always Keep)
Medium-Value Memory (Keep Summarized)
Low-Value Memory (Safe to Discard)
Mapping Values to Strategies
Exercise 52
Where Memory Sits in the Agent Architecture
Exercise 53
Choosing the Right Strategy
Exercise 54
What Memory Is Not
Exercise 55
Looking at the Landscape
Exercise 56
What’s Next
Quiz 12
3 attempts allowed
Chapter 17: Implementing the Memory Layer
Data Types: What Memory Looks Like
Exercise 57
The State Manager
Configuration
State Operations: Load and Save
Exercise 58
Resource CRUD Operations
Adding a Resource
Updating Existing Resources
Removing Resources
Reading Resources
Exercise 59
Checksum and Drift Detection
Detecting Drift
Exercise 60
Dependency Graph
Querying Dependencies
Exercise 61
Agent State Bridge: MCP Result → Persistent State
The Entry Point: addStateFromMCPResult
Updating Managed Resources: Security Gate
Persisting After Each Step
Exercise 62
MCP-Mediated State Operations
Exercise 63
Resource Extraction Pipeline
Inferring Resource Type
Building Unified Resource Info
Reading Memory: The Decision Context
The DecisionContext Struct
Exercise 64
Short-Term Memory: Recovery Context
PlanFailureContext
CompletedStepInfo
RecoveryAttemptHistory
Exercise 65
The Complete Memory Flow
What the State File Looks Like
Memory Boundaries
Exercise 66
What You Built
What’s Next
Quiz 13
3 attempts allowed
Chapter 18: The ReAct Pattern—Reason, Act, Recover
What ReAct Actually Means
Exercise 67
The Execution Loop
Running Steps, One at a Time
Detecting Success or Triggering Recovery
Exercise 68
How Steps Pass Data to Each Other
Exercise 69
Capturing the Moment of Failure
Exercise 70
Consulting the AI for a Recovery Strategy
Building the Recovery Prompt
Assembling the New Plan
Exercise 71
Validating Before Trusting
Executing the Recovery, With Approval
Running the Recovery Steps
Exercise 72
Human in the Loop: How Approval Actually Works
Exercise 73
Learning Across Attempts
Exercise 74
The Full Loop in Action
Exercise 75
When Recovery Goes Wrong
Exercise 76
How Many Times to Try
Exercise 77
What You Built
What’s Next
Quiz 14
3 attempts allowed
Chapter 19: The Road Ahead
What You Actually Built
The Patterns Generalize
Exercise 78
Where the Cracks Are
Exercise 79
What to Build Next
Exercise 80
The Human in the Loop Is the Point
Exercise 81
Where You Go From Here
Thank You for Reading
Quiz 15
3 attempts allowed
The AIOps Book (The Course)
From Manual Operations to AI-Powered Infrastructure
Master AI-powered infrastructure automation with this hands-on guide to building production-ready MCP servers and AI agents in Go. Transform from manual AWS operations to intelligent automation that understands your environment and makes smart decisions while keeping humans in control.
Minimum price
$129
$179
You pay
Author earns
About
About the Course
Transform your infrastructure operations with AI-powered automation that actually works in production. This comprehensive guide teaches DevOps engineers, SREs, and platform architects how to build intelligent systems using the Model Context Protocol (MCP) and AI agents with Go.
Stop copying configuration files into ChatGPT and start building AI assistants that understand your AWS environment directly. Learn to create MCP servers that give AI systems real-time access to your infrastructure, develop agents that can provision complete environments from natural language descriptions, and implement secure automation workflows that augment human expertise without replacing it.
Written by a practicing DevOps engineer for practitioners, this course focuses on production-ready solutions rather than theoretical concepts. You'll build working systems from day one: MCP servers that integrate with AWS APIs, AI agents that can analyze deployment failures and suggest specific fixes, and complete automation workflows that handle the repetitive tasks while keeping humans in control of critical decisions.
Every chapter includes working Go code examples, real-world scenarios, and practical patterns you can adapt to your environment. The companion GitHub repository provides complete implementations that you can deploy and extend immediately.
Whether you're automating your first infrastructure task with AI or designing enterprise-scale AIOps platforms, this course gives you the knowledge and tools to build systems that are both intelligent and reliable. Learn to leverage AI's pattern recognition and reasoning capabilities while maintaining the security, auditability, and control that production environments require.
The future of infrastructure operations isn't about replacing DevOps engineers with AI—it's about augmenting human expertise with tools that can handle complexity at scale. Start building that future today.
Instructor
About the Instructor
I am a DevOps Lead at FinX with extensive experience in designing, building, and managing mission-critical infrastructure for digital banking products on Amazon Web Services (AWS). My professional journey has been deeply rooted in the financial sector, where security, resilience, and scalability are paramount.
In addition to my primary work, I pursue side projects as a book author. Two of my proudest works are The AIOps Book and On-Call in Action.
I also lead the DevOpsVN and Cloud Native Vietnam community, which boasts over 25,000 followers on Facebook. As a founder of DevOpsVN, my goal is to empower the tech community by simplifying complex concepts and offering actionable, real-world solutions. Through my writing, I strive to bridge the gap between theory and practice, helping others navigate the ever-evolving landscape of modern technology.
Material
Course Material
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.