Claude Code/
Lesson

You understand what MCPWhat is mcp?Model Context Protocol - a standard that lets AI tools connect to external services like databases, issue trackers, or APIs. is. Now let's use it. This lesson covers where to find MCP servers, how to configure them, and what to watch out for.

Finding MCPWhat is mcp?Model Context Protocol - a standard that lets AI tools connect to external services like databases, issue trackers, or APIs. servers

MCP servers are distributed as regular packages, mostly npm packages or standalone executables. Here are the main places to find them:

  • Anthropic's official directory: A curated list of verified servers at the MCP documentation site
  • npm registryWhat is registry?A server that stores and distributes packages or container images - npm registry for JavaScript packages, Docker Hub for container images.: Search for @modelcontextprotocol/server-* for official servers, or browse community packages tagged with mcp
  • GitHub: Many developers publish MCP servers as open-source repos
  • Community lists: Curated "awesome-mcp" lists on GitHub with categorized servers

The official servers maintained by Anthropic cover the most common use cases: filesystem access, GitHub, PostgreSQL, Slack, Google Drive, and more.

02

Configuring servers in Claude Desktop

Claude Desktop reads its MCPWhat is mcp?Model Context Protocol - a standard that lets AI tools connect to external services like databases, issue trackers, or APIs. configuration from a JSONWhat is json?A text format for exchanging data between systems. It uses key-value pairs and arrays, and every programming language can read and write it. file called claude_desktop_config.json. The location depends on your operating system:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Here is a basic configuration with a filesystem server:

json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/projects"],
      "env": {}
    }
  }
}

Let's break this down:

  • "filesystem", the name you give this server (can be anything descriptive)
  • "command", the command to start the server (npx runs it directly from npm)
  • "args", arguments passed to the command: -y auto-confirms the install, the package name, and the directory to expose
  • "env", environment variables the server needs (empty here, but used for APIWhat is api?A set of rules that lets one program talk to another, usually over the internet, by sending requests and getting responses. keys)

After saving this file and restarting Claude Desktop, you will see a hammer icon in the input bar indicating MCP tools are available.

Good to know
The JSON config file must be valid JSON, a single missing comma or extra trailing comma will silently break all your MCP connections. If servers aren't appearing, validate your JSON first (paste it into a JSON linter).
03

Configuring servers in Claude Code

Claude Code has a built-in command for adding MCPWhat is mcp?Model Context Protocol - a standard that lets AI tools connect to external services like databases, issue trackers, or APIs. servers:

# Add a filesystem server
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /Users/you/projects

# Add a GitHub server with an environment variable
claude mcp add github -e GITHUB_TOKEN=ghp_xxxxxxxxxxxx -- npx -y @modelcontextprotocol/server-github

# List configured servers
claude mcp list

# Remove a server
claude mcp remove filesystem

The claude mcp add syntax is: claude mcp add <name> [flags] -- <command> [args...]. The -- separates Claude Code flags from the server command.

04

Common MCPWhat is mcp?Model Context Protocol - a standard that lets AI tools connect to external services like databases, issue trackers, or APIs. servers

Here are the most widely used MCP servers and what they provide:

ServerPackageCapabilitiesUse case
Filesystem@modelcontextprotocol/server-filesystemRead, write, search filesLet Claude access project files
GitHub@modelcontextprotocol/server-githubIssues, PRs, repos, branchesCode review, issue management
PostgreSQL@modelcontextprotocol/server-postgresRead-only SQL queries, schema inspectionDatabase analysis and debugging
Slack@modelcontextprotocol/server-slackRead channels, post messagesTeam communication via AI
Google Drive@modelcontextprotocol/server-gdriveRead, search documentsDocument analysis
Memory@modelcontextprotocol/server-memoryPersistent key-value storeLet Claude remember things across sessions
Puppeteer@modelcontextprotocol/server-puppeteerBrowser automation, screenshotsWeb scraping, testing
Brave Search@modelcontextprotocol/server-brave-searchWeb searchGive Claude internet access
05

A multi-server configuration

You can configure multiple servers at once. Here is a realistic developer setup:

json
{
  "mcpServers": {
    "project-files": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/projects/my-app"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      }
    },
    "database": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": {
        "DATABASE_URL": "postgres://readonly_user:password@localhost:5432/myapp_dev"
      }
    }
  }
}

With this configuration, Claude can read your project files, check your GitHub issues and PRs, and query your development database, all in one conversation.

AI pitfall
AI-generated MCP configurations sometimes use incorrect package names or outdated argument formats. Always check the official MCP documentation for the exact package name and required arguments. A common mistake AI makes is omitting the -y flag for npx, which causes the install to hang waiting for confirmation.
06

Verifying your connection

After configuring a server, verify it is working:

  1. Claude Desktop: Look for the hammer icon in the input bar. Click it to see available tools. If the icon is missing, check your JSONWhat is json?A text format for exchanging data between systems. It uses key-value pairs and arrays, and every programming language can read and write it. file for syntax errors.
  2. Claude Code: Run claude mcp list and confirm your server appears with status "connected".
  3. Test with a simple request: Ask Claude something that requires the server. For a filesystem server, ask "What files are in my project directory?" If Claude can answer, the server is connected.

Common connection errors

ErrorCauseFix
Server not appearingJSON syntax errorValidate your JSON (use a linter or paste into jsonlint.com)
"Tool execution failed"Missing environment variableCheck the env section, does the server need an API key?
"Connection refused"Server command not foundMake sure npx is in your PATH and you have Node.js installed
Server appears but no toolsWrong argumentsCheck the server's documentation for required args
07

Security: the principle of least privilege

MCPWhat is mcp?Model Context Protocol - a standard that lets AI tools connect to external services like databases, issue trackers, or APIs. servers run on your machine with your permissions. This is powerful, and dangerous if misconfigured.

Rule 1: ScopeWhat is scope?The area of your code where a variable is accessible; variables declared inside a function or block are invisible outside it. access narrowly

Bad: give the filesystem server access to your entire home directory

json
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you"]

Good: scope it to just the project you are working on

json
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/projects/my-app"]

Rule 2: Use read-only access when possible

If Claude only needs to read your database, connect with a read-only database user. Do not give it the admin password.

Rule 3: Avoid hardcoding secrets

Instead of putting APIWhat is api?A set of rules that lets one program talk to another, usually over the internet, by sending requests and getting responses. keys directly in your config file, reference environment variables:

json
"env": {
  "GITHUB_TOKEN": "${GITHUB_TOKEN}"
}

Then set the variable in your shell profile (~/.zshrc or ~/.bashrc):

export GITHUB_TOKEN="ghp_your_actual_token"

Rule 4: Review third-party servers

Before installing a community MCP server, check:

  • Is the source code public? Can you read what it does?
  • Does it request more permissions than it needs?
  • Is it actively maintained?
  • Do other developers use and trust it?

Treat MCP servers like browser extensions: useful, but worth inspecting before you install.

Edge case
If you reference environment variables with ${VAR_NAME} syntax but the variable isn't set, the server will start with an empty string for that value. This often leads to confusing "authentication failed" errors rather than a clear "missing environment variable" message. Always verify your variables are set with echo $VAR_NAME before configuring the server.