Want an AI that works for you 24/7? Get the Free Blueprint href="/blueprint">Meet your Chief AI Officer →rarr;
Guide

How to Connect Claude Code to External Tools (MCP Guide)

Unlock Claude Code's full potential by connecting it to Slack, databases, APIs, and more. Complete guide to the Model Context Protocol ecosystem.

Updated February 10, 2026 · 14 min read

You connect Claude Code to external tools using MCP (Model Context Protocol) — an open-source standard by Anthropic that lets Claude talk to Slack, databases, GitHub, Notion, and virtually any API through lightweight server plugins you configure in a JSON file. Once set up, Claude can query your database, send messages, and call APIs directly from your terminal.

This guide covers everything from installing your first MCP server to building custom integrations, with step-by-step setup for the most popular tools freelancers and teams actually use.

New to Claude Code? Watch the free CAIO Blueprint to see it in action.

Understanding MCP: The Bridge to External Tools

MCP stands for Model Context Protocol. Think of it as a universal translator between Claude Code and external services. Instead of Claude only working with files on your computer, MCP lets it:

The protocol is open-source and created by Anthropic, which means it's designed specifically for Claude and actively maintained.

How MCP Works

MCP uses a client-server architecture with three transport types:

  1. MCP Server: A small program that knows how to talk to a specific service (like Slack or PostgreSQL)
  2. MCP Client: Claude Code itself, which connects to these servers
  3. Transport: How they communicate — HTTP (recommended for remote cloud services), SSE (older remote servers), or stdio (local processes on your machine)

When you ask Claude to "send a message to the #marketing channel," it routes that request through the Slack MCP server, which handles the actual API call.

Key benefit: Stdio MCP servers run locally on your machine. HTTP servers connect directly to cloud services. In both cases, your data goes between your machine and the service — not through Anthropic.

Claude Code also supports OAuth 2.0 authentication for remote HTTP servers. After adding a server, run /mcp inside Claude Code to authenticate through your browser. Tokens are stored securely and refreshed automatically.

Popular MCP Tool Integrations

The MCP ecosystem has grown rapidly. Here are the most useful integrations for non-technical users:

Communication Tools

Tool What Claude Can Do Use Case
Slack Send messages, read channels, search history Automated updates, team notifications
Gmail Read, compose, and send emails Email automation, bulk responses
Discord Post messages, manage channels Community management

Data and Storage

Tool What Claude Can Do Use Case
PostgreSQL Query, insert, update data Reports, data analysis
SQLite Full database operations Local data management
Google Drive Read and create documents Document automation
Notion Read and update pages, databases Knowledge base management

Development and APIs

Tool What Claude Can Do Use Case
GitHub Create issues, PRs, read repos Project management
Fetch/HTTP Call any REST API Custom integrations
Puppeteer Browser automation Web scraping, testing

Step-by-Step: Connecting Your First MCP Server

Let's walk through connecting Claude Code to Slack as an example. The process is similar for other tools.

Step 1: Get Your API Credentials

For Slack, you'll need to create a Slack App:

  1. Go to api.slack.com/apps
  2. Click "Create New App" and choose "From scratch"
  3. Give it a name and select your workspace
  4. Under "OAuth & Permissions," add scopes like chat:write, channels:read, channels:history
  5. Install the app to your workspace
  6. Copy the "Bot User OAuth Token" (starts with xoxb-)

Step 2: Add the MCP Server via CLI

The recommended way to add MCP servers is through the claude mcp add command. Open your terminal and run:

claude mcp add --transport stdio --scope user \
  --env SLACK_BOT_TOKEN=xoxb-your-token-here \
  --env SLACK_TEAM_ID=T01234567 \
  slack -- npx -y @modelcontextprotocol/server-slack

This adds the Slack server at the user scope, so it is available in all your projects. All options must come before the server name, and -- separates your options from the server command.

Alternative: Edit Configuration File Directly

You can also configure servers by editing configuration files. For team-shared servers, create a .mcp.json file in your project root:

{
  "mcpServers": {
    "slack": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-slack"],
      "env": {
        "SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}",
        "SLACK_TEAM_ID": "${SLACK_TEAM_ID}"
      }
    }
  }
}

Using ${SLACK_BOT_TOKEN} syntax lets you reference environment variables, so each team member can supply their own token without it being hardcoded in the file.

Step 3: Test the Connection

Start Claude Code and try a simple command:

Send a message to the #general channel saying "Hello from Claude Code!"

If everything is configured correctly, Claude will use the Slack MCP server to post the message.

Tip: Use the /mcp command in Claude Code to see which servers are connected and their status. Run claude mcp list from the terminal to see all configured servers. Run claude mcp get slack to test a specific connection.

Connecting to Databases

Database access is one of the most powerful MCP use cases. Here's how to connect to PostgreSQL:

PostgreSQL Configuration

Using the CLI command:

claude mcp add --transport stdio --scope user db -- npx -y @bytebase/dbhub \
  --dsn "postgresql://readonly:password@localhost:5432/mydb"

Or in a configuration file:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@bytebase/dbhub", "--dsn", "postgresql://user:password@localhost:5432/mydb"]
    }
  }
}

Once connected, you can ask Claude things like:

Security note: For production databases, always use read-only credentials when possible. Create a dedicated database user with limited permissions for Claude Code access.

Building Custom MCP Servers

What if there's no MCP server for a tool you need? You can build your own. Official SDKs are available in Python, TypeScript, and other languages. MCP is an interoperable protocol, so a server built in TypeScript can be used by any MCP-capable client.

When to Build Custom

Basic Structure (Python with FastMCP)

The Python SDK includes FastMCP, a high-level framework for building servers quickly:

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("my-custom-tool")

@mcp.tool()
async def get_customer_data(customer_id: str) -> str:
    """Fetch customer data from our internal CRM."""
    # Your API call logic here
    response = await internal_crm.get_customer(customer_id)
    return str(response)

if __name__ == "__main__":
    mcp.run()

Basic Structure (TypeScript)

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

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

server.tool("get_customer_data",
  { customer_id: z.string() },
  async ({ customer_id }) => {
    // Your API call logic here
    const response = await getCustomer(customer_id);
    return { content: [{ type: "text", text: JSON.stringify(response) }] };
  }
);

server.run();

The MCP SDK handles all protocol communication, type safety, and transport management. You just define what tools to expose and what they do.

Resources for Building

Security Considerations

Connecting Claude Code to external tools means giving it real access to real systems. Here's how to do it safely:

Principle of Least Privilege

Environment Variables

Never hardcode credentials in configuration files that might be shared. Use environment variable expansion in .mcp.json:

{
  "mcpServers": {
    "slack": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-slack"],
      "env": {
        "SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}",
        "SLACK_TEAM_ID": "${SLACK_TEAM_ID}"
      }
    }
  }
}

The ${VAR} syntax is expanded at runtime from your shell environment. You can also use ${VAR:-default} for fallback values. This way the .mcp.json file can be safely checked into version control.

For HTTP servers that support OAuth, you don't need to manage tokens at all. Add the server and use /mcp in Claude Code to authenticate through your browser.

Audit and Monitor

Never connect to production databases without careful consideration. Start with development or staging environments, and use read-only access.

Common Mistakes to Avoid

1. Overcomplicating Initial Setup

Start with one MCP server. Get it working. Then add more. Trying to connect everything at once leads to debugging nightmares.

2. Using Production Credentials

Always start with test environments and limited-permission credentials. Upgrade access only when you've verified the setup works correctly.

3. Forgetting to Restart

MCP configuration changes require restarting Claude Code. If a new server isn't appearing, restart first before debugging. You can also use claude mcp get [server-name] from the terminal to test a connection directly.

4. Ignoring Rate Limits

External APIs have rate limits. If Claude makes many rapid requests, you might hit them. Be aware of limits for each service you connect.

5. Not Testing Incrementally

After each configuration change, test with a simple command before moving on. This makes it easy to identify which change caused an issue.

MCP Server Scopes

When adding servers, you can control their visibility with the --scope flag:

# Add for all your projects
claude mcp add --transport http --scope user notion https://mcp.notion.com/mcp

# Add for the team (creates .mcp.json)
claude mcp add --transport http --scope project sentry https://mcp.sentry.dev/mcp

Frequently Asked Questions

What is MCP in Claude Code?

MCP (Model Context Protocol) is an open standard that allows Claude Code to connect to external tools and services. It supports three transport types: HTTP for remote cloud services (recommended), SSE for older remote servers, and stdio for local processes. Servers can run locally on your machine or connect to remote cloud APIs.

How do I connect Claude Code to Slack?

Run claude mcp add --transport stdio --scope user --env SLACK_BOT_TOKEN=xoxb-your-token --env SLACK_TEAM_ID=T01234567 slack -- npx -y @modelcontextprotocol/server-slack in your terminal. Then restart Claude Code. You can send messages and read channels directly from Claude using natural language.

Can Claude Code access databases?

Yes, Claude Code can connect to PostgreSQL, MySQL, SQLite, and other databases through MCP servers. This allows you to query data, generate reports, and even modify database records using natural language commands.

Is MCP secure for sensitive data?

MCP servers run locally on your machine, so data doesn't pass through third-party servers. However, you should use read-only access where possible, restrict permissions to the minimum needed, and never expose production databases without proper safeguards.

Can I build my own MCP server?

Yes, you can build custom MCP servers using the official SDKs. The Python SDK includes FastMCP for rapid development, and the TypeScript SDK uses Zod for type safety. Both handle protocol compliance and transport management automatically. Servers are interoperable — a TypeScript server works with any MCP client.

Like Claude Code? Meet Your Chief AI Officer

Watch our free training video to see MCP integrations in action. Learn how to connect Claude to your entire tech stack.

Get the Free Blueprint href="/blueprint" class="cta-btn">Watch the Free Setup Video →rarr;