Connecting Claude Desktop to MCP Server: Step-by-Step Guide

This is a quick note to connect Claude Desktop to an MCP (Model Context Protocol) server.

Introduction

Since Claude Desktop is made by Anthropic, the originator of MCP, it has had built-in support as MCP clients from an early stage.

Until now, I’ve been using GPT/OpenAI APIs to connect with MCP servers. I haven’t tried using Claude Desktop with an MCP server before.

This post is a quick note on how to connect Claude Desktop to an MCP server.

Note: This article was translated from my original post.

How to Connect Claude Desktop to an MCP Server

Follow the steps below to connect Claude Desktop to an MCP server:

  1. Add MCP server information to the Claude Desktop config file
  2. Restart Claude Desktop

1. Add MCP Server Information to the Config File

First, from the top tab of Claude Desktop:

"Claude" > "Settings..."

Click that, and from the settings window that appears, select:

"Developer" > "Edit Config"

Select "Claude" > "Settings..."

Select "Developer" > "Edit Config"

Then Claude Desktop will automatically open the location of the claude_desktop_config.json file in Finder, so open it with any editor.

Location of claude_desktop_config.json:

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

In the claude_desktop_config.json file, specify the MCP server startup command in the following format:

{
  "mcpServers": {
    "<mcp server name>": {
      "command": "<server startup command>",
      "args": [
        // Add the arguments for the startup command here
      ],
      "env": {
        // If needed, set environment variables here as key-value pairs
        "<ENV Key>": "<ENV Value>"
      }
    }
  }
}

The JSON needed here is usually included in the README or documentation of the MCP server.

For example, to launch and connect to the PostgreSQL MCP server, use the following config:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ]
    }
  }
}

This starts the PostgreSQL MCP server using the command npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb and connects it to Claude Desktop.

2. Restart Claude Desktop

Once the settings in claude_desktop_config.json are updated, restart Claude Desktop. The changes will be applied, and the MCP server will be connected.

You can check the tools provided by the connected MCP server from the hammer icon in Claude Desktop.

You can check the available tools provided by the connected MCP server from the hammer icon

Example of available tools listed

Conclusion

That’s a quick note on how to connect Claude Desktop to an MCP server.

Hope this helps someone!

[Related Articles]

en.bioerrorlog.work

en.bioerrorlog.work

References