Lesson 1 of 10 · Lesson + Lab · 75 min · Free preview

AI Agents for Testers — LLM + Tools + Loop, MCP and the STLC

Understand what an AI agent really is, how the Model Context Protocol connects agents to tools, and where agents fit in the testing life cycle.

Why this matters on the job

Picture a sprint review at a product company in Bengaluru or a client delivery team in Pune. The engineering manager says: "Our competitors are using AI agents to write and fix tests. Can we cut our regression automation backlog in half this quarter?" Half the team has only used AI chat to paste a stack trace and ask what went wrong. The other half has tried an agent that clicked around the app, wrote a test, ran it and fixed its own mistakes - and they are either excited or worried.

In 2026 the conversation has moved from "AI suggests a line of code" to "AI agents explore the app, write tests, run them and repair them". Testers who understand how an agent works - the model, the tools it can call, and the loop it runs - are the people who can make it useful and safe. Testers who do not understand it either avoid agents completely or trust them blindly. Both are career risks. This lesson gives you the mental model you will use for the rest of the course.

Concepts

Three generations of AI help for testers

It helps to separate the hype into three clear generations. Most teams in India and abroad now use all three side by side.

GenerationWhat the AI doesTypical exampleTester's role
1. AutocompletePredicts the next lines while you typeInline code suggestions in the IDEWrite the test, accept or reject suggestions
2. Chat assistantAnswers a question or writes a block of code from a prompt"Write a Playwright test for the login page" in a chat windowCopy, paste, run, debug the code yourself
3. AgentPlans steps, calls tools (browser, terminal, files, APIs), observes results and repeats until the goal is metAn agent that opens the app through Playwright MCP, writes a spec file, runs npx playwright test and fixes failuresDefine the goal and boundaries, review every change, own the quality decision

The jump from generation 2 to 3 is not about a smarter model. It is about giving the model hands (tools) and time (a loop). That is why the same model can feel like a toy in a chat window and like a junior automation engineer inside an agent.

Anatomy of an agent: LLM + tools + loop

  • LLM (the brain) - reads the goal, the conversation so far and the tool results, then decides the next action. It does not "see" your app directly; it only sees what tools return.
  • Tools (the hands) - functions the model is allowed to call: navigate a browser, take an accessibility snapshot, click, read a file, run a shell command, call an API. Each tool has a name, a description and an input schema.
  • Loop (the persistence) - the host program sends the model's tool request to the tool, captures the result and sends it back to the model. This repeats until the model says it is done, a step limit is reached, or a human stops it.
  • Context (the memory) - everything the model can see in one turn: instructions, files you attach, previous tool outputs. Context is limited, so good agents summarise and good testers keep prompts focused.
  • Guardrails - permissions, approvals, allowed websites, step limits and human review. Without guardrails, an agent is just an automated way to make mistakes faster.

The following pseudo-code is not a real product, but it shows the loop every agent host runs, whether it is VS Code, Claude Code or a CI bot:

# Simplified agent loop - for understanding only
def run_agent(goal, tools, llm, max_steps=25):
    messages = [{"role": "system", "content": "You are a test automation agent."},
                {"role": "user", "content": goal}]
    for step in range(max_steps):
        reply = llm.chat(messages, tools=[t.schema for t in tools])
        if reply.tool_call is None:          # model says it is finished
            return reply.text
        tool = next(t for t in tools if t.name == reply.tool_call.name)
        if tool.needs_approval and not human_approves(reply.tool_call):
            messages.append({"role": "tool", "content": "User denied this action."})
            continue
        result = tool.run(**reply.tool_call.arguments)   # e.g. click, run tests
        messages.append({"role": "tool", "content": result})
    return "Stopped: step limit reached - ask a human to review."

Notice three tester-relevant details: the max_steps limit (agents can loop forever), the approval check (some tools are risky), and that every tool result goes back into the context (so a malicious web page can talk to the model - we will cover that prompt-injection risk in lesson 9).

