
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.
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.
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.
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.
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.
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.
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.
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.
What exactly is an AI agent? This lecture defines agents, autonomous workflows, and agentic AI, so that you share a precise vocabulary for the security discussions that follow.
We begin with a simple chatbot, which receives a message and produces a reply. An AI agent goes further. It pursues a goal by repeatedly deciding what to do next, using tools to observe or change the world, and incorporating the results into its next decision. The language model acts as the reasoning engine, while tools provide the ability to act.
Next, we describe autonomous workflows. Some are tightly scripted, with the model filling in small steps. Others are open-ended, with the model choosing among many tools over many iterations. The more freedom the model has, the more useful and the more risky the system becomes. We also introduce agentic AI as the broader pattern of systems composed of one or more agents, memory, tools, and orchestration.
You will see the core components: instructions, context, memory, tools, an execution loop, and an identity with permissions. Each component is also a security consideration, since each can be influenced, misconfigured, or abused.
By the end of this lecture you will be able to describe how agents differ from simple model calls and identify the parts that need protection.
To secure an agent, you must understand how it decides what to do. This lecture explains how AI agents plan, reason, and execute actions in a loop.
We begin with the basic cycle. The agent receives a goal and context, the model proposes a next step, often as a tool call with arguments, the system executes that call, and the result is added to the context. The model then decides whether the goal is achieved or another step is needed. This continues until a stopping condition is reached.
We discuss planning approaches. Some agents produce a full plan first and then follow it, while others decide one step at a time. Some use explicit reasoning text, and others rely on structured tool-calling interfaces. We describe common patterns such as reflection, retries, and delegation to other agents.
From a security perspective, we highlight key observations. Every tool result becomes part of the model's context and may influence later steps. Plans can drift from the user's intent. Errors can cascade across steps. Loops can run long and consume resources. The model's reasoning cannot be treated as a trustworthy security decision.
This leads to a principle you will use throughout the course: the model proposes, but deterministic code disposes. Policy checks, permissions, and approvals must be enforced outside the model. By the end of this lecture you will understand the loop and where controls belong.
The Model Context Protocol has quickly become a common way to connect AI applications with tools and data, and this lecture introduces what it is and why it matters for security.
We begin with the problem MCP addresses. Before a shared standard, each application needed custom code to connect each model to each tool or data source, which led to many one-off integrations. MCP defines a common way for an AI application to discover and use capabilities offered by separate servers, so tools can be reused across applications.
You will learn the basic idea. An MCP server exposes capabilities such as tools, which perform actions, resources, which provide data, and prompts, which provide reusable templates. A client inside an AI application connects to servers, lists what they offer, and lets the model request tool calls. Messages follow a defined structure, which makes integrations consistent and easier to build.
We discuss why this matters for security. A standard makes it easy to add many tools quickly, which can expand the attack surface just as quickly. Each server is effectively a new component with its own code, credentials, and trust level. Users may install servers from many sources.
We also preview the main themes you will study: authentication, authorization, tool integrity, input validation, isolation, and supply chain trust. By the end of this lecture you will understand MCP's purpose and why careful design is essential.
MCP has a specific architecture with named roles, and understanding it precisely is necessary for analyzing where threats and controls belong. This lecture explains hosts, clients, servers, tools, resources, and prompts.
The host is the application that the user interacts with, such as a chat interface or an agent runtime. It manages the model, the user's session, and one or more MCP clients. Each client maintains a connection to a single server and handles the protocol messages. The server is a program that exposes capabilities to clients.
Servers offer three main primitives. Tools are functions that the model can request to be called, such as searching documents or creating a ticket. Each tool has a name, a description, and an input schema. Resources are data items identified by addresses, such as files or database records, that can be read to provide context. Prompts are predefined templates that guide interactions.
We trace a typical interaction: the client discovers the server's capabilities, the host presents tool definitions to the model, the model requests a call, the host asks the client to execute it, the server runs the function, and the result returns to the model.
For each element, we note security relevance. Tool descriptions influence the model, schemas validate inputs, resources may carry untrusted content, and the host decides what to approve. By the end of this lecture you will be able to name each part and discuss it precisely.
Tools are the way an agent acts, and this lecture explains how MCP handles tool discovery, input schemas, and tool execution, along with the security implications of each step.
We begin with discovery. A client asks a server to list its tools, and the server returns definitions containing a name, a human-readable description, and a schema describing the expected inputs. The host passes these definitions to the model, which uses the descriptions to decide when a tool is appropriate. Because the model reads these descriptions as text, they are an influence channel, and a manipulated description can steer behavior.
Next, we discuss input schemas. A schema defines argument names, types, constraints, and required fields. Schemas help the model produce well-formed calls, but they must also be enforced by the server, since a model or a client can send unexpected values. Validation should check types, ranges, lengths, formats, and allowed values, and it should reject anything else.
Then we cover execution. When the model requests a call, the host decides whether to run it, possibly after user approval, and the server performs the action and returns results, including errors. We discuss how results flow back into the context and why they must be treated as untrusted data.
By the end of this lecture you will understand the lifecycle of a tool call and the points where validation, approval, and logging should occur.
MCP messages must travel between clients and servers, and this lecture explains the two main transports, standard input and output, and streamable HTTP, and how their security properties differ.
We begin with standard input and output, often called stdio. In this mode, the host launches the server as a local child process and exchanges messages through the process's input and output streams. It is simple, has no network exposure, and works well for local tools. The security considerations are different, however. The server runs with the permissions of the user who launched it, so a malicious or buggy server can access local files, environment variables, and other resources. Choosing and verifying the server's code becomes critical, and isolation through containers or restricted accounts is valuable.
Next, we cover streamable HTTP. Here the server runs as a network service, and clients connect over HTTP, potentially across machines. This enables shared servers, remote integrations, and centralized management. It also brings the familiar web concerns: transport encryption, authentication, authorization, origin validation, protection against cross-site request attacks, binding to the right network interfaces, and rate limiting.
We compare the transports by deployment model, trust assumptions, and controls required. By the end of this lecture you will be able to choose an appropriate transport for a scenario and apply the matching safeguards.
A trust boundary is a line where data or control passes between components with different levels of trust, and this lecture teaches you to find them in agent systems.
We begin with the idea. Within one trusted component, you can assume code behaves as written. When data crosses into another component, especially one controlled by someone else, you must validate it and limit what it can influence. Most security failures occur when data or authority crosses a boundary without checks.
In an agent system, there are many boundaries. The user to the agent. The agent to the language model, which is not a deterministic or fully trustworthy decision maker. The model to the tools. The tools to backend systems and databases. The agent to external content such as websites, files, and emails. One agent to another. The host to third-party MCP servers. Each boundary raises questions: who authenticated this request, what are they allowed to do, and what content is untrusted?
A key insight is that text returned from tools and documents is data from an untrusted source, but it enters the same context as the user's instructions, which blurs the boundary. We discuss design patterns that restore it, including separation of privileges, validation, and approval.
By the end of this lecture you will be able to identify trust boundaries in an architecture and decide where to place controls.
In this hands-on exercise you will map a complete AI agent and MCP architecture with its trust boundaries, creating a diagram that guides your security work in later sections.
Begin with the sample ecosystem from the lab package. List every component: the user interface, the agent runtime, the language model, each MCP client and server, the API, the database, the file stores, and any external services. For each, note who controls it and how much you trust it.
Next, draw the data flows. Show how a request travels from the user through the agent to the model and tools, and how results travel back. Label each flow with the kind of data it carries, such as instructions, user data, documents, credentials, or tool outputs. Mark which flows involve untrusted content, such as retrieved documents or responses from external services.
Then add trust boundaries as dashed lines around components with the same level of trust. Number each boundary crossing and write a short note about what should be checked there, for example authentication, input validation, authorization, output filtering, approval, or logging.
Finally, identify the three boundary crossings that concern you most and explain why. Save the diagram in your lab folder. You will use it as the foundation for the threat model that you build later in the course.
Before installing anything, it helps to understand the whole technology stack of the lab. This lecture describes each component, why it was chosen, and how the pieces fit together.
We begin with Python, the language used for the agent, the MCP servers, and test scripts. Git tracks changes to your lab work. Docker provides isolated, repeatable environments and is essential for sandboxing in later sections. Ollama runs open-source language models locally, so that you do not need paid services or external accounts, and so that lab data never leaves your computer.
Next, we cover the MCP Python SDK, which you will use to build servers and clients, and MCP Inspector, a visual tool for connecting to servers, viewing their tools, and sending test calls. FastAPI provides a small web application that represents a business system, and SQLite provides a lightweight database filled with synthetic records.
We also preview supporting tools introduced later, including libraries for authentication, scanning tools for dependencies, and logging and dashboard components.
We discuss system requirements, such as memory and disk space for local models, and trade-offs in choosing smaller models for faster responses. We also explain how the lab is organized into folders and Compose services. By the end of this lecture you will understand the technology stack, the reasons behind each choice, and what to prepare before setup.
In this lecture you will install the development tools that the rest of the lab depends on: Python, Git, Docker, and a code editor.
We begin with Python. You will check whether a suitable version is already installed, install one if needed, and create a virtual environment for the course. We explain why virtual environments keep dependencies separate and how to activate them on each operating system. You will also learn to install packages with pip and record them in a requirements file.
Next, we install Git, configure your name and email, and create a repository for your lab work. We show basic commands for checking status, committing changes, and viewing history, which will help you track the effect of each security change.
Then we install Docker. We discuss Docker Desktop or Docker Engine depending on your platform, adjusting memory and processor limits, and verifying the installation by running a small test container. We explain images, containers, and Compose in simple terms, since you will use them for isolation later.
Finally, we recommend a code editor with Python support, helpful extensions, and a terminal. We cover a verification checklist that confirms each tool is working. By the end of this lecture your computer will be ready for the model, SDK, and application setup in the next lessons.
Running a language model locally keeps lab data private and removes the need for paid services, and this lecture shows how to install and configure Ollama for that purpose.
We begin with what Ollama does. It downloads and serves open-source language models on your computer and exposes a local interface that applications can call. Because everything runs locally, you can experiment safely without sending prompts or synthetic data to any external provider.
You will learn how to install Ollama on your operating system and verify that the service is running. We discuss choosing a model. Smaller models run faster and require less memory but may be less capable at following instructions and calling tools, while larger models are more capable and need more resources. We recommend a model that supports tool calling and fits your hardware, and we show how to pull it and test it from the command line.
Next, we send a simple request through the local interface and examine the response, so you know how the agent application will talk to the model later. We also cover useful settings, such as the context size and the generation temperature, and explain why lower temperatures give more consistent behavior for testing.
Finally, we troubleshoot common problems such as insufficient memory and slow first responses. By the end of this lecture you will have a working local model ready for your agent.
To build and test MCP servers, you need the right libraries and inspection tools. In this lecture you will set up the MCP Python SDK and MCP Inspector.
We begin with the SDK. Inside your virtual environment, you will install the official Python package for MCP and confirm its version. We review the main concepts it provides: creating a server object, registering tools, resources, and prompts with decorators, and running the server over a chosen transport. We also look at the client side of the SDK, which the agent will use to connect to servers.
Next, we introduce MCP Inspector, a developer tool that provides a browser interface for connecting to an MCP server, listing its tools and resources, and calling them with test inputs. This is invaluable for debugging and for security testing, because you can see exactly what a server advertises and how it responds, independent of any language model.
You will create a minimal test server, start it, and connect Inspector to it. You will view the tool definitions, call a tool with valid and invalid input, and inspect the raw messages.
We also mention keeping Inspector bound to your local machine and not exposing it to a network, since it is a powerful debugging interface. By the end of this lecture you will have the tools you need to build and examine MCP servers.
Your lab needs a business system for the agent to work with, and this lecture shows you how to create a FastAPI application and a local test database to play that role.
We begin with the design. The application represents a small enterprise back office that stores employees, support tickets, and internal documents. FastAPI provides a simple, modern way to define web endpoints in Python, with automatic validation and generated documentation. SQLite stores the data in a single local file, which keeps setup simple.
You will create the project structure, define the database tables, and write a script that fills them with synthetic records, including fake names, tickets, and department information. We emphasize that no real personal or company data is used anywhere in the lab. Next, you will write several API endpoints for listing and retrieving tickets, searching documents, and creating records, and run the application locally.
You will test the endpoints using the automatic documentation page and a command-line client. We explain the intentionally simple design, including the lack of authentication at this stage, and note that the application is bound only to your own computer. Later sections will add authentication, authorization, and monitoring.
By the end of this lecture you will have a working API and database that the agent and MCP servers can use as realistic targets for security exercises.
Safe security practice requires a safe place to practice, and this lecture explains how to build an isolated security playground filled with synthetic data.
We begin with isolation goals. Experiments should not touch your real files, accounts, or network resources, and any mistakes should be easy to undo. You will use Docker networks and Compose to run lab components in containers that are separated from the rest of your system, with ports published only to your own machine.
Next, we cover synthetic data. You will generate realistic but fake records that include sample employee details, ticket text, documents, and placeholder credentials that resemble real formats but are not valid anywhere. Using fake values lets you practice detecting and preventing leaks without any real exposure. We also mark certain records as sensitive, such as fake personal information and fake secrets, so that later exercises can test classification and redaction.
We discuss resetting the environment: using volumes and scripts to restore the database to a known state, and using Git to restore configuration. A repeatable reset makes experiments safe and comparisons fair.
Finally, we set simple rules for the playground, such as no real credentials, no real data, no connection to production services, and clear logging of what runs. By the end of this lecture you will have a controlled environment where you can test attacks and defenses responsibly.
In this hands-on exercise you will launch and validate the complete AI agent security laboratory, confirming that every component is installed, connected, and ready for the exercises ahead.
Begin by starting the Docker Compose stack, which brings up the API, the database, and supporting services. Check each container's status and read the logs for errors. Confirm that the API responds and that the database contains the synthetic records.
Next, verify the local model. Make sure the Ollama service is running, that your chosen model is available, and that a test prompt returns a sensible response. Then start the sample MCP server and connect to it with MCP Inspector. List its tools, call one with valid input, and view the result.
Now test the end-to-end path. Run the starter agent with a simple request, such as looking up a ticket, and observe the model deciding to call a tool, the server executing it, and the result returning to the agent. Review the logs to see each step.
Finally, create a validation checklist covering tools installed, services running, model working, MCP connection successful, API reachable, and data reset script tested. Resolve any failures and save the checklist. Take a Git snapshot of the working lab, so you can return to a known good state at any time.
Before writing code, a good engineer designs the system, and this lecture shows how to design a practical enterprise AI agent that you will build and later secure.
We begin with the business need. The SecureOps company wants an internal service desk assistant that helps employees find policy information, check ticket status, create new tickets, and look up basic directory details. We turn this need into requirements: what the agent should do, what it should never do, which users it serves, and which systems it touches.
Next, we define the agent's capabilities as a small set of tools. A knowledge search tool retrieves internal documents. A ticket lookup tool reads ticket records. A ticket creation tool writes a new ticket. A directory tool returns limited employee information. For each tool, we record inputs, outputs, data sensitivity, and whether it only reads or also changes data. This inventory becomes the basis for later permission design.
We also discuss design choices that affect security from the start: keeping the agent's scope narrow, separating read and write tools, planning for logging, deciding where human approval might be needed, and thinking about identity, meaning on whose behalf the agent acts.
Finally, we sketch the architecture and the interaction flow. By the end of this lecture you will have a clear specification for a useful agent and a list of design decisions that you will revisit when you add protections.
In this lecture you will create your first AI agent using a local language model, building the core loop that turns a model into an actor.
We begin with the components you need: a client for the local model served by Ollama, a system prompt that describes the agent's role, a conversation history, and a loop that sends messages to the model and processes the response. We choose a model that supports tool calling, so the model can return a structured request when it wants to use a tool.
You will write a small Python program that connects to the model, sends a user request along with instructions, and prints the reply. Then you will extend it with a loop that checks whether the model asked to call a tool, runs the requested function, appends the result to the conversation, and asks the model to continue. We add a maximum number of iterations to prevent endless loops, which is your first safety control.
We also cover basic configuration: model name, temperature, and timeouts, and storing settings in a configuration file rather than in code. We run the agent with a simple question and trace the messages exchanged.
By the end of this lecture you will have a working, minimal agent and a clear understanding of the cycle that the rest of the course will protect and monitor.
An agent's behavior is shaped by its instructions, its context, and the tool calls it makes, and this lecture explains how each works and why each matters for security.
We begin with instructions. The system prompt describes the agent's role, tone, rules, and limits. Good instructions improve behavior, but they are guidance to the model, not enforcement. A model can ignore or misread instructions, especially when confronted with conflicting text, so critical rules must also be enforced in code.
Next, we discuss context. The context window contains the system prompt, the user's messages, previous tool results, retrieved documents, and any memory. Everything in the context can influence the next decision, including content from untrusted sources. We discuss context size limits, what happens when the window fills, and why careful selection of what enters the context improves both quality and safety.
Then we examine tool calls. The model produces a structured request containing a tool name and arguments. Your code must validate that the tool exists, that the arguments match the schema, and that the call is permitted before running it. The result is returned to the model as new context.
We demonstrate these ideas with short examples and show how to print the full message sequence for debugging. By the end of this lecture you will understand how instructions, context, and calls combine to determine behavior.
An agent becomes useful when it can act, and this lecture shows how to connect it to Python functions and business APIs through well-defined tools.
We begin with the simplest tools: ordinary Python functions. You will write functions for searching tickets, retrieving a ticket by identifier, and creating a ticket. For each, we define a clear name, a precise description that tells the model when to use it, and a schema that lists parameters with types and constraints. Good descriptions and schemas help the model choose and call tools correctly.
Next, you will connect the functions to the FastAPI business application. Instead of reading the database directly, each tool calls an API endpoint using an HTTP client. This mirrors real enterprise integration and creates a clean boundary where authentication and authorization can later be added.
We cover error handling. Tools should return clear, structured errors rather than raw exceptions, and should avoid revealing internal details such as stack traces or file paths. We also add input validation inside each function, since the model's arguments must never be trusted blindly.
Finally, we register the tools with the agent, run requests that need one or several tools, and observe the results. By the end of this lecture your agent will be able to perform real operations against the lab system, ready for protection in later sections.
Many enterprise agents answer questions from internal documents, and this lecture shows how to build a knowledge retrieval tool for that purpose.
We begin with the idea of retrieval. Instead of asking the model to remember company policies, the agent searches a document collection for relevant passages and includes them in its context, so its answer is grounded in actual text. This improves accuracy and keeps information current.
You will prepare a small set of synthetic internal documents, such as an IT acceptable use policy, a travel policy, and a password guidelines document. We split the documents into passages, store them in a simple searchable form, and write a search function that returns the most relevant passages for a query, together with their source names.
Next, you will expose the function as a tool, with a schema that accepts a query and a limit on the number of results. The tool returns passages with citations, so users can verify the source. We discuss how to keep results short enough to fit in the context.
We also highlight a security point that returns later in the course: retrieved documents are content from a data source, and their text enters the model's context. If a document contains misleading or manipulative text, it can influence the agent. For now, we simply note this and design the tool so that it clearly labels retrieved content.
By the end of this lecture you will have a working knowledge tool.
Real tasks usually require several steps, and this lecture shows how to implement multi-step agent workflows that combine tools to complete a goal.
We begin with an example request: an employee asks the agent to find the password policy, check whether they already have an open ticket about account access, and create a ticket if none exists. This needs a search, a lookup, a decision, and a possible write, executed in sequence.
You will see how the agent loop handles this naturally. The model calls the knowledge tool, receives passages, calls the ticket search tool, receives results, reasons about them, and then decides whether to call the creation tool. We discuss how to keep the conversation state organized, how to limit the number of steps, and how to stop when the goal is met.
We also explore design choices. Some workflows benefit from explicit structure, for example a fixed sequence with the model filling in details, because it is easier to test and secure. Others rely on flexible planning, which is powerful but harder to predict. We discuss choosing the least flexible design that satisfies the need.
We add safeguards: a maximum step count, a total time limit, detection of repeated identical calls, and a clear final answer format. We also discuss how mistakes in early steps can propagate to later ones. By the end of this lecture you will be able to build and reason about multi-step workflows.
You cannot secure or debug what you cannot see, and this lecture shows how to add basic tool execution logging and error handling to your agent.
We begin with logging. For every tool call, record the time, a unique request identifier, the tool name, the arguments, the outcome, and the duration. Include the user or session associated with the request, even if that is only a placeholder at this stage. Write logs in a structured format such as JSON, so that they can be searched and analyzed later. We discuss what not to log, including secrets, full document contents, and sensitive personal data, and how to redact or truncate values.
Next, we cover error handling. Tools can fail because of invalid input, network problems, timeouts, or backend errors. The agent should handle failures gracefully: return a clear and safe error message to the model, avoid exposing internal details, retry only when appropriate, and give up after a limit. Unhandled exceptions should not crash the agent or leak stack traces.
We also add timeouts for model calls and tool calls, so a stuck dependency cannot hang the system, and we record which step failed and why.
Finally, we run several normal and failing requests and review the logs. By the end of this lecture you will have a foundation of visibility that later sections extend into full audit logging and monitoring.
In this hands-on exercise you will build a working enterprise service desk AI agent that combines the knowledge, ticket, and directory tools into one assistant.
Begin with the specification you wrote earlier. Create the agent project structure, with separate modules for configuration, the model client, tools, the agent loop, and logging. Write the system prompt describing the assistant's role and the boundaries of its tasks.
Next, implement the tools. Connect the knowledge search tool to your synthetic documents, the ticket lookup and creation tools to the FastAPI service, and a directory tool that returns limited information. Add input validation, clear descriptions, schemas, and structured errors to each tool. Register them with the agent.
Then add the control features from this section: a maximum step count, timeouts, repeated-call detection, and structured logging of every tool call. Run a series of tests with realistic requests, such as asking about a policy, checking ticket status, creating a ticket, and handling a request that needs several steps. Also test some failure cases, such as a missing ticket and an invalid argument.
Finally, review the logs, record the agent's behavior in a short report, and note which parts currently lack protections, such as authentication and approval. Save the project in Git, because you will build on it throughout the rest of the course.
MCP separates tools from the agent by placing them in servers, and this lecture explains how MCP server development works and how tools are exposed to clients.
We begin with the shift in design. In earlier lessons, tools were Python functions inside the agent. With MCP, they live in an independent server process that advertises its tools through a standard protocol. Any compliant client can discover and call them, which allows reuse across applications and teams, and makes it possible to manage tools separately from agents.
You will learn the structure of a server. It has a name and version, a set of registered tools with schemas and descriptions, optional resources and prompts, and a transport that carries messages. The server handles requests to list capabilities and to execute a tool, and it returns results or errors in a defined format.
We discuss design guidelines. Keep each server focused on one domain. Give tools clear names and honest descriptions. Use precise input schemas and validate every argument. Return only the information the client needs. Avoid hidden side effects, and make read and write operations separate tools so that permissions can differ.
We also introduce the security perspective: every tool you expose is a capability that someone, or some model, may invoke in ways you did not expect. By the end of this lecture you will understand how MCP servers are structured and the principles for exposing tools responsibly.
In this lecture you will create your first MCP server using Python, going from an empty file to a running server that a client can use.
We begin by creating a project and importing the MCP Python SDK. You will instantiate a server object with a name, then define a simple tool using a decorator. The first tool might return the current server status or perform a simple calculation, with a type-annotated function signature and a docstring that becomes the tool's description. We explain how the SDK derives the input schema from the function's type hints, and why accurate hints produce accurate schemas.
Next, you will choose a transport. For local development, you will run the server over standard input and output, and connect to it using MCP Inspector to list the tool and call it. You will also run it over streamable HTTP and observe how it listens on a local address and port.
We discuss running the server safely. Bind network transports to the local loopback address only, avoid enabling debug features that reveal details, and keep logging free of sensitive data.
We finish by connecting your agent as a client, discovering the tool, and letting the model call it. By the end of this lecture you will have created, run, tested, and integrated a working MCP server.
Input validation is a core security control for tools, and this lecture shows how to implement MCP tools with carefully validated input schemas.
We begin with why validation matters. The arguments for a tool call are generated by a model, which may be influenced by untrusted content or may simply make mistakes. A tool that trusts its inputs can be pushed into unintended behavior, such as reading the wrong record, returning too much data, or constructing unsafe queries. Validation is the server's responsibility, regardless of what the client or model does.
You will learn to define strict schemas. Specify the type of each field, whether it is required, minimum and maximum values, string length limits, allowed patterns, and enumerated lists of permitted values. Use identifiers with restricted formats instead of free text where possible. Reject unknown fields and return clear error messages for invalid input.
Next, we discuss using validation libraries to enforce schemas inside the tool, in addition to the declared schema. We cover safe handling of values passed to databases, using parameterized queries and never assembling queries by concatenating strings, and limiting result sizes and pagination to prevent bulk data retrieval.
We test the tool with valid inputs, boundary values, wrong types, and oversized strings, and confirm that bad inputs are rejected. By the end of this lecture you will be able to design tools that fail safely.
In this lecture you will build an MCP server for enterprise document retrieval, moving the knowledge search capability from the agent into a reusable server.
We begin with the design. The server exposes a search tool that accepts a query and a limit, and a tool that retrieves a specific document by identifier. It might also expose documents as resources, so that clients can read them directly. We decide what metadata each result includes, such as the title, source, and classification label, and which fields should be omitted.
You will implement the server using the Python SDK. Load the synthetic documents, build a simple search index, and write the tool functions with validated inputs, result limits, and consistent output structure. Each result includes a clear marker that it is retrieved content, which helps downstream components handle it as data and not as instructions.
We discuss practical safeguards: restricting the server to a specific document directory, preventing path traversal by using identifiers rather than file paths, limiting passage length, and logging each request with a request identifier.
Next, you will test the server with MCP Inspector, trying normal searches, empty queries, long queries, and invalid identifiers. Then you will connect it to the agent and confirm that answers cite their sources.
By the end of this lecture you will have a focused document retrieval server ready for integration and later hardening.
In this lecture you will build an MCP server that handles support tickets and database operations, which introduces tools that change data and therefore carry greater risk.
We begin by defining the tools. A read tool searches and retrieves tickets by identifier, status, or requester. A write tool creates a ticket with a title, description, and priority. Another write tool adds a comment or updates the status. We keep read and write operations as separate tools, so that permissions and approvals can be applied differently.
You will implement the server on top of the SQLite database or the FastAPI service. We use parameterized queries exclusively, so that arguments are always treated as data. We validate all inputs, limit the number of records returned, and return only the fields required. For write tools, we record who requested the change and when, even though real identity checks are added later.
We discuss transaction handling and idempotency. If the same create request is sent twice because of a retry, the system should avoid duplicate tickets, for example by using a client-provided request key. We also cover clear error messages that do not reveal database structure.
Finally, we test with MCP Inspector, check database contents after each operation, and review logs. We also note which tools are high risk and need stronger controls in later sections. By the end of this lecture you will have a working server with both read and write capabilities.
Real agents often use several MCP servers at once, and this lecture shows how to connect multiple servers to one agent and manage what results.
We begin with the architecture. The host application creates one MCP client for each server. At startup, each client connects, performs initialization, and lists the server's tools, resources, and prompts. The host merges these into a combined catalog that is presented to the model. When the model requests a tool call, the host routes it to the right client and server.
You will learn to handle naming. Different servers may offer tools with the same or similar names, which can cause confusion or be abused. A good practice is to namespace tools with their server name, and to keep an explicit mapping between each tool and its source. We discuss how the model sees the combined list and why a large catalog can reduce accuracy and increase risk.
Next, we cover configuration. Define servers in a configuration file with their commands or addresses, and keep this file under version control. Control which tools are exposed to the model for each task, rather than exposing everything by default.
We also discuss failure handling, such as a server that does not start or stops responding, and how the agent should degrade gracefully. By the end of this lecture you will be able to assemble a multi-server agent and understand the trust implications of each connection.
MCP Inspector lets you examine and test servers independently of any language model, and this lecture shows how to use it to verify your tools thoroughly.
We begin with launching Inspector and connecting it to a server, using either standard input and output or streamable HTTP. Once connected, you can see the server's information, capabilities, tools, resources, and prompts. For each tool, you can view the name, description, and input schema exactly as a client would receive them.
You will learn how to call tools manually. Fill in the arguments, run the call, and inspect the full response, including content, errors, and timing. Test valid cases to confirm correct behavior, then try boundary and invalid inputs to see how validation works. Check that error messages are helpful without revealing sensitive details, and that large results are limited.
We also use Inspector to review message history, which shows the raw protocol exchanges. This helps you understand initialization, capability negotiation, and the structure of requests and results. It is also useful for spotting unexpected fields or descriptions that contain odd instructions.
We discuss safe use. Run Inspector locally, avoid exposing it on a network, and do not connect it to untrusted servers without isolation. By the end of this lecture you will be able to use Inspector as a routine part of building, testing, and reviewing MCP servers.
In this hands-on exercise you will create and integrate three MCP servers into the enterprise agent, producing the multi-server system that later sections will analyze and secure.
Begin with the three servers you have designed: a document retrieval server, a ticket and database operations server, and a directory server that returns limited employee information. Review each server's tools, schemas, and descriptions, and confirm that each is focused on a single domain. Complete any missing pieces, adding input validation, result limits, and structured logging to each.
Next, test each server independently using MCP Inspector. Call every tool with valid, boundary, and invalid inputs, and record the results in a simple test table. Fix any issues you find before integrating.
Then update the agent configuration to connect to all three servers. Namespace the tools, verify that the combined catalog appears correctly, and run realistic requests that need tools from more than one server, such as finding a policy and then opening a related ticket. Review the logs to follow each request through the host, client, server, and backend.
Finally, document the architecture, listing servers, tools, read or write behavior, and data touched. Commit your work to Git. This inventory becomes the starting point for the threat modeling exercise in the next section.
Now that you have built an agent and several servers, it is time to think like a defender about what could go wrong. This lecture introduces the AI agent threat landscape.
We begin with the unique features that shape threats. Agents interpret natural language, decide actions at runtime, hold credentials, and connect to tools and data. Attackers do not need to compromise a server if they can influence what the agent reads or does. We organize threats by where they enter: through user input, through retrieved content, through tool descriptions and responses, through compromised components, and through weaknesses in identity and infrastructure.
Next, we describe the main threat families at a conceptual level. Manipulation of instructions can redirect an agent's goals. Malicious or altered tools can mislead the agent. Weak identity controls can let one user access another's data or let the agent act with more authority than intended. Over-broad permissions enlarge the damage of any error. Sensitive information may leak through outputs, logs, or tool calls. Unsafe execution may affect the host or network. Dependencies and third-party servers may carry hidden risks. Multi-agent systems add impersonation and persistent poisoning of memory.
We also discuss attacker goals, such as data theft, unauthorized actions, service disruption, and persistence, and defender goals, such as limiting impact and detecting misuse.
By the end of this lecture you will have a structured view of threats that you will apply in later sections.
The OWASP Top 10 for Agentic Applications is a community-driven framework for the most important risks in agent systems, and this lecture introduces it as a shared language for discussing and prioritizing them.
We begin with the purpose of the list. Security teams need a common vocabulary to describe risks, compare systems, and communicate with developers and leadership. OWASP has a long history of providing such guidance for web applications and large language model applications, and its agentic guidance extends the approach to autonomous systems that plan and act.
We walk through the categories at a high level. They cover themes such as goal and instruction manipulation, misuse of tools, identity and privilege abuse, weaknesses in memory and context, insecure communication between agents, unexpected code execution, supply chain compromise, cascading failures, overreliance by humans, and rogue or unmonitored agents. For each, we explain the risk in plain language, give a simple example scenario, and name the types of mitigations that apply.
We connect each category to the sections of this course where you build and test the corresponding defenses. This helps you see the whole curriculum as a systematic response to the framework.
Finally, we discuss how to use the list in practice, including threat modeling workshops, design reviews, test planning, and reporting. By the end of this lecture you will be able to describe each risk category and map it to controls.
Threat modeling turns general knowledge into specific findings about your system, and this lecture shows how to model threats on agent-to-tool and tool-to-system interactions.
We begin with a simple method. Describe the system with a diagram that shows components, data flows, and trust boundaries. For each element and each flow, ask what could go wrong using a structured checklist such as STRIDE, which considers spoofing, tampering, repudiation, information disclosure, denial of service, and elevation of privilege. Then add agent-specific questions: what if the model is manipulated, what if the content is hostile, what if the tool lies?
We apply this to the agent-to-tool boundary. Could a tool be impersonated? Could arguments be manipulated to read other users' data? Could tool descriptions or results mislead the model? Could an unapproved action be triggered? For the tool-to-system boundary, we ask whether the tool uses excessive credentials, whether queries can be abused, whether outputs reveal too much, and whether actions are logged.
For each threat, you record the scenario, affected asset, likelihood, impact, existing controls, and recommended mitigations. We show how to organize results in a threat register that can be tracked and updated.
By the end of this lecture you will be able to run a focused, structured threat modeling session on agent tool interactions.
MCP clients and servers each present their own attack surface, and this lecture shows how to identify weaknesses in both.
We begin with the server side. Servers receive requests, parse arguments, access backend systems, and return results. Their attack surface includes input handling, authentication and authorization, secrets stored in configuration, file system and network access, dependencies, logging, and the descriptions they advertise. A server that exposes powerful capabilities with weak checks can be abused by any client that reaches it, including a compromised or manipulated agent.
Next, we turn to the client and host side. Clients decide which servers to trust, process tool definitions and results, and present information to the model and the user. Their attack surface includes server configuration files, handling of untrusted descriptions, approval prompts that may be unclear or too frequent, storage of tokens, handling of server-initiated requests, and the way results are inserted into context.
We also discuss the transport. Local standard input and output connections inherit local privileges, while network connections raise questions of encryption, origin checks, binding addresses, and exposure to other users or sites.
You will practice by examining your lab servers and listing entry points, assets, and trust assumptions for each. By the end of this lecture you will be able to enumerate attack surfaces systematically and prepare them for risk analysis.
Who is the agent acting for, and with whose authority? This lecture explores agent identity, delegated authority, and the confused deputy problem, which is one of the most important concepts in agent security.
We begin with identity. An agent may have its own identity, such as a service account, or it may act on behalf of a user. Tools and backend systems need to know which identity is making a request so that they can apply the correct permissions and record accountability. Many early agent designs use a single shared credential for all users, which erases this distinction.
Next, we explain delegation. When a user asks an agent to perform a task, the agent receives some authority from that user. Good designs pass along limited, traceable credentials that never exceed what the user may do. Poor designs give the agent broad standing access that exceeds any individual user's rights.
This leads to the confused deputy problem. A deputy is a component with more authority than the party making a request. If an attacker can persuade the deputy to act on their behalf, the deputy's authority is misused. An agent with broad access that follows instructions from untrusted content is a classic example.
We discuss mitigations: per-user identity propagation, narrow scopes, checking authorization at the resource, and approvals for sensitive actions. By the end of this lecture you will recognize and prevent these failures.
Not all risks deserve equal attention, and this lecture shows how to prioritize them using likelihood, impact, and blast radius.
We begin with likelihood. Consider how easy an issue is to trigger, what access or skill is required, whether the entry point is exposed to untrusted content or users, and whether existing controls reduce the chance. A weakness that can be reached through any document the agent reads is more likely to be triggered than one requiring administrator access.
Next, we discuss impact. Consider the sensitivity of the data involved, the severity of possible actions, financial or operational consequences, regulatory implications, and harm to people. An agent that can read public documentation has limited impact, while one that can modify records or send messages has more.
Then we introduce blast radius, which is how far the damage can spread if something goes wrong. It depends on the permissions of the agent, whether tenants and users are isolated, whether credentials are shared, and what the agent can reach on the network. Reducing blast radius is often the most effective strategy, because it limits harm even when prevention fails.
We combine these factors into a simple scoring approach, such as a matrix with ratings, and discuss recording rationale. We also cover deciding whether to mitigate, accept, transfer, or avoid each risk. By the end of this lecture you will be able to rank risks and justify priorities.
In this hands-on exercise you will create a threat model and risk register for the lab application, applying the methods from this section to the system you built.
Begin with your architecture diagram and the inventory of agents, servers, tools, and data flows. Update the diagram so that all components and trust boundaries are shown clearly. Mark the entry points for untrusted content, the tools that change data, and the places where credentials are used.
Next, run a structured analysis. For each boundary crossing and each tool, apply the STRIDE categories and the agent-specific questions you have learned. Use the OWASP agentic categories as a checklist to make sure that you have not missed a theme, such as identity abuse, tool misuse, memory risks, or supply chain exposure. Write each threat as a short scenario in plain language.
Then build the risk register as a table. For every threat, include an identifier, description, affected asset, likelihood, impact, blast radius, overall priority, current controls, and a proposed mitigation with the course section where you will implement it. Sort the register by priority and highlight the top five.
Finally, review your work with a critical eye, add any overlooked items, and save the document under version control. You will update it as you implement defenses, recording which risks are reduced and how you verified each improvement.
Prompt injection is the best-known attack against language model applications, and this lecture explains the difference between direct and indirect forms and why both matter for agents.
We begin with the root cause. A language model receives instructions and data together as text, and it has no reliable built-in way to distinguish a command from the developer or user from words that merely appear in the content it reads. An attacker exploits this by crafting text that the model treats as instructions.
In direct prompt injection, the attacker is the user, or controls the user's input, and writes text intended to override the system's rules, such as asking the model to ignore earlier instructions. This is often what people picture first, and it matters most when users should not be trusted with the model's full capabilities.
In indirect prompt injection, the attacker does not talk to the agent at all. Instead, they place instructions in content that the agent will later read, such as a web page, an email, a shared document, a ticket comment, or a tool response. When the agent retrieves that content, the hidden text enters its context and may influence its next actions. For agents with tools, this is especially serious because the result may be an action, not just a misleading answer.
We discuss why impact depends on the agent's permissions, and why defenses must limit what a manipulated agent can do. By the end of this lecture you will be able to explain both forms clearly.
Every agent reads content from sources it does not control, and this lecture explains how untrusted content crosses trust boundaries and what that means for design.
We begin by listing the channels. Users type requests. Retrieval systems return documents. Web fetch tools return pages. Email and chat tools return messages. Ticket systems return comments written by many people. Tool servers return results and descriptions. Even a database field may contain text entered by an outsider. In each case, the agent places the text into its context window next to trusted instructions.
We examine why this is dangerous. The model does not see labels such as trusted and untrusted unless the application provides them, and even then the labels are only hints. Content that looks like a policy or system message may be given more weight than it deserves. When the agent holds powerful tools, a successful influence can lead to real actions.
You will learn the principle of treating all external content as data, never as authority. Practical steps include clearly delimiting and labeling retrieved text, limiting how much of it enters the context, stripping or flagging suspicious patterns, and avoiding automatic execution of actions suggested by content.
We also discuss data flow awareness: tracking where content came from and restricting what high-risk tools may do after the agent has read untrusted material. By the end of this lecture you will be able to trace untrusted content through an agent system.
An agent has goals given by its owner and user, and goal hijacking occurs when something else takes control of those goals. This lecture explains how it happens and how instruction priority confusion contributes.
We begin with goals. The system prompt establishes a role and rules, the user adds a task, and the agent plans steps to complete it. Goal hijacking means that the agent's objective is redirected, so that it pursues a different aim than intended, such as sending information somewhere new or performing unrelated actions.
Next, we discuss instruction priority. Developers expect that system instructions outrank user instructions, which outrank content from documents and tools. Models do not enforce such a hierarchy reliably. A persuasive, well-placed, or repeated piece of text may override the intended order, especially in long contexts or when the content mimics the style of authoritative messages. This confusion is why prompt-only designs are fragile.
We look at the signs of hijacking in a harmless way: the agent mentions new tasks that the user did not ask for, calls tools unrelated to the request, or changes its tone and rules. We discuss how to detect these deviations by comparing planned actions with the original request.
Defensive ideas include restating the user's goal at decision points, validating each proposed action against the allowed task, limiting the tools available per task, and requiring approval for actions outside the expected path. By the end of this lecture you will understand how goals can drift and how to keep them anchored.
Agents commonly process documents, web pages, and tool responses, and each is a channel through which injected instructions can arrive. This lecture explains how each channel works and how to reduce the risk.
We begin with documents. Files uploaded by users or retrieved from shared stores can contain text that is invisible or unnoticeable to people but is still read by the model, such as small text, comments, or metadata. Search and retrieval tools may return passages from such documents without any review.
Next, we examine web pages. A browsing or fetch tool retrieves content from sites outside your control. The page may include text designed for an agent audience rather than human readers. The same applies to search result snippets and feeds.
Then we discuss tool responses. A server may return fields that include free text from third parties, such as ticket comments, customer messages, or error details. A compromised or malicious server may deliberately embed instructions in its output.
For each channel, we cover mitigation approaches. Sanitize and normalize content. Limit its length. Wrap it in clearly marked data sections. Remove hidden elements where possible. Restrict which sources are retrievable. Prevent the agent from taking sensitive actions in the same session after reading untrusted material unless a person approves.
We also stress testing with harmless, benign markers rather than harmful payloads. By the end of this lecture you will be able to assess each content channel in your agent and apply appropriate controls.
Many teams first try to stop prompt injection by writing stronger instructions in the system prompt. This lecture explains why prompt-only guardrails cannot guarantee security and what to rely on instead.
We begin with how prompt-based defenses work. They add text such as warnings to ignore instructions found in documents, or rules about what the assistant must never do. These measures can reduce the frequency of simple attacks, and they are worth including as one layer.
Next, we explain their limits. The model processes the defensive text and the hostile text with the same mechanism, so there is no strict boundary between them. Results vary by model, wording, and context length. A new phrasing, a different language, an encoded message, or a long conversation can defeat a rule that worked in testing. Because behavior is probabilistic, a defense that works ninety-nine times may fail on the hundredth, and attackers can try many variations.
Classifier-based filters have similar issues. They help detect known patterns but can miss novel ones and can also block legitimate content.
The central lesson is to avoid depending on the model to enforce security. Any control whose failure would cause serious harm must be implemented in deterministic code or infrastructure outside the model, such as permission checks, schema validation, approval gates, network restrictions, and isolation.
We also discuss defense in depth and measuring effectiveness through repeated testing. By the end of this lecture you will understand why prompts are useful guidance but not a security boundary.
If the model cannot be trusted to enforce security, what can? This lecture shows how to build layered defenses with policy checks, isolation, and approval gates.
We begin with the principle of assuming the model may be manipulated and designing so that manipulation has limited consequences. The layers work together: reduce the chance of influence, restrict what can be done, detect problems, and contain damage.
The first layer is policy checks. Before any tool call runs, deterministic code verifies that the tool is allowed for this user and task, that the arguments meet constraints, and that the call is consistent with the current context. For example, a policy might forbid sending messages to new external addresses after the agent has read untrusted content.
The second layer is isolation. Separate privileged tools from components that process untrusted content. Use different agents or sessions for reading external material and for taking actions, passing only validated, structured data between them. Run tools with minimal credentials in restricted environments.
The third layer is approval gates. High-impact actions, such as changing records, sending data externally, or spending resources, pause for human confirmation. We discuss making approvals meaningful by showing exact details and avoiding approval fatigue.
We also add logging and alerts, and reducing the information that enters the context. By the end of this lecture you will be able to design layered defenses that limit harm even when the model is influenced.
In this hands-on exercise you will demonstrate a harmless prompt injection, add layered defenses, and retest, following a safe, repeatable defensive workflow.
Begin by choosing a benign test scenario. Create a synthetic document in your lab document store that contains a harmless marker instruction, such as asking the agent to add a specific, innocuous phrase to its answer or to call a harmless status tool. Nothing in the test involves real data, real recipients, or damaging actions. Ask the agent a normal question that causes it to retrieve the document, and observe whether the marker instruction influences its behavior. Record the result and the full message trace.
Next, apply defenses. Add clear labeling and delimiting of retrieved content, and strengthen the system prompt as a first layer. Then implement deterministic controls: a policy check that blocks tool calls not related to the user's request, a restriction that prevents write tools from running after untrusted content has been retrieved unless approved, and an approval prompt that shows the exact action requested.
Retest using the same scenario and several variations, such as different placements of the marker text. Record which defenses worked and which only reduced frequency. Note that the deterministic controls hold even when the model is influenced.
Finally, update your risk register with the findings, the controls applied, and the residual risk. Commit your changes and save the test cases for later automation.
Tools are advertised through descriptions that the model reads, and this lecture explains tool poisoning, in which those descriptions or related metadata are manipulated to influence the agent.
We begin with how a model chooses tools. It reads each tool's name, description, and schema as part of its context, and uses them to decide when and how to call the tool. Descriptions are therefore instructions of a kind, written by whoever controls the server.
Tool poisoning occurs when a description contains content intended to steer the model in unintended ways. Instead of simply explaining what the tool does, the text might include additional directions about how the model should behave, when to prefer this tool over others, or what to do with other data. Because users commonly see only a short tool name or a summary in an interface, the full description may never be reviewed by a person.
We discuss why this is hard to notice. Descriptions can be long, may be updated by the server at any time, and are processed automatically. A tool can also influence behavior for other tools, since all descriptions share the same context.
Defensive thinking begins with treating descriptions as untrusted input from the server's author, reviewing them before approval, displaying complete descriptions to users, limiting length, and scanning for unusual directive language. We also discuss pinning approved versions so that later changes are noticed.
By the end of this lecture you will understand tool poisoning conceptually and where to apply protective controls.
Not every MCP server is trustworthy, and this lecture explains how a malicious or compromised server can influence an agent's decisions, and how to defend against it.
We begin with the position of a server in the system. It supplies tool definitions, receives arguments, and returns results, all of which become part of the agent's context. A server also may hold access to data the agent sends it. If the server is controlled by an adversary, every one of these channels is an opportunity.
We examine the kinds of influence at a conceptual level. A server can describe its tools in ways that encourage the agent to prefer them over safer alternatives. It can return results that include misleading information or embedded instructions. It can collect more data than needed through the arguments it requests. It can behave well during review and differently later. It can impersonate a trusted server by using a similar name.
We also discuss shadowing, in which a tool's description attempts to alter how the agent uses tools from other servers, which shows the risk of mixing trusted and untrusted servers in one context.
Defenses include vetting servers before use, separating high-trust and low-trust servers, limiting which data each server can receive, validating and filtering results, and monitoring behavior. By the end of this lecture you will be able to evaluate how a server could affect decisions and apply boundaries accordingly.
Metadata and responses are both text flowing across trust boundaries, and this lecture examines how violations occur when they are treated as trusted.
We begin with tool metadata, including names, descriptions, schemas, annotations, and resource listings. Clients and hosts often pass this information straight to the model. If metadata is accepted without review, the server's author effectively gains a voice inside the model's context.
Next, we look at tool responses. A response may contain structured data, free-form text, links, or references to resources. The text may originate from third parties, such as customers or external websites, and the agent may read it as if it were reliable. We discuss how responses can contain misleading claims, formatting that imitates system messages, or directives that attempt to change the agent's plan.
A trust boundary violation occurs when content crossing from a less trusted domain into a more trusted one receives unwarranted authority. Examples include a response from a low-privilege server influencing calls to a high-privilege server, or metadata from an external server shaping the use of internal tools.
Mitigations include schema-validating responses and rejecting unexpected fields, converting free text to clearly marked data, limiting size, filtering known directive patterns, separating servers by trust level, and applying policy checks on subsequent calls. We also encourage logging both metadata and responses for review.
By the end of this lecture you will be able to recognize these violations and design controls that preserve boundaries.
A tool that was safe when you approved it might not remain safe, and this lecture explains rug pulls, which are changes to previously approved tool definitions or behavior.
We begin with the scenario. A user or administrator reviews a server and its tools, approves them, and begins to rely on them. Later, the server's author, or an attacker who compromises the server or its update channel, modifies a tool's description, schema, or behavior. Because approval was granted once, the change may be accepted automatically and may never be reviewed again.
We discuss how this can happen. Remote servers can change their advertised tools at any time. Packages fetched without version pinning may update silently. Configuration might refer to the latest version of a component. Server-sent notifications can tell clients that the list of tools has changed, and some clients simply refresh and continue.
The impact may include new instructions in descriptions, widened arguments that collect more data, altered behavior that sends information elsewhere, or additional tools that expand capabilities.
Defensive practices include recording a hash or fingerprint of each approved tool definition, alerting or blocking when it changes, requiring re-approval for changes, pinning versions of packages and images, using signed or verified releases where possible, and monitoring for behavior differences.
By the end of this lecture you will understand why trust must be continuous, not one-time, and how to detect and respond to changes.
Discovery and registration are the moments when tools and servers enter your system, and this lecture covers how to secure them, along with tool schemas.
We begin with registration. Decide who may add a server to your environment and through what process. A central registry or configuration managed under version control is safer than letting each user add servers freely. Each entry should record the owner, purpose, source, version, transport, permissions, and review date. Servers should be identified by verified identities and not only by names, to prevent lookalike impersonation.
Next, we discuss discovery. When a client connects, the server lists its tools. The host should compare that list with the approved catalog, expose only allowed tools to the model, and reject or quarantine unknown ones. Namespacing helps prevent collisions and shadowing. We discuss limiting the number of tools in a given context, which reduces confusion and attack surface.
Then we cover schemas. Review input schemas for overly permissive fields, free-form strings that could carry unexpected content, or parameters that accept paths, commands, or URLs. Prefer strict types, enumerations, and length limits. Review output schemas and annotations too.
We also describe approval workflows, including review of the complete description, schema, and requested permissions. By the end of this lecture you will be able to design a controlled process for bringing tools into your environment.
In this lecture you will build the technical controls that enforce tool trust: allowlisting, change detection, and runtime verification.
We begin with allowlisting. Define an approved catalog that lists each permitted server and tool, along with its approved description, schema, and permissions. At runtime, the host exposes only the tools in the catalog to the model. Anything else is ignored and reported. You will store the catalog in a version-controlled file and load it when the agent starts.
Next, we implement change detection. Compute a cryptographic hash of each tool's name, description, and schema when it is approved. Each time the client lists tools, recompute the hashes and compare. If they differ, block the tool, log the event, and require re-approval. We also handle the notification that a server's tool list has changed, treating it as a trigger for re-verification.
Then we add runtime verification. Before executing a call, check that the tool is allowed, that the arguments conform to the approved schema, and that the call fits policy for the user and task. After execution, validate that the response matches the expected structure and size, and flag unexpected content.
We discuss usability, such as clear messages when a tool is blocked and a simple way for administrators to review changes. We also discuss keeping catalogs small and purposeful. By the end of this lecture you will be able to implement a working trust layer for tools.
In this hands-on exercise you will simulate a poisoned MCP tool in a safe lab setting and prevent unauthorized tool behavior using the controls from this section.
Begin by creating a deliberately flawed test server in your isolated environment. It exposes a harmless tool whose description includes a benign marker directive, such as asking the agent to mention a specific phrase or to prefer this tool for unrelated tasks. The tool performs no harmful actions and touches only synthetic data. Connect it to the agent and observe whether the description changes the agent's behavior. Record the message trace.
Next, simulate a rug pull. Approve the tool with its original description, then change the description and schema on the server side. Restart the server and see whether the agent notices. In the baseline lab, it will not.
Now add defenses. Implement an allowlist catalog, hash-based change detection, and namespaced tools. Configure the host to block changed or unknown tools and write a clear log entry. Add schema validation for arguments and responses, and size limits for results.
Retest both scenarios. Confirm that the poisoned description is detected during review, that the changed definition is blocked until re-approved, and that normal tools still work. Update your risk register and commit your changes, noting which residual risks remain, such as malicious behavior that does not change metadata.
Authentication and authorization are often confused, yet in agent systems, getting them right is essential. This lecture explains the difference and how each applies to agents and MCP servers.
Authentication establishes who or what is making a request. In an MCP setting, it can mean verifying the identity of a user, a client application, an agent, or a server. Without it, anyone who can reach an endpoint may use it. Authorization decides what the authenticated party may do: which tools to call, which resources to read, which records to access, and under what conditions.
We illustrate with examples. A user logs in and receives an access token. The agent presents the token to an MCP server. The server validates it, which is authentication, and then checks whether the token's permissions allow the requested tool and data, which is authorization. A valid identity with excessive permissions is still dangerous, and strict permissions without proper identity checks are useless.
Agent systems add complications. There may be several identities in play: the human user, the agent application, the model service, each server, and backend systems. Requests may pass through several hops, and each hop must preserve and verify the identity and limit privileges. A common mistake is for the agent to use one powerful credential for everyone.
We introduce principles for the section: authenticate every request, authorize at the resource, propagate user context safely, and log decisions. By the end of this lecture you will be able to explain both concepts precisely and apply them to your architecture.
OAuth 2.0 and OpenID Connect provide standard ways to handle authorization and identity, and this lecture introduces them in the context of MCP.
We begin with OAuth 2.0. It lets a client application obtain limited access to a protected resource on behalf of a user, without handling the user's password. The main roles are the resource owner, the client, the authorization server that issues tokens after authenticating the user and obtaining consent, and the resource server that accepts tokens. Tokens carry scopes, which describe the permissions granted, and have limited lifetimes.
Next, we introduce OpenID Connect, which adds an identity layer on top of OAuth. It defines an ID token and standard claims that describe who the user is, along with discovery documents that publish endpoints and keys, so that clients can configure themselves automatically.
You will see why this matters for MCP. A remote MCP server is a protected resource. Rather than inventing custom login schemes, MCP uses established OAuth patterns so that clients can discover how to authenticate, send users through a standard login, receive tokens, and present them to the server. This allows central policy, consent screens, token expiration, and revocation.
We also discuss the authorization code flow with PKCE, which suits applications that cannot keep a secret, and cover common mistakes. By the end of this lecture you will understand the main concepts and flows that appear in the rest of the section.
For a client to authenticate to an MCP server automatically, it must discover how. This lecture explains protected resource metadata and authorization server discovery.
We begin with the problem. A client connects to an HTTP MCP server that requires authorization. It needs to know which authorization server issues valid tokens, which scopes exist, and where to find endpoints and keys. Hard-coding this information does not scale to a world of many servers and many clients.
The solution uses published metadata. When a client makes a request without a valid token, the server responds with an authorization-required status and a header pointing to its protected resource metadata. That document, served at a well-known address, describes the resource, the authorization servers that it trusts, and supported scopes. The client then retrieves the authorization server's own metadata, which lists the endpoints for authorization, token issuance, key sets, and supported features.
We walk through the discovery sequence step by step, and then discuss the security considerations. The client must validate that the metadata corresponds to the expected resource, use encrypted connections, and be cautious about redirects and untrusted metadata, since a malicious server could point clients to an attacker-controlled authorization server. Allowlisting authorization servers and verifying identifiers helps prevent mix-up attacks.
By the end of this lecture you will understand how discovery works, what each document contains, and how to configure and verify it safely.
In this lecture you will implement OAuth-based protection for an HTTP MCP server, turning an open endpoint into one that requires valid tokens.
We begin with the design. The MCP server acts as a resource server. It will publish protected resource metadata, respond with an authorization-required status when requests lack valid tokens, and validate bearer tokens on every request. A local identity provider acts as the authorization server for the lab.
You will implement token validation in Python. For each request, extract the bearer token from the authorization header, retrieve the signing keys from the authorization server's published key set, verify the signature, and check the issuer, audience, expiration, and scopes. Reject anything invalid with an appropriate error and a header describing how to authenticate. Cache keys sensibly and handle key rotation.
Next, you will map scopes to tools. A read scope allows search tools, a write scope allows creation tools, and an administrative scope is required for sensitive tools. The server checks the scope before executing each tool, not only at connection time. We also add the user's identity from the token to the logs, so actions are attributable.
Finally, you will test with a client that obtains tokens through the standard flow and with requests that lack or misuse tokens. By the end of this lecture your MCP server will enforce authentication and scope-based authorization.
A token is only valuable if it is validated correctly, and this lecture covers access token security: audience validation, scopes, expiration, and PKCE.
We begin with the structure of an access token and the claims you must check. The issuer identifies who created it, and you accept only expected issuers. The audience identifies the intended recipient, and your server must reject tokens meant for a different resource, which prevents a token stolen from one service from working on another. The expiration limits how long a token is useful, and short lifetimes reduce exposure. The scopes list granted permissions, which must be checked against the requested action.
Next, we discuss audience binding in the context of MCP. Clients should request tokens for a specific server, and servers should verify that they are the intended audience. Tokens should never be accepted merely because they are validly signed.
Then we cover PKCE, the Proof Key for Code Exchange. In the authorization code flow, the client creates a random secret, sends a hashed version when starting the flow, and later proves possession of the original when exchanging the code for a token. This stops an attacker who intercepts the code from redeeming it.
We also mention secure token storage, refresh token handling, revocation, and avoiding tokens in URLs or logs. By the end of this lecture you will be able to implement and review token validation with confidence.
Several specific mistakes repeatedly weaken authorization in agent systems, and this lecture explains token passthrough, credential theft, and authorization mix-up risks.
We begin with token passthrough. An MCP server receives a token from a client and then forwards that same token to a downstream API, or accepts tokens that were not issued for it. This breaks audience boundaries, makes it hard to know who really made a request, bypasses downstream controls, and means that a compromise of the server exposes tokens valid elsewhere. The recommended pattern is for the server to validate that the token is meant for it and to obtain its own, separate credentials for downstream calls, using a standard exchange mechanism when acting on behalf of a user.
Next, we cover credential theft. Tokens and keys may be exposed through logs, error messages, configuration files, browser storage, or over-permissive servers. We discuss storing secrets safely, keeping tokens short-lived, limiting scopes, and never placing tokens in model context where they could be repeated in output.
Then we explain authorization mix-up. A client dealing with multiple authorization servers may be tricked into sending a code or token to the wrong one. Defenses include verifying the issuer in responses, using distinct redirect handling per server, and keeping an allowlist of trusted authorization servers.
By the end of this lecture you will recognize these pitfalls and apply the matching protections.
Applications often keep state between steps, such as sessions, cursors, or references to stored objects, and this lecture explains how to secure application state handles and prevent cross-user access.
We begin with the concept. A state handle is an identifier that refers to something held by the server: a session identifier, a conversation reference, a cursor for paged results, a file or document identifier, or a workflow instance. The client or the model presents the handle to continue or access that state.
The danger arises when handles are guessable or are accepted without checking who is presenting them. If one user's handle is used by another, whether by accident, guessing, or injection through the model, the second user may read or change the first user's data. This is a classic broken access control issue, and in agent systems the model may pass identifiers it has seen in context.
You will learn protective measures. Generate handles with sufficient randomness. Bind each handle to the authenticated user, tenant, and session on the server, and verify the binding on every use. Never rely on the handle alone as proof of authorization. Expire handles, and invalidate them on logout or revocation. Avoid placing sensitive identifiers where they are exposed unnecessarily.
We also discuss testing for cross-user access by attempting to use one test user's handle with another user's token in the lab. By the end of this lecture you will be able to design state handling that keeps users and tenants separate.
In this hands-on exercise you will protect an MCP server with a local OAuth provider and validate access, applying the authentication and token validation skills from this section.
Begin by starting a local identity provider in Docker, such as a lightweight open-source authorization server. Create a realm or tenant for the lab, define two test users with different roles, and register a client for your agent. Define scopes for reading tickets, creating tickets, and administration, and configure short access token lifetimes.
Next, update your HTTP MCP server. Add protected resource metadata, enforce bearer token validation, check issuer, audience, expiration, and scopes, and map each tool to its required scope. Return correct authorization errors with discovery hints, and write the authenticated user into the logs.
Then configure the client to follow the standard flow with PKCE, obtain a token, and call the server. Test the positive cases for each user. Test negative cases: no token, expired token, wrong audience, missing scope, and a token for a different user attempting to use another user's state handle. Confirm that every negative case is rejected and logged.
Finally, remove any token passthrough in your code by ensuring that downstream calls use separate service credentials. Update your risk register, record test results, and commit your work. This establishes identity as a foundation for the authorization work in the next section.
An agent that can do more than its task requires is a risk even when everything else works correctly. This lecture explains excessive agency and privilege escalation in agent systems.
Excessive agency means that an agent has more capability, more permission, or more autonomy than is necessary for its purpose. It has three common forms. Excessive functionality gives the agent tools that it does not need, such as a general command runner when only a search function is required. Excessive permissions let tools run with broad credentials, such as an administrative database account used for simple lookups. Excessive autonomy allows high-impact actions to run without any review.
We explain why this matters. Models can be mistaken, manipulated, or confused, so any mistake is limited only by what the agent is allowed to do. A well-scoped agent that is manipulated can cause little harm, while an over-privileged one can cause serious damage from a single bad decision.
Next, we discuss privilege escalation. A low-privilege user may exploit an agent that has higher privileges to obtain access the user should not have, for example by asking it to retrieve data that they cannot see directly. Agents may also chain tools in ways that combine permissions unexpectedly, or write configuration that grants themselves more rights.
Mitigation begins with design: minimal tools, narrow scopes, per-user authority, and approvals. By the end of this lecture you will recognize these risks in a design and know how to reduce them.
Access control models define who can do what, and this lecture shows how to design role-based and attribute-based controls for agent tools and data.
We begin with role-based access control, or RBAC. Users are assigned roles such as employee, support agent, or administrator, and each role grants a set of permissions on tools and data. RBAC is easy to understand, audit, and implement, and it works well when permissions align with job functions. Its weakness is coarse granularity: roles can multiply or be too broad when finer distinctions are needed.
Next, we cover attribute-based access control, or ABAC. Decisions use attributes of the user, such as department and clearance, of the resource, such as owner and classification, of the action, and of the context, such as time, device, or whether untrusted content has been read in this session. ABAC allows rules such as permitting a support agent to view tickets only for their own region, or blocking external sharing of confidential documents.
We discuss combining both: roles for broad capability and attributes for fine restrictions. For agents, include the agent identity and task context as attributes, so that the same user may have different effective permissions when interacting through an agent.
We emphasize designing from the data and tool inventory, defaulting to deny, documenting policies, and reviewing them regularly. By the end of this lecture you will be able to design a practical access model for an agent platform.
Design becomes protection only when it is enforced in code, and this lecture shows how to implement per-user and per-tool authorization policies in your MCP servers and agent host.
We begin with the enforcement points. The host can check whether a tool is allowed for the current user before showing it to the model and before executing a call. Each MCP server must also enforce authorization independently, because it cannot assume that the host is correct or uncompromised. Backend systems should add a final check at the data layer.
You will implement a policy function that receives the authenticated identity, the tool name, the arguments, and context, and returns allow or deny with a reason. Policies may read a permissions table that maps roles to tools and a rules module for finer conditions, such as the requester being the owner of the ticket. Default to deny when no rule matches.
Next, we cover user-specific data filtering. A tool that lists tickets should apply the user's identity to the query so that it returns only records they may see, rather than returning everything and hoping the model filters it. We use parameterized queries with the user or tenant identifier included.
We also log each decision with identity, tool, outcome, and reason, and test with users of different roles to confirm correct behavior. By the end of this lecture you will be able to implement and verify enforceable authorization.
Some actions are too consequential to leave to an automated decision, and this lecture shows how to restrict high-risk agent actions with human approval.
We begin by classifying actions. Reading public documentation is low risk. Creating a ticket is moderate. Deleting records, changing permissions, sending external messages, moving money, or running commands is high risk. A simple classification, applied to each tool and sometimes to specific arguments, determines which actions require approval.
Next, we cover the approval flow. When the agent requests a high-risk call, the system pauses execution and presents the user or an authorized approver with clear details: the tool, the exact arguments, the affected resources, and the expected effect. The approver can accept, reject, or modify. The decision is recorded, and only an approved call, with exactly the approved arguments, is executed. The approval must be enforced by deterministic code, not requested by the model.
We discuss common pitfalls. Prompts that are vague or full of technical detail lead to blind approval. Too many prompts lead to fatigue, so reserve approvals for meaningful risk and use policies to automatically allow low-risk actions. Approvals should expire, should be bound to the specific call, and should be requested from the right person rather than the same user who might be influenced.
By the end of this lecture you will be able to design and implement effective approval gates that add safety without making the system unusable.
In a multi-tenant system, one customer or department must never see another's data, and this lecture explains how to prevent unauthorized cross-tenant access in agent environments.
We begin with the tenancy model. A tenant might be a customer organization, a business unit, or a team. Data, configuration, and permissions are scoped to a tenant, and a user belongs to one or more. Isolation failures are among the most serious security problems, since they expose data across organizational boundaries.
Agents introduce specific risks. Shared agent memory, caches, retrieval indexes, or logs may mix tenant data. A tool may accept a tenant identifier as an argument that the model supplies, so a manipulated model or a crafted request could name another tenant. Embeddings from several tenants stored in one index may be retrieved without filtering.
You will learn defensive patterns. Derive the tenant from the authenticated identity, never from model-generated arguments or user-supplied text. Apply tenant filters at the data layer on every query. Use separate indexes, schemas, or databases for stronger isolation where risk is high. Namespace caches, memory, and state handles by tenant. Include tenant in logs and metrics to support auditing.
We also discuss testing for isolation by using two synthetic tenants and attempting cross-tenant requests through every tool. By the end of this lecture you will be able to design and verify tenant boundaries in an agent platform.
As systems grow, scattering authorization checks across code becomes difficult to maintain. This lecture introduces policy engines and centralized security enforcement.
We begin with the problem. When every tool implements its own checks, rules drift, bugs hide, and audits are hard. A policy engine moves decisions into a dedicated component that evaluates declarative rules against a request and returns a decision. Applications ask the engine whether an action is allowed and then enforce the answer.
You will learn the architecture. A policy enforcement point, located in the host or server, intercepts a request and collects relevant information: the identity, roles and attributes, the tool and arguments, the resource, and context. It sends this to a policy decision point, which evaluates policies written in a rules language and returns allow, deny, or require approval, with a reason. Policy data and rules are versioned and managed centrally.
We discuss the benefits: consistent enforcement across servers, easier review by security teams, testability, change tracking, and the ability to update rules without modifying application code. We also discuss tradeoffs, including added latency, availability dependencies, and the need to handle failures safely, usually by denying when the engine cannot be reached.
We give examples of rules suited to agents, such as blocking external sends after reading untrusted content, or limiting bulk access. By the end of this lecture you will understand how to adopt centralized policy enforcement.
In this hands-on exercise you will implement and test least-privilege access across the enterprise MCP tools, bringing together the authorization concepts from this section.
Begin by reviewing your tool inventory and classifying each tool by sensitivity and whether it reads or changes data. Define roles for the lab, such as employee, service desk analyst, and administrator, and list the tools and data that each should be able to reach. Write the access matrix as a table, with deny as the default.
Next, implement the policies. Add a policy function or connect a lightweight policy engine so that each tool call passes through a decision point. Include user identity from the validated token, role, tool name, and arguments. Apply data-level filters so that listing and search tools return only records permitted for the user, and derive the tenant from the identity rather than from arguments.
Then add approval gates for the high-risk tools, such as deleting a ticket or updating permissions. Show the exact arguments to the approver, record the decision, and execute only the approved call.
Test thoroughly. For each role, try allowed and disallowed tool calls, attempt cross-tenant access with a second synthetic tenant, and attempt to supply a manipulated tenant argument. Confirm that every unauthorized attempt is denied and logged.
Finally, update your risk register with the controls and test evidence, and commit the work.
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.