🖥️

Playwright mCP Server for API Testing

May 13, 2025

Playwright mCP Server API Testing

Introduction

  • Presenter: Karik from isautomation.com
  • Topic: Playwright mCP Server and its new API testing support

Model Context Protocol (mCP)

  • mCP is an open-source standard aimed at enhancing AI assistants' effectiveness by connecting them to systems and tools where relevant data exists.
  • mCP servers can interact with various systems on the machine (e.g., Slack, Google Drive, Puppeteer).
  • Previous discussions included a demo of the Playwright mCP server performing UI automation tasks (e.g., login operations).

New Feature: API Testing Support

  • The Playwright mCP server now includes functionality for API testing.
  • Users can perform API operations using plain English text commands.
  • Demonstration planned for how to conduct API tests with this new feature.

Setting Up Playwright mCP Server

  • Ensure you have Playwright mCP server version 0.2.4 or higher to access API testing features.
  • Reference the mCP server in your Cloud Desktop client to utilize the new functionality.

Demonstration of API Testing

  1. Initiating API Test:
    • Command example: "Perform a POST operation for the URL [insert URL] with the body [insert body] and verify the response has 'created_at' and 'ID' properties."
  2. Using a Test API:
    • Example API for testing is a publicly available RESTful API.
    • Commands include sending POST requests and checking that the response contains necessary properties.
  3. Response Verification:
    • The system will verify if the response body contains the correct properties (e.g., 'created_at', 'ID').
    • Users can also check the response status code (200, 404, etc.).

Workflow for API Operations

  • API testing can be streamlined using plain English commands rather than traditional methods like Postman.
    • Example Workflow:
      • Perform a POST request to create a product and store the returned ID.
      • Use the stored ID for further operations (GET, PUT, PATCH).

Example Commands

  • Create a product:
    • "Perform a POST operation for the URL with this body and verify the response has 'created_at' and 'ID' properties. Store the 'ID' as 'product_ID'."
  • Retrieve a product:
    • "Perform a GET operation for the 'product_ID' and verify the response has properties 'ID' and 'name'."
  • Update a product:
    • "Perform a PUT operation for 'product_ID' with this body and verify the response contains 'created_at' and 'ID' properties."
  • Patch a product:
    • "Perform a PATCH operation to update the product, then verify the updated name."

Conclusion

  • The Playwright mCP server allows users to conduct API testing seamlessly using plain English text.
  • Future updates may include additional capabilities for more complex API requests (e.g., multipart forms, binary data).
  • Encouragement to utilize the Playwright mCP server for API testing without cost.

Final Note

  • Thank you for watching, and look forward to the next video.