1. Overview: What Is the MCP Protocol and Its Benefits for Claude Code
By default, Claude Code is still quite limited. If you want it to browse the web, inspect databases, manage GitHub, and think thoroughly like a seasoned developer, you need to plug in MCP. This guide walks through each tool in detail: what it can do, which command to use to install it, what prompts to ask Claude, and what caveats to keep in mind.
After reading this, you will:
- Understand what MCP is without needing deep programming knowledge.
- Be able to install all 6 MCPs using ready-to-copy commands (or have Claude install them for you).
- Have ready-to-use sample prompts to immediately test each MCP.
- Know how to restrict permissions so Claude doesn’t make unauthorized changes to files, databases, or codebases.
Simply put, Claude Code is the version of Claude that runs inside your command-line interface (Terminal), specialized in reading and writing code directly on your machine. On its own, it can already read, modify files, and run commands. However, it cannot automatically open a browser, connect to a database, or know when a library has just released a new version.
MCP (Model Context Protocol) is an open “plug-in standard” that allows AI to connect with external tools[13]. Think of it like a USB port: any device built to the USB standard will work when plugged into any computer. Each MCP server (a small background program) is an accessory: plugging it in gives Claude the “hands and feet” needed to perform new tasks[1].
| MCP | Analogous to | What Claude can additionally do |
|---|---|---|
| Playwright | Giving Claude a web browser | Open websites, click buttons, fill out forms, take screenshots, run UI tests |
| Filesystem | A key to only the authorized room | Read, search, edit, and organize files within designated directories |
| Postgres | A microscope for the database | Inspect table schemas, write and run SQL, identify slow queries |
| GitHub | An assistant for managing code repositories | Read/create Issues, open and review Pull Requests, check CI status |
| Context7 | An always up-to-date documentation library | Look up the latest docs for React, Next.js… before coding |
| Sequential Thinking | A scratchpad for step-by-step reasoning | Break down complex problems, self-verify, and adjust reasoning |
A few terms you will encounter: Terminal, npx, Token / API key. npx requires Node.js 18 or higher[2] from nodejs.org (LTS recommended).
If it outputs something like v22.x.x, you’re good to go. Postgres MCP Pro is written in Python and runs via the uvx command from the uv tool[12]. Paste the corresponding command into your Terminal:
2. Installation Guide and Basic Command Syntax for Beginners
Every MCP is installed using a single command in the following format[1]:
--scope user means install once, use across all projects on your machine. If omitted, it defaults to being used only in the current directory. With --scope project, Claude writes the configuration to a .mcp.json file for the entire team to share.
Step 4: Check if MCP is running
Type claude mcp list in the Terminal, or type /mcp directly inside Claude Code. Any MCP showing connected is ready to use.
Easiest Way to Install Any MCP from the Documentation
- Scroll down to the MCP you want to install, click Copy in the lenh-cai.txt box.
- Open Claude Code, paste the copied content into the chat box, then send: “Please help us install this MCP, ask us if a token or path is needed.”
- Claude will automatically run the
claude mcp addcommand. Click agree when it asks for permission to run the command. - Exit Claude Code and reopen it (type
/exit, thenclaude), then type/mcpto check.
Using Windows?:npxcmd /c-- cmd /c npx @playwright/mcp@latest
3. MCP 1: Playwright – Test Automation and Browser Control
Playwright[2]Source code repository
Tip: The first time it runs, Playwright may need to download browsers. If Claude reports missing browsers, just send: “Please install the browsers for Playwright for us.” And remember to start your web app first (e.g., npm run dev) before asking Claude to inspect it. Grant Claude permissions to read files, search code, fix bugs, and clean up directories—but only within the directories you allow. Filesystem MCP[3] is an official server in the Model Context Protocol reference implementations. It comes with built-in tools: Read one or multiple files, list directories, render directory trees, search files, inspect file metadata (read-only group); create directories, write files, edit files, and move/rename (write group). Security guardrails: During setup, you specify the allowed directories. Claude can only operate within those folders and cannot touch anything else. If the client supports the “roots” capability, the list of directories provided by the client will override the setup list[3]. Claude Code natively reads and edits files within your opened project directory anyway. Filesystem MCP is most useful when: You want Claude to work with folders outside your project (e.g., documentation, images), you want an explicit list of allowed directories, or you share the same configuration with Claude Desktop—the chat app version that cannot natively read local files. View the directory tree of ~/Projects/shop, find all references calling the old formatPrice function,
change them to formatCurrency, and list the modified files.
Organize the directory ~/Documents/tai-lieu: Move PDF files into pdf/, images into images/,
DO NOT delete any files, and report back the list of moved items once finished.
4. MCP 2: Filesystem – Secure File Management and Permissions
Do not grant entire drives: Do not grant an entire drive. Only allow the specific project directory. Avoid granting the entire user home directory (~) or drive C:, where passwords, SSH keys, and critical configuration files reside. Claude inspects table schemas on its own, writes SQL queries itself, runs queries, and analyzes data without you having to sit and manually describe the messy data. PostgreSQL (Postgres) is a very popular database management system. SQL is the language used to query and modify data within it. The original Postgres MCP version from the Model Context Protocol team has now been archived and is no longer maintained[5]. Therefore, this guide uses Postgres MCP Pro[4], an actively maintained open-source fork that does much more: The connection string (DATABASE_URI) follows the format postgresql://username:password@host:5432/database_name. Obtain this information from wherever you are hosting your database (Supabase, Neon, your local machine…). Inspect the database schema and draw us an ER diagram showing the relationships between the orders, users, and products tables.
What is the revenue for the last 30 days broken down by product category? Provide us with the SQL query used as well.
The /orders page loads very slowly. Find the slowest query related to the orders table and suggest an index.
5. MCP 3: PostgreSQL – Query and Inspect Databases from the Command Line
Be careful with production databases: Be careful with production databasesWith databases currently running for clients, always use –access-mode=restricted and ideally create a dedicated read-only database user for Claude. Do not install with –scope user because each project has its own database. Do not paste connection strings containing actual passwords into files and push them to GitHub. Connect Claude directly to GitHub: Read and create Issues, open Pull Requests, review code, check CI, eliminating the need to constantly switch back and forth between the terminal and the browser. GitHub is where code is stored. Issues track bugs/to-do items; Pull Requests (PRs) propose merging new code into the project. The GitHub MCP Server[6] is the official implementation developed by GitHub, dividing tools into multiple toolsets such as repos, issues, pull_requests, actions (CI), code_security, discussions, notifications… Log in to GitHub then click your avatar in the upper right corner then Settings then Developer settings then Personal access tokens then Generate new token. Select the permitted repositories and only check the permissions you feel comfortable granting to AI[6]. Copy the token (it will only be displayed once). Replace YOUR_GITHUB_PAT with the copied token[7]: claude mcp add-json –scope user github ‘{“type”:”http”,”url”:”https://api.githubcopilot.com/mcp”,”headers”:{“Authorization”:”Bearer YOUR_GITHUB_PAT”}}’
install-command.txt
6. MCP 4: GitHub – Automating Pull Request, Issue & Commit Management
Tip: If you are just starting out, enable read-only mode so Claude can only view without creating or modifying anything: For the online version, change the URL to https://api.githubcopilot.com/mcp/readonly (command readily available in the lenh-cai.txt box). Once you get used to it, you can grant more permissions. AI learns from old data, so it often writes code using outdated library versions. Context7 feeds the latest documentation to Claude before coding. “Hallucination” occurs when an AI confidently invents a non-existent function or uses deprecated syntax. This happens very frequently with React, Next.js, Supabase… because they update continuously. Upstash’s Context7[8] solves this with 2 tools: claude mcp add –scope user –header “Authorization: Bearer YOUR_API_KEY” –transport http context7 https://mcp.context7.com/mcp
How to Use
“use context7”[8]
7. MCP 5: Context7 – Documentation Lookup And Latest Library Updates
No need to type “use context7” every time: No need to type “use context7” every time—just add a line to your project’s CLAUDE.md file: “When writing code using external libraries, always look up the documentation via Context7 first.” Claude will remember it automatically. When facing difficult bugs or complex architecture, don’t force AI to answer immediately. Enable this so it can break down the problem, reason step-by-step, and self-verify. Sequential Thinking[10] gives Claude a structured “scratchpad.” Each time the sequential_thinking tool is called, Claude records a thought step with a sequence number, an estimate of total steps, and can refine its thinking: Better to be a bit slow and certain than quick and completely wrong. claude mcp add –scope user sequential-thinking — npx -y @modelcontextprotocol/server-sequential-thinking
Sample Prompt
8. MCP 6: Sequential Thinking – Sequential Reasoning to Solve Complex Problems
Combined with the built-in thinking mode:
9. Practical 3-Step Automation Pipeline With the .mcp.json File
Copy the .mcp.json file above into the root directory of your project, then declare the environment variables before launching Claude Code. This approach allows you to share it with colleagues without exposing your tokens. On Mac, files starting with a dot are hidden; press Cmd + Shift + dot to show them. After copying the file into the project, run export GITHUB_PAT=..., export CONTEXT7_API_KEY=..., export DATABASE_URI=..., then open Claude Code in that directory and approve the project’s MCPs. Type /mcp to check the status.
The sample file only uses the ${VARIABLE_NAME} format, so it is safe to share. If you paste your tokens directly and push to GitHub, your tokens will be compromised immediately.
- Extract and copy the du-an-mau/.mcp.json file into your project’s root directory. (Mac hides dotfiles; press Cmd + Shift + . to reveal them.)
- Open Claude Code in the project, drag the DOC-TRUOC.txt file into the chat, and type: “Help us set the environment variables and enable these MCPs.”
- When Claude Code asks if you trust the project’s MCPs, select approve. Type
/mcpto verify.
The .mcp.json file uses the ${VARIABLE_NAME} syntax, so it can be pushed to GitHub without leaking tokens[1].
Only install MCPs from trusted sources (the repos in this document are all official releases or popular open-source tools). Grant least privileges: specific directories, read-only databases, and repo-scoped GitHub tokens. Exercise caution when allowing Claude to browse unfamiliar websites using Playwright, as web pages may contain content designed to prompt-inject the AI into performing unintended actions.
Type claude mcp remove <name>, for example: claude mcp remove playwright. Installing too many MCPs at once consumes Claude’s context window memory; only enable the tools you genuinely need for the project.
10. Frequently Asked Questions & Troubleshooting (FAQ)
A compilation of solutions for technical issues and common questions when configuring the Model Context Protocol for Claude Code:
Read next: Leveraging 6 Open-Source AI Repositories on GitHub to Build Systems

Chưa có bình luận nào. Hãy là người đầu tiên chia sẻ góc nhìn!