MCP Server Setup Guide (Full Tutorial)

MCPSetup

A complete guide to setting up and configuring MCP servers for your AI agents.

MCP Server Setup Guide (Full Tutorial)

Introduction

The Model Context Protocol (MCP) is an open standard that enables AI models to connect with data sources and tools. This guide will walk you through setting up your first MCP server.

What is MCP?

MCP provides a standardized way for AI assistants to access external data and tools. Instead of building custom integrations for each data source, MCP gives you a universal connector.

Key Concepts

  • Host: The AI application (Claude Desktop, Cursor, etc.)
  • Server: The MCP server that provides tools and resources
  • Client: The bridge between host and server

Quick Start

1. Install the MCP CLI

npm install -g @modelcontextprotocol/cli

2. Run a Pre-built Server

npx -y @modelcontextprotocol/server-github

3. Configure in Claude Desktop

Add to your claude_desktop_config.json:

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

Restart Claude Desktop and the MCP server will be available.

Building Your Own MCP Server

Step 1: Create a New Project

npx @modelcontextprotocol/create-server my-server
cd my-server
npm install

Step 2: Define Your Tools

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";

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

server.setRequestHandler(CallToolRequestSchema, async (request) => {
  if (request.params.name === "my-tool") {
    return {
      content: [{
        type: "text",
        text: "Hello from my tool!",
      }],
    };
  }
  throw new Error("Tool not found");
});

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

Step 3: Build and Configure

npm run build

Add to Claude Desktop config:

{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["dist/index.js"]
    }
  }
}

Available Pre-built Servers

ServerDescriptionInstall
GitHubRepository access@modelcontextprotocol/server-github
PostgreSQLDatabase queries@modelcontextprotocol/server-postgres
NotionWorkspace content@modelcontextprotocol/server-notion
SlackTeam communication@modelcontextprotocol/server-slack
Brave SearchWeb search@modelcontextprotocol/server-brave-search

Troubleshooting

IssueSolution
Server not showing upCheck config file path
Authentication errorsVerify token is valid
Connection refusedCheck command and args
Tools not availableRestart host application

Resources