Model Context Protocol (MCP) basics

Before MCP, every AI tool vendor wrote its own plugin format. The Model Context Protocol is an open standard that defines how an AI application discovers and calls external tools and data. Write a tool server once and many clients can use it - VS Code with GitHub Copilot, Claude Code, Cursor and others.

MCP termMeaningTesting example
HostThe AI application the user works inVS Code, Claude Code, Claude Desktop
ClientThe connector inside the host that talks to one serverThe VS Code connection to the Playwright server
ServerA program exposing capabilities over MCP@playwright/mcp exposing browser tools
ToolsActions the model can invokebrowser_navigate, browser_snapshot, browser_click
ResourcesRead-only data the host can attach as contextA test plan file, an OpenAPI spec
PromptsReusable prompt templates offered by a server"Generate a regression plan for this page"

Servers can run locally as a child process (communicating over standard input/output) or remotely over HTTP. Most testing servers you will use start with an npx command. A typical client configuration looks like this (the exact file name and top-level key differ per client - VS Code uses .vscode/mcp.json with a servers key, many other clients use mcpServers):

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest"]
    }
  }
}

This is the configuration documented on the Playwright MCP getting started page. Important point for testers: an MCP server is code that runs on your machine with your permissions. Treat adding one like installing a dependency - only from trusted publishers, pinned and reviewed.

Where agents fit in the STLC

Agents are not equally useful in every phase. Use this map when your manager asks "where should we start?"

STLC phaseAgent can help withHuman must ownFit today
Requirement analysisSummarise user stories, list ambiguities, suggest acceptance criteriaConfirming business intent with the product ownerMedium
Test planningExplore the app and draft a Markdown test planScope, risk priority, what not to automateHigh
Test designGenerate scenarios, boundary values, negative cases, synthetic dataDomain rules (GST, UPI limits, KYC rules)High
Test implementationWrite Playwright/API tests, refactor to Page Object ModelCode review, locator quality, assertions that prove somethingHigh
ExecutionRun suites, re-run failures, collect tracesEnvironment and data readinessHigh (mostly via CI, not the LLM)
Defect reporting / triageCluster failures, summarise traces, draft bug reportsSeverity, deciding bug vs test issueMedium-High
Test closureDraft summary reports and metrics narrativeSign-off and release recommendationMedium

Limits you must explain to stakeholders

  • Non-determinism - the same prompt can produce different tests on different runs. Commit the generated code, not the prompt, as the source of truth.
  • Confident but wrong - agents can write assertions that always pass (for example checking that a page has a title) and report success.
  • Cost and speed - every tool call is a model call. Running the LLM inside every CI test run is slow and expensive; use agents to create and maintain tests, and plain Playwright to run them.
  • Data privacy - anything the agent reads may be sent to the model provider. Never point agents at production data or paste client PII; use synthetic data and practice sites. In India the Digital Personal Data Protection (DPDP) Act 2023 applies to personal data, and EU clients will expect GDPR discipline.

Hands-on Lab: Watch an MCP server without any AI

Target: the Playwright MCP server and saucedemo.com. Setup: Node.js 22.19 or newer (needed by the MCP Inspector), a terminal and a browser. No AI account is required - you will act as the "LLM" yourself, which is the fastest way to understand what an agent actually sees.

  1. Check your Node version with node -v. Upgrade to a current LTS if it is older than 22.19.
  2. Start the official MCP Inspector with the Playwright server as its target:
    npx -y @modelcontextprotocol/inspector npx @playwright/mcp@latest
  3. The Inspector opens in your browser. Connect, then open the Tools list. Note down at least eight tool names and read their descriptions and input schemas - this is exactly what the model reads when deciding what to do.
  4. Call browser_navigate with {"url": "https://www.saucedemo.com"}. A real browser window opens.
  5. Call browser_snapshot. Study the output: roles (textbox, button), names and element references such as ref=e5. The model uses these references, not pixels, to choose what to click.
  6. Using the refs from the snapshot, call browser_type to enter the public demo user standard_user and password secret_sauce, then browser_click on the Login button. Take another snapshot and confirm you are on the Products page.
  7. Optional: list tools from the command line, which is useful in CI scripts:
    npx @modelcontextprotocol/inspector --cli npx @playwright/mcp@latest --method tools/list
  8. Write a one-page note: which tools would you allow an agent to use freely, which need approval, and which would you disable on a client project? Keep it - you will reuse it in lesson 9.

