Tutorials4 min read

Getting Started with MCP Servers for Claude

Model Context Protocol (MCP) servers extend Claude's capabilities with custom tools. Learn how to install, configure, and build MCP servers.

ShareXInFb
Getting Started with MCP Servers for Claude
Table of Contents

Getting Started with MCP Servers for Claude

Model Context Protocol (MCP) is Anthropic's open standard for connecting Claude to external tools and data sources. MCP servers are the bridge that makes this possible.

What is MCP?

MCP (Model Context Protocol) allows Claude to:

  • Access databases and APIs
  • Read and write files
  • Execute code
  • Interact with external services
  • Use custom tools you define

Think of MCP servers as plugins that extend what Claude can do beyond just generating text.

How MCP Works

┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Claude    │────▶│ MCP Client  │────▶│ MCP Server  │
│  (Claude    │     │  (Claude    │     │  (Your      │
│   Desktop)  │     │   Desktop)  │     │   Tools)    │
└─────────────┘     └─────────────┘     └─────────────┘
                                               │
                                               ▼
                                        ┌─────────────┐
                                        │  External   │
                                        │  Services   │
                                        │  (DB, API)  │
                                        └─────────────┘

Installing Your First MCP Server

Step 1: Configure Claude Desktop

Find your Claude Desktop config file:

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

Step 2: Add the Server Configuration

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"]
    }
  }
}

Step 3: Restart Claude Desktop

Close and reopen Claude Desktop. You should see a hammer icon (🔨) indicating tools are available.

1. Filesystem Server

Access files and directories:

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

2. GitHub Server

Interact with GitHub repos:

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

3. PostgreSQL Server

Query your database:

{
  "postgres": {
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@localhost/db"]
  }
}

Building Your Own MCP Server

Basic Structure (TypeScript)

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

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

// Define a tool
server.setRequestHandler("tools/list", async () => ({
  tools: [
    {
      name: "get_weather",
      description: "Get current weather for a location",
      inputSchema: {
        type: "object",
        properties: {
          location: { type: "string", description: "City name" }
        },
        required: ["location"]
      }
    }
  ]
}));

// Handle tool calls
server.setRequestHandler("tools/call", async (request) => {
  if (request.params.name === "get_weather") {
    const location = request.params.arguments.location;
    // Your implementation here
    return { content: [{ type: "text", text: `Weather in ${location}: Sunny, 72°F` }] };
  }
});

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

Package.json

{
  "name": "my-mcp-server",
  "version": "1.0.0",
  "type": "module",
  "bin": {
    "my-mcp-server": "./dist/index.js"
  },
  "dependencies": {
    "@modelcontextprotocol/sdk": "^1.0.0"
  }
}

Best Practices

1. Security First

  • Never expose sensitive operations without authentication
  • Validate all inputs from Claude
  • Use environment variables for secrets

2. Clear Descriptions

Claude uses tool descriptions to decide when to use them. Be specific:

{
  name: "search_codebase",
  description: "Search for code patterns, function definitions, or file contents in the current project. Use this when you need to find existing implementations or understand how something is done in the codebase."
}

3. Handle Errors Gracefully

try {
  const result = await riskyOperation();
  return { content: [{ type: "text", text: JSON.stringify(result) }] };
} catch (error) {
  return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true };
}

Browse MCP Servers

Don't want to build from scratch? Our marketplace has pre-built MCP servers for:

  • Database integrations (PostgreSQL, MongoDB, Redis)
  • API connectors (Stripe, Slack, GitHub)
  • Development tools (Docker, AWS, Kubernetes)
  • Custom business logic (domain-specific solutions)

Each server comes with documentation, example configurations, and community support.