Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
AI Agent & MCP Security: Build and Defend Real Systems
New
499 students

AI Agent & MCP Security: Build and Defend Real Systems

Build and secure MCP servers and AI agents with hands-on labs in prompt injection, OAuth, tool safety, and monitoring.
Last updated 11/2026
English
English [Auto],

What you'll learn

  • Build and secure AI agents and MCP servers using Python, FastAPI, Ollama, and open-source tools.
  • Identify and defend against prompt injection, MCP tool poisoning, privilege escalation, and data exfiltration attacks.
  • Implement OAuth 2.0, authentication, authorization, RBAC, and least-privilege security for AI agents and MCP tools.
  • Secure AI agent execution environments using Docker sandboxing, API security, secrets management, and Zero Trust principles.
  • Perform authorized AI red teaming, vulnerability assessments, threat modeling, and security testing in controlled environments.
  • Implement AI security monitoring, audit logging, threat detection, and automated security testing for agentic applications.
  • Protect multi-agent workflows, agent communication, shared memory, and enterprise integrations from security threats.
  • Build and defend a complete enterprise AI agent ecosystem through a hands-on cybersecurity capstone project.

Course content

17 sections • 128 lectures • 10h 33m total length
  • Welcome to AI Agent & MCP Security: Build and Defend Real Systems5:06

    Welcome to AI Agent & MCP Security: Build and Defend Real Systems. This opening lecture introduces the course, explains why securing autonomous AI systems has become an urgent skill, and shows how each section builds toward a complete, defended enterprise agent platform.


    We begin with the shift that makes this topic important. AI agents no longer just answer questions. They read documents, query databases, call APIs, run tools, and take actions on behalf of users and organizations. The Model Context Protocol, or MCP, standardizes how agents discover and use those tools, which makes integration easy and also creates new places where things can go wrong.


    You will see the learning path. First we cover fundamentals, set up a safe local lab, and build a tool-enabled agent and several MCP servers. Then we study threats, including prompt injection, tool poisoning, weak authentication, excessive permissions, data leakage, unsafe execution, supply chain risk, and multi-agent attacks. For each threat you will learn a defensive control and test it. Later sections cover monitoring, authorized red teaming, governance, and a final capstone.


    Everything runs locally with open-source tools and synthetic data, so you can practice safely. By the end of this lecture you will know what the course covers, what you will build, and how to get the most from every lesson and lab.

  • Why Securing AI Agents Is Different from Traditional Application Security5:20

    Securing an AI agent is not the same as securing a traditional application, and this lecture explains why the old playbook is necessary but no longer sufficient.


    In a traditional application, developers write the logic. Inputs are validated, code paths are fixed, and behavior is largely predictable. Security teams can reason about which functions run and which data they touch. An AI agent changes this. A language model interprets instructions, often written in natural language, and decides at runtime which tools to call and with what arguments. The program's behavior is partly determined by content the model reads.


    This creates new properties. Instructions and data share the same channel, so text from a webpage or document can look like a command. Behavior is probabilistic, so the same input may produce different actions. Agents hold credentials and permissions, so a manipulated decision can have real consequences. Chains of tool calls can combine harmless steps into a harmful result.


    We also explain what still applies: authentication, authorization, least privilege, input validation, logging, and isolation remain essential. The difference is that they must be enforced outside the model, in code and infrastructure that does not depend on the model behaving well.


    By the end of this lecture you will understand what is new, what is familiar, and why deterministic controls matter most.

  • Understanding the Emerging AI Agent Security Landscape4:59

    The security landscape for AI agents is evolving quickly, and this lecture gives you a map of the main risk areas and the organizations and frameworks that describe them.


    We begin with the layers of an agent system: the model, the instructions and context, the tools and protocols, the data sources, the identity and permission layer, and the runtime environment. Each layer has its own weaknesses, and attackers look for the weakest link across them.


    Next, we survey the major categories of risk. Prompt injection and goal hijacking target the model's instruction handling. Tool poisoning and malicious servers target the tool ecosystem. Authentication and authorization failures expose protected resources. Excessive agency lets an agent do more than intended. Data leakage and exfiltration expose sensitive information. Unsafe execution and weak sandboxing allow side effects on the host. Supply chain compromise introduces untrusted code. Multi-agent systems add impersonation and memory poisoning.


    We introduce the frameworks that organize this knowledge, including the OWASP guidance for agentic applications and large language model applications, and we explain how to use them for communication and prioritization.


    Finally, we discuss how defenders think: assume the model can be influenced, limit the blast radius, verify at boundaries, and monitor continuously. By the end of this lecture you will have a mental map that organizes everything else in the course.

  • Real-World AI Agent and MCP Security Incidents5:08

    Learning from real incidents is one of the fastest ways to understand risk, and this lecture reviews the kinds of AI agent and MCP security incidents that have been reported and what they teach us.


    We focus on patterns rather than sensational details. Researchers and practitioners have publicly described cases where an assistant read untrusted content, such as an email, a web page, or an issue in a code repository, and was influenced to take actions the user never intended. Others have shown tool descriptions that contained hidden instructions, servers that changed behavior after being approved, and integrations that exposed tokens or returned more data than necessary. Package ecosystems have also seen malicious or typosquatted components aimed at developers building agent tooling.


    For each pattern, we examine the root causes. Often the problem was a combination of untrusted input, an agent with broad permissions, and no approval or monitoring step. Rarely was a single clever trick responsible. Weak boundaries and missing controls were the common thread.


    We then turn each lesson into a defensive takeaway: treat external content as untrusted, grant minimal permissions, verify tools before and during use, pin and review dependencies, require approval for risky actions, and log everything meaningful.


    By the end of this lecture you will be able to recognize recurring failure patterns and connect them to the controls you will build later in the course.

  • Introducing Our End-to-End AI Agent Security Lab5:12

    Throughout this course you will work inside one consistent environment, and this lecture introduces the end-to-end AI agent security lab and the fictional company it represents.


    We begin with the scenario. SecureOps is a simulated enterprise that uses an AI agent to help employees with service desk requests, document search, ticket handling, and data lookups. The agent connects to several MCP servers, each exposing tools for a business function. All data is synthetic, and everything runs on your own computer.


    You will see the architecture at a high level: a local language model served by Ollama, an agent application written in Python, MCP servers built with the Python SDK, a FastAPI service and SQLite database that stand in for business systems, and Docker for isolation. Supporting tools include MCP Inspector for testing and logging components that you will add later.


    We explain how the lab evolves. First, you build the system in a simple, intentionally under-protected form so you can observe weaknesses safely. Then each section introduces a threat and a matching defense, and you will apply, test, and verify the control. By the final capstone, the same platform will be hardened and monitored.


    By the end of this lecture you will understand the lab layout, the learning approach, and how every later exercise connects to the same system.

  • Responsible Security Testing, Lab Boundaries, and Rules of Engagement5:09

    Security skills must be practiced responsibly, and this lecture establishes the ethical rules, boundaries, and expectations for all hands-on work in this course.


    We begin with the principle of authorization. Security testing is only appropriate when you have clear permission to test a specific system. In this course, that permission applies only to the lab environment that you build yourself, using synthetic data. You should never apply attack-style techniques to systems, services, accounts, or models that you do not own or have explicit written permission to assess.


    Next, we define the rules of engagement for the lab. Keep experiments inside the isolated environment. Use only the fake credentials and sample data provided. Avoid connecting the lab to real company data, production services, or personal accounts. Keep network exposure limited to your own machine. Document what you test and what you find, as a professional assessor would.


    We also discuss responsible disclosure and professional conduct: report vulnerabilities you discover in real products through proper channels, respect scope and time limits, avoid causing harm, and protect any sensitive information encountered during legitimate assessments.


    Finally, we explain how the course demonstrations are designed to be harmless and focused on defense. Each exercise ends with a mitigation and a retest. By the end of this lecture you will understand the boundaries and be ready to practice safely and professionally.

  • Hands-on: Explore the sample AI agent ecosystem and identify security exposure4:28

    In this hands-on exercise you will explore the sample AI agent ecosystem and identify its security exposure, building the habit of assessing a system before changing it.


    Begin by reviewing the provided sample ecosystem, which includes an agent, two simple MCP servers, a small API, and a database containing synthetic records. Read the configuration files and source code to understand how the pieces connect. Note which tools exist, what each one can do, which data it can reach, and which credentials or settings it uses.


    Next, draw a simple diagram. Show the user, the agent, the model, each tool and server, the API, the database, and the files involved. Mark where data enters from outside, such as documents, web content, and tool responses, and where actions leave the system, such as writes and outbound requests.


    Then list your observations about exposure. Look for tools with broad capabilities, missing input validation, secrets stored in plain text, absence of authentication between components, unrestricted network access, and no logging of actions. Do not exploit anything yet. Rate each observation by likely impact and write it in a simple findings table.


    Finally, keep your notes and diagram, because later sections return to each finding, apply a defense, and measure the improvement. Treat this as your baseline assessment.

  • Complete Lab Package - AI Agent & MCP Security1:40

    This lecture is your guide to the complete AI Agent & MCP Security lab package, the collection of source code, configuration, and data that supports every exercise in the course.


    We explain what is included and how to use it. The package contains the sample agent, starter MCP servers, a FastAPI application, a SQLite database with synthetic data, Docker and Compose files, configuration templates, test scripts, policy examples, and checklists. Folders are organized by section so that you can find the starting files and the reference solutions for each lab.


    You will learn how to download and extract the package, where to place it on your computer, and how to create a clean working copy. We recommend initializing a Git repository so you can track your changes and return to earlier states whenever an experiment goes wrong. We also describe naming conventions and the purpose of each top-level folder.


    We cover good practices for working with the lab. Use the provided fake credentials only, keep the lab isolated from real systems, avoid committing real secrets to any repository, and reset the environment between experiments when needed. We also explain how to compare your work with the reference solutions without simply copying them.


    Finally, we show how to troubleshoot common issues, such as port conflicts and missing dependencies. By the end of this lecture you will know where everything lives and be ready to begin.

Requirements

  • Basic understanding of Python programming is recommended.
  • Familiarity with REST APIs, JSON, and HTTP concepts will be helpful.
  • Basic knowledge of cybersecurity principles is beneficial but not mandatory.
  • No prior experience with AI agents, MCP, or agentic AI security is required.
  • A Windows, macOS, or Linux computer capable of running Python and development tools.
  • At least 8 GB RAM; 16 GB recommended for running local AI models with Ollama.
  • Internet access for downloading free, open-source development tools.
  • No paid AI subscriptions, cloud services, or commercial API keys are required.
  • Willingness to experiment with hands-on labs, security testing, and Python-based projects.

Description

This course contains the use of artificial intelligence.

Master AI Agent Security, MCP Security, and Agentic AI Cybersecurity Through Hands-On Projects

AI agents are transforming how applications work, but are they secure?

As organizations adopt Agentic AI, Large Language Models (LLMs), AI Agents, and the Model Context Protocol (MCP), new cybersecurity challenges are emerging. AI-powered systems can access databases, execute tools, communicate with APIs, and perform autonomous actions. Without proper security controls, these capabilities introduce serious risks.

Welcome to AI Agent & MCP Security: Build and Defend Real Systems, a comprehensive, hands-on course designed to teach you how to build, secure, test, and defend AI agents and MCP servers using practical techniques, open-source technologies, and enterprise security best practices.

Whether you're an AI Engineer, Cybersecurity Professional, DevSecOps Engineer, Python Developer, Security Architect, or AI Red Teamer, this course will help you understand and address the rapidly evolving security challenges of Autonomous AI Systems.

What You'll Learn

Throughout this course, you'll develop practical expertise in:

  • AI Agent Security: Understand agentic architectures, autonomous workflows, attack surfaces, and trust boundaries.

  • Model Context Protocol (MCP): Build secure MCP Servers, MCP Clients, and MCP Tools using Python.

  • Prompt Injection Attacks: Identify and defend against Direct Prompt Injection, Indirect Prompt Injection, and Agent Goal Hijacking.

  • MCP Tool Poisoning: Explore malicious tool descriptions, compromised integrations, and tool manipulation.

  • Authentication and Authorization: Implement OAuth 2.0, Identity Management, Role-Based Access Control (RBAC), and Least Privilege.

  • AI Security Vulnerabilities: Understand Privilege Escalation, Credential Exposure, Data Exfiltration, and Unauthorized Tool Execution.

  • AI Runtime Security: Apply Docker Sandboxing, Secure Tool Execution, Network Isolation, and Container Security.

  • Multi-Agent Security: Protect agent communication, shared memory, delegated permissions, and workflows.

  • AI Red Teaming: Perform authorized security testing and vulnerability assessments in isolated environments.

  • AI Security Monitoring: Implement Audit Logging, Threat Detection, Security Observability, and Incident Response.

  • Secure AI Development: Apply OWASP Agentic AI Security, Zero Trust Architecture, DevSecOps, and Secure SDLC principles.

Learn by Building Real Systems

This isn't just another theoretical AI Cybersecurity Course.

You'll build an enterprise-style AI Agent Security Lab using Python, FastAPI, Ollama, MCP Python SDK, SQLite, and Docker.

Through guided practical exercises, you'll create AI agents, develop MCP servers, safely simulate security vulnerabilities, implement defensive controls, and validate your solutions.

You'll explore LLM Security, Tool-Calling Security, API Security, Secrets Management, Supply Chain Security, and AI Governance through realistic enterprise scenarios.

Final Capstone Project

You'll design and defend SecureOps, a simulated enterprise AI agent platform featuring multiple MCP servers, secure authentication, authorization policies, runtime monitoring, vulnerability testing, and comprehensive security controls.

By completing this project, you'll gain practical experience designing Secure Agentic AI Applications.

Start Building Secure AI Today

The future of software is increasingly autonomous, and AI Security Engineering is becoming an essential discipline.

Join this course to develop the knowledge, hands-on experience, and security mindset needed to build more trustworthy AI Agents, MCP Integrations, and Enterprise Agentic AI Systems.

Build AI agents. Understand the threats. Implement defenses. Secure the future of Agentic AI.

Who this course is for:

  • AI Engineers and LLM Developers who want to build secure AI agents and MCP integrations.
  • Cybersecurity Professionals interested in emerging AI security threats, vulnerabilities, and defensive techniques.
  • DevSecOps Engineers looking to integrate security controls into AI-powered development workflows.
  • Python and Backend Developers building AI applications, MCP servers, and tool-enabled autonomous systems.
  • Security Architects and Enterprise Architects designing secure, scalable agentic AI infrastructure.
  • AI Red Teamers and Penetration Testers exploring prompt injection, tool poisoning, and authorized AI security testing.
  • Cloud Security Engineers responsible for securing AI workloads, APIs, containers, and enterprise integrations.
  • AI Governance and Risk Professionals seeking practical knowledge of AI security controls and risk management.
  • Technical Leads and Solution Architects responsible for deploying secure enterprise AI agent solutions.
  • Technology Professionals and Students interested in developing practical skills in AI agent security, MCP security, and emerging AI cybersecurity technologies.