Common mistakes

  • Thinking the agent "sees" the screen like a human - with Playwright MCP it mostly reads an accessibility snapshot, so poor accessibility in the app means poor agent results.
  • Running agents with no step limit or approval rules and then being surprised by 200 tool calls and a large bill.
  • Adding random MCP servers found on the internet without checking the publisher, the code and the permissions they need.
  • Using the LLM inside every CI run instead of generating stable Playwright code once and running it deterministically.
  • Pasting real customer names, Aadhaar-like IDs, card numbers or client URLs into an agent prompt - use synthetic data and practice targets.

Real-world assignment

Prepare a two-page "Agentic testing opportunity map" for a realistic product (for example a UPI payments app or an e-commerce site like saucedemo.com). For each STLC phase, list one task an agent could do, the MCP tools it would need, what a human must review, the risk level and how you would measure success. Add a diagram of the agent loop in your own words. Publish it in your portfolio repository as a Markdown file - interviewers increasingly ask candidates how they would introduce AI agents safely.

Key takeaways

  • An agent is an LLM plus tools plus a loop, wrapped in guardrails - the tools and loop are what make it useful.
  • MCP is the open standard that lets one tool server (like Playwright MCP) work with many AI hosts.
  • Agents fit best in planning, design, implementation and triage; humans own scope, risk and sign-off.
  • Use agents to create and maintain tests; run the resulting code deterministically in CI.
  • Every tool result enters the model's context, which is both a superpower and a security risk.

🧪 Practical checklist

Do each task yourself and tick it off. All tasks are required to complete this lesson.

🎤 Interview questions

What is the difference between an AI coding assistant and an AI agent in test automation?

An assistant responds to a prompt with text or code that I then run myself. An agent is given a goal and tools - such as a browser, terminal and file access - and runs a loop of planning, acting, observing results and retrying until the goal is met. That makes it more powerful but also means I must set permissions, step limits and review its output.

Explain Model Context Protocol to a non-technical manager.

MCP is like a standard power socket for AI tools. Instead of every AI product building its own custom integration for a browser or a test management tool, a tool is wrapped once as an MCP server and any MCP-compatible AI app can use it. For us it means we can plug Playwright, GitHub or our own internal tools into the AI assistant the team already uses.

Where in the STLC would you introduce agents first, and why?

I would start with test design and implementation for stable, well-understood flows, such as login and checkout regression, because the output is code that can be reviewed in a pull request and measured. I would avoid using agents for sign-off or severity decisions, and keep humans owning scope and risk.

Why shouldn't we call the LLM in every CI test run?

It makes runs slower, more expensive and non-deterministic, and it adds a data-sharing risk on every run. A better pattern is to let the agent generate and maintain plain Playwright code that runs deterministically in CI, and use the agent only when tests need to be created or repaired.

What does an agent actually see when it uses Playwright MCP?

Mainly a structured accessibility snapshot of the page - roles, accessible names and element references - rather than raw pixels. Screenshots are available, but the snapshot is the main input. So apps with good accessibility and stable labels give much better agent results.

📝 Quiz, progress tracking & certificate

You're reading a free preview. Premium members tick off labs, take the quiz, unlock all 10 lessons and earn a verifiable certificate.

💎 Unlock with Premium Premium login
✓ You're subscribed — job alerts arrive daily at 9 AM
Scroll to Top