How to Install MCP Servers in Claude Code
Claude Code now supports MCP (Model Context Protocol) servers, which allow Claude to interact with external tools and services. This article shows you how to install an MCP server using the playwright server as an example.
The Quick Solution
Installing an MCP server in Claude Code can be confusing. I struggled with this a few times, so I wrote this post.
I am using a Playwright MCP server as an example. To install the Playwright MCP server, run this command:
claude mcp add playwright -s user -- npx -y @executeautomation/playwright-mcp-server
That's it. But let's understand what this command does.
Breaking Down the Command
This Playwright MCP server is based on JavaScript and NPM. That is true for many MCP servers.
The command has several parts that work together:
claude mcp add
- The base command for adding an MCP server to Claude Codeplaywright
- The name you want to give to this MCP server in Claude Code-s user
- Specifies the scope as "user", meaning this server will be available across all your projects--
- Separator indicating that everything after this is the actual command to run the servernpx -y @executeautomation/playwright-mcp-server
- The npx command that runs the Playwright MCP server from the JavaScript NPM package
The -s user
option is particularly useful. It means you install the MCP server once and can use it in all your Claude Code sessions. The alternative would be project-specific installation, which you'd need to repeat for each project.
The npx -y
part automatically confirms the installation of the NPM package without prompting, making the setup smoother.
I am not describing more options and details here because the example from above gives you a great starting point to use the offical Claude Code MCP documentation effectively.
Verifying the Installation
After running the installation command, you can verify that the MCP server is properly installed by using the /mcp
command in Claude Code:
/mcp
This command lists all available MCP servers. You should see your newly installed "playwright" server in the list.
You can navigate the list and press Enter on your new MCP server entry. Claude Code shows you details about this server.
Pressing Enter again shows you all the tools the server provides.
Testing
To test if the server is working correctly, you can ask Claude to use it. For example:
Can you use playwright to navigate to example.com and take a screenshot?
Here is a screenshot:
Claude now has access to the Playwright MCP server and can perform browser automation tasks for you.
What's Next?
MCP servers open up many possibilities for extending Claude Code's capabilities. You can install servers for database access, API interactions, file system operations, and more.
Learn More
If you're new to these tools, here are some helpful resources:
- What is Claude Code? - Anthropic's official CLI for Claude that enables advanced coding assistance
- What is MCP (Model Context Protocol)? - An open protocol that enables AI assistants to interact with external tools and services
- What is npx? - A package runner tool that comes with npm, allowing you to execute packages without installing them globally
- What is npm? - The Node Package Manager, the world's largest software registry for JavaScript packages