Ad Space (horizontal)
Advanced

Claude Code MCP Server Setup and Practical Use Cases

A comprehensive guide to Claude Code's MCP server capabilities. Learn how to connect external tools, configure servers, and explore real-world integration examples.

What Is MCP?

MCP (Model Context Protocol) is an open protocol for connecting AI assistants to external tools and data sources. Claude Code acts as an MCP client, enabling it to interact with databases, APIs, and various services through MCP servers.

Configuring MCP Servers

MCP server settings go in .claude/settings.json or ~/.claude/settings.json:

{
  "mcpServers": {
    "server-name": {
      "command": "executable-command",
      "args": ["arg1", "arg2"],
      "env": {
        "ENV_VAR": "value"
      }
    }
  }
}

You can also add servers via the CLI:

claude mcp add server-name -- command arg1 arg2

Example 1: Database Integration

Set up an MCP server to run queries directly against PostgreSQL:

claude mcp add postgres-server -- npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@localhost:5432/mydb

Once configured, you can query your database from within a Claude Code session:

> Count the new user registrations from the past week in the users table
> Show the daily trend in a table format

Claude Code automatically generates and executes SQL queries, then formats the results for you.

Example 2: GitHub Integration

The GitHub MCP server lets you manage issues and PRs directly from Claude Code:

claude mcp add github -- npx -y @modelcontextprotocol/server-github

Set up the token via environment variables:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxx"
      }
    }
  }
}

Here’s what you can do:

> List all open issues in the repository
> Look at Issue #42, create a fix branch, and implement the solution
> Once the fix is done, create a PR

Example 3: Filesystem Extension

An MCP server that provides safe access to a specific directory:

claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/directory

Example 4: Web Scraping

The Puppeteer MCP server enables web page fetching and interaction:

claude mcp add puppeteer -- npx -y @modelcontextprotocol/server-puppeteer
> Read the API documentation at https://example.com/api/docs
> and create a client library for that API

Example 5: Slack Integration

The Slack MCP server lets you read messages from channels and send notifications:

{
  "mcpServers": {
    "slack": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-slack"],
      "env": {
        "SLACK_BOT_TOKEN": "xoxb-xxxxxxxxxxxx"
      }
    }
  }
}
> Check the latest messages in #dev
> Post today's progress update to #daily-report

Managing MCP Servers

List Registered Servers

claude mcp list

Remove a Server

claude mcp remove server-name

Setting the Scope

You can specify the configuration scope for MCP servers:

# Project-local (default)
claude mcp add --scope project db-server -- command

# User-global
claude mcp add --scope user db-server -- command

Building a Custom MCP Server

You can also create project-specific tools as custom MCP servers:

// my-mcp-server.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer({
  name: "my-project-tools",
  version: "1.0.0",
});

// Define a custom tool
server.tool(
  "deploy-staging",
  "Deploy to the staging environment",
  { branch: z.string().describe("Branch name to deploy") },
  async ({ branch }) => {
    // Deployment logic
    return {
      content: [{ type: "text", text: `Deployed ${branch} to staging` }],
    };
  }
);

const transport = new StdioServerTransport();
await server.connect(transport);

Register it like this:

claude mcp add my-tools -- npx tsx my-mcp-server.ts

Security Considerations

1. Credential Management

Tokens and passwords in MCP server configs should be managed through environment variables or .env files. Never commit them to Git.

2. Limit Access Scope

Follow the principle of least privilege — for example, use a read-only database user for your database MCP server.

3. Use Local Settings

Store configs containing credentials in .claude/settings.local.json and add it to .gitignore.

Conclusion

MCP servers let you extend Claude Code’s capabilities across your entire project ecosystem. From database queries to GitHub workflows to Slack notifications, you can use Claude Code as the central hub of your development workflow. Start with the official MCP servers, then build custom ones as needed.

Ad Space (rectangle)
#Claude Code #MCP #MCP server #integrations #extensions