In this stage, we'll learn the basics of MCP servers in Cursor and set up our first server using Playwright. This will allow us to interact with web browsers directly from Cursor's AI chat.
What is MCP?MCP (Model Context Protocol) is an open protocol that allows AI models in Cursor to interact with external tools and services. With MCP servers, the AI can perform actions beyond just generating text, such as:
- Controlling applicationsThere are three ways to configure MCP servers in Cursor:
1. In Cursor Settings:.cursor/mcp.json
file in your project root~/.cursor/mcp.json
fileThe configuration format in mcp.json
files follows this structure:
{ "mcpServers": { "serverName": { "command": "executable", "args": ["arg1", "arg2"], "env": { "ENV_VAR": "value" }, "transport": "stdio" // or "sse" } } }
Where:
-serverName
: The name you'll use to reference this servercommand
: The executable to runargs
: Command-line arguments to passenv
: Environment variables (optional)transport
: Communication method (default is "stdio")This structure is used to configure both Global and Project-specific MCP servers through the mcp.json
file.
Let's set up our first MCP server using Playwright. Playwright is a browser automation framework that will allow the AI to control web browsers, navigate to websites, take screenshots, and interact with web pages.
Let's create the Playwright MCP configuration for our project using the project-specific approach. Ask the AI to create the folder and the mcp.json
file.
After the file is created, check the settings to see the new MCP server:
Click on "Disabled" button to enable the server. After that, you should see the green checkmark on the server name as shown above.
Now that we've set up our Playwright MCP server, let's test it by asking the AI to use it to check the weather in New York.
If everything is set up correctly, the AI should be able to use the Playwright tools to open a browser, navigate to a weather website, and retrieve the current weather information for New York City.
What's Next?In the next stage, we'll dive deeper into MCP architecture, transport formats, and will build a custom MCP server.