Claude Code guide in three levels, Beginner to Advanced: hands-on lessons with checked exercises, every volatile fact cited to its source. Independent community guide.
Connect a tool with MCP
Intermediate · Lesson 7 of 8 · about 25 minutes · Needs: Permissions, settings scopes and the sandbox · Verified against Claude Code v2.1.308 (stable) on 2026-10-25
Goal
By the end of this lesson you can connect a version-pinned MCP server at the right scope and use its browser evidence to find and fix a page error.
You need
- One of your own repositories, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both. Set up the repository's
.practice/folder as the Intermediate index describes, if you haven't yet. - Chrome, and npm, which comes with Node.js: the server runs through
npx(upstream requirements). - Usage: light.
The idea
MCP (the Model Context Protocol) lets Claude Code use tools that another program provides: an MCP server. This lesson uses Chrome DevTools MCP (Vendor: Google) to inspect a local page's console, diagnose its error and capture the repair (tool reference).
flowchart LR
accTitle: How Claude reaches Chrome through an MCP server
accDescr: Claude Code calls the chrome-devtools MCP server's tools. The server, a local process started with npx, drives a Chrome browser and returns the results to Claude Code.
A["Claude Code"] -->|tool call| B["chrome-devtools MCP server, started with npx"]
B --> C["Chrome"]
B -->|result| A
Where you add a server decides who gets it (MCP installation scopes):
| Scope | Who gets it | Stored in |
|---|---|---|
| Local, the default | You, in this project | ~/.claude.json |
| Project | Everyone who works in the project | .mcp.json at the project root, committed |
| User | You, in every project | ~/.claude.json |
In an interactive session, Claude Code asks you to approve a project's servers before it uses them. Approving a server and approving an individual tool call are separate decisions. A shared .mcp.json never holds a token: write ${VAR} and each teammate sets the variable (Environment variable expansion). With tool search, the default, only tool names and server instructions load at session start (Scale with MCP Tool Search).
[!WARNING] Data that leaves your machine. By default, Chrome DevTools MCP sends usage statistics to Google, may send the URLs of performance traces to Google's CrUX API, and checks npm for updates (upstream README). This lesson always runs it with all three turned off. The pages Claude opens still load from the web, and the server shows Claude everything in that browser. Use the isolated browser only for this local demo, with no personal accounts or sensitive pages.
Worked example
Save this page as
.practice/demo.htmlin your repository. It has a planted browser bug; leave it unfixed:<!doctype html> <title>Linkcheck demo</title> <a href="#guide">Guide</a> <a href="#reference">Reference</a> <p id="link-count">Counting links...</p> <script> const links = document.querySelectorAll('a'); document.querySelector('#link-total').textContent = `${links.length} links ready`; </script>Add the server at local scope, for yourself. Run this in your repository's terminal. The version is pinned,
--isolatedgives the browser a temporary profile, and the other two flags and the variable turn the data flows off (configuration). Everything after--is the server's own command:claude mcp add --env CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1 --transport stdio chrome-devtools -- npx -y [email protected] --isolated --no-usage-statistics --no-performance-cruxRun
claude mcp get chrome-devtoolsin the same repository. It shows which scope holds the server, local here, and the server's status (Find your configuration on disk).Start a Manual session with
claude --permission-mode defaultfor this first MCP tool use (Choose a permission mode). Run/mcpand selectchrome-devtoolsto inspect its status and tools. The list shows a tool count; select the server to see the tool list (Tool availability). Then ask:Use the chrome-devtools tools to open .practice/demo.html as a file: URL. Read the title, visible count and console error. Report the error and its source location, without editing any files.If Claude Code asks about a tool call, inspect the tool name and inputs, then approve only that call (Configure permissions). Do not grant a standing approval for this exercise. Read the actual tool output: the count stays at
Counting links..., and the script fails when it tries to update an element that wasn't found. Your browser's error wording may differ. After reviewing the first call, pressShift+Tabuntil the status bar reads⏵⏵ auto mode on, if auto mode is available, so later calls can proceed under its checks (Switch permission modes).
Your turn
Give every teammate the exact browser server you reviewed, then use it to fix the broken demo page.
In the same repository's terminal, remove your local copy, which would otherwise take precedence over a project server of the same name (Scope hierarchy and precedence):
claude mcp remove chrome-devtools -s local. If it reports no local server, confirm you are in the repository where you added it; local scope belongs to that project.Add the same server at project scope. The command writes
.mcp.jsonat the repository root, beside any servers already in it (Project scope):claude mcp add --scope project --env CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1 --transport stdio chrome-devtools -- npx -y [email protected] --isolated --no-usage-statistics --no-performance-cruxRead
.mcp.jsonbefore you commit it: check the pinned version, the two flags and the variable, and that it holds no token. Then commit it.Exit the session from the Worked example, then start
claudeagain in your repository. When it asks about the project's new server, approve it only if you have reviewed the server's command and arguments in.mcp.json: they decide what code runs on your machine. If.mcp.jsonnames a server you haven't reviewed, decline and investigate. Run/mcp, select the server and check that it connected (Edit .mcp.json directly). Keep auto mode for the repair.Use the project's browser tools to reload
.practice/demo.htmland read its console before editing. Decide whether the element lookup or the count calculation is at fault: compare the reported source line with the page's existing result element. Fix the mismatched lookup while keeping the calculation; hiding the exception would leave the page broken. Ask Claude to make that focused repair, then use the MCP tools to reload and verify the visible count and console. The result should read2 links readywith no script error. Then have the server save the repaired page as a PNG to.practice/i-7-page.png(Screenshot tool).
Check
You are done when all of these are true:
- The committed
.mcp.jsonpins the package to an exact version and turns off usage statistics, CrUX lookups and update checks:git show HEAD:.mcp.json | jq '.mcpServers["chrome-devtools"]'shows them. -
.practice/i-7-page.pngholds a PNG image of the repaired page, saved after the repair. - The demo script displays
2 links readywithout a script error; a hardcoded count doesn't pass. - Self-check (not tested): you reviewed the first MCP tool call, used the project's server to read the real console error, and verified the repaired count and clean console after reloading.
Run npm run check -- i-7 --dir <your repo> from your practice copy, or npm run check -- i-7 in the copy itself.
If the server item fails, compare each argument with the Worked example's command: @latest isn't pinned. If the capture is missing or older than the repair, confirm the server connected, then ask it to save the PNG again. If the demo item fails, revisit Your turn step 5: removing the script or swallowing its error doesn't repair the count.
Watch out
- A
claude -prun loads a project's servers without asking (Project scope). Read a repository's.mcp.jsonbefore you script Claude Code in it. A quiet tool call in auto mode doesn't prove that you granted a permanent permission. - To be asked about a project's servers again, run
claude mcp reset-project-choices, then restart Claude Code. If you missed the approval prompt, open/mcpto approve the server there.
Third-party: it can run code on your machine or give Claude new tools. Review it before installing; this guide does not audit it.
Listings checked against the listing bar on 2026-10-06.
Go further
- Connect to MCP servers: adding remote servers, signing in to them, and other ways to add one.
- The MCP Registry: the MCP project's list of public servers, which it labels "preview" (About).
- What is the Model Context Protocol (MCP)?: the protocol itself.
Sources: Connect Claude Code to tools via MCP · Connect to MCP servers · Configure permissions · Choose a permission mode · Chrome DevTools MCP README · Chrome DevTools MCP configuration · Chrome DevTools MCP tools · The MCP Registry
← Delegate to a custom subagent · Intermediate index · Install and manage plugins → · Topic: MCP · Stuck on this lesson?