Table of contents

How do I Install an MCP Server on My System?

Installing a Model Context Protocol (MCP) server on your system enables you to extend AI assistants with custom tools, data sources, and integrations. This guide provides comprehensive instructions for setting up MCP servers across different platforms and programming languages.

Understanding MCP Server Architecture

Before installation, it's important to understand that MCP servers act as bridges between AI applications and external resources. They communicate via standard input/output (stdio) or server-sent events (SSE), making them language-agnostic and easy to integrate.

Prerequisites

Before installing an MCP server, ensure you have:

  • Node.js (version 16 or higher) for JavaScript/TypeScript servers
  • Python (version 3.8 or higher) for Python-based servers
  • Git for cloning repositories
  • Administrative/sudo privileges for system-wide installations
  • A compatible MCP client (like Claude Desktop, Cline, or other MCP-enabled applications)

Installing a Node.js MCP Server

Step 1: Install the MCP SDK

First, create a new directory for your MCP server and initialize a Node.js project:

mkdir my-mcp-server
cd my-mcp-server
npm init -y

Install the official MCP SDK:

npm install @modelcontextprotocol/sdk

Step 2: Create Your Server

Create a file named index.js with a basic MCP server:

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

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

// Define available tools
server.setRequestHandler(ListToolsRequestSchema, async () => {
  return {
    tools: [
      {
        name: "fetch_webpage",
        description: "Fetches HTML content from a webpage",
        inputSchema: {
          type: "object",
          properties: {
            url: {
              type: "string",
              description: "The URL to fetch",
            },
          },
          required: ["url"],
        },
      },
    ],
  };
});

// Handle tool execution
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  if (request.params.name === "fetch_webpage") {
    const url = request.params.arguments.url;
    const response = await fetch(url);
    const html = await response.text();

    return {
      content: [
        {
          type: "text",
          text: html,
        },
      ],
    };
  }

  throw new Error(`Unknown tool: ${request.params.name}`);
});

// Start server
async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error("MCP Server running on stdio");
}

main().catch(console.error);

Step 3: Configure the Server in Your Client

Add the server configuration to your MCP client. For Claude Desktop, edit the configuration file:

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

{
  "mcpServers": {
    "my-scraping-server": {
      "command": "node",
      "args": ["/absolute/path/to/my-mcp-server/index.js"]
    }
  }
}

Installing a Python MCP Server

Step 1: Set Up Python Environment

Create a virtual environment and install the MCP SDK:

mkdir my-python-mcp-server
cd my-python-mcp-server
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install mcp

Step 2: Create the Server

Create a file named server.py:

import asyncio
import json
from mcp.server.models import InitializationOptions
from mcp.server import NotificationOptions, Server
from mcp.server.stdio import stdio_server
from mcp.types import (
    Tool,
    TextContent,
    CallToolRequest,
    CallToolResult,
)
import httpx

# Create server instance
server = Server("python-scraping-server")

@server.list_tools()
async def handle_list_tools() -> list[Tool]:
    """List available tools."""
    return [
        Tool(
            name="scrape_url",
            description="Scrapes content from a URL",
            inputSchema={
                "type": "object",
                "properties": {
                    "url": {
                        "type": "string",
                        "description": "URL to scrape",
                    },
                    "selector": {
                        "type": "string",
                        "description": "CSS selector for content extraction",
                    },
                },
                "required": ["url"],
            },
        )
    ]

@server.call_tool()
async def handle_call_tool(
    name: str, arguments: dict
) -> list[TextContent]:
    """Handle tool execution."""
    if name == "scrape_url":
        url = arguments["url"]

        async with httpx.AsyncClient() as client:
            response = await client.get(url)
            content = response.text

        return [
            TextContent(
                type="text",
                text=f"Successfully scraped {url}\n\nContent preview:\n{content[:500]}..."
            )
        ]
    else:
        raise ValueError(f"Unknown tool: {name}")

async def main():
    """Run the server."""
    async with stdio_server() as (read_stream, write_stream):
        await server.run(
            read_stream,
            write_stream,
            InitializationOptions(
                server_name="python-scraping-server",
                server_version="1.0.0",
                capabilities=server.get_capabilities(
                    notification_options=NotificationOptions(),
                    experimental_capabilities={},
                ),
            ),
        )

if __name__ == "__main__":
    asyncio.run(main())

Step 3: Configure Client for Python Server

Update your MCP client configuration:

{
  "mcpServers": {
    "python-scraping-server": {
      "command": "python",
      "args": ["/absolute/path/to/my-python-mcp-server/server.py"]
    }
  }
}

Installing Pre-built MCP Servers

Many ready-to-use MCP servers are available. Here's how to install popular ones:

Installing the Playwright MCP Server

The Playwright MCP server enables browser automation similar to handling browser sessions in Puppeteer, but through the MCP protocol:

npm install -g @executeautomation/playwright-mcp-server

Configure in your MCP client:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["-y", "@executeautomation/playwright-mcp-server"]
    }
  }
}

Installing the Filesystem MCP Server

For file operations:

npm install -g @modelcontextprotocol/server-filesystem

Configuration:

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

Installing the WebScraping.AI MCP Server

For advanced web scraping with AI capabilities:

npm install -g @webscraping-ai/mcp-server

Configure with your API key:

{
  "mcpServers": {
    "webscraping-ai": {
      "command": "npx",
      "args": ["-y", "@webscraping-ai/mcp-server"],
      "env": {
        "WEBSCRAPING_AI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Platform-Specific Installation Notes

macOS Installation

On macOS, you may need to grant permissions for the MCP server to run:

chmod +x /path/to/your/server.js

If you encounter security warnings, go to System Preferences > Security & Privacy and allow the application to run.

Windows Installation

On Windows, ensure your PATH includes Node.js and Python directories. You may need to use absolute paths in your configuration:

{
  "mcpServers": {
    "my-server": {
      "command": "C:\\Program Files\\nodejs\\node.exe",
      "args": ["C:\\path\\to\\server.js"]
    }
  }
}

Linux Installation

On Linux, you might need to install additional dependencies:

# For Node.js servers
sudo apt-get update
sudo apt-get install nodejs npm

# For Python servers
sudo apt-get install python3 python3-pip python3-venv

Verifying Your Installation

After installation, verify your MCP server is working:

Check Server Logs

Most MCP clients log server communication. For Claude Desktop:

macOS: ~/Library/Logs/Claude/ Windows: %APPDATA%\Claude\logs\

Test Server Communication

Create a simple test script:

// test-mcp-connection.js
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

const transport = new StdioClientTransport({
  command: "node",
  args: ["./index.js"],
});

const client = new Client(
  {
    name: "test-client",
    version: "1.0.0",
  },
  {
    capabilities: {},
  }
);

await client.connect(transport);
const tools = await client.listTools();
console.log("Available tools:", tools);

Troubleshooting Common Installation Issues

"Command not found" Errors

Ensure the command executable is in your system PATH:

# Check Node.js
which node

# Check Python
which python3

# Add to PATH if needed (Linux/macOS)
export PATH=$PATH:/path/to/executable

Permission Denied Errors

Grant execute permissions:

chmod +x server.js
chmod +x server.py

Module Not Found Errors

Reinstall dependencies:

# Node.js
rm -rf node_modules package-lock.json
npm install

# Python
pip install --force-reinstall mcp

Port Already in Use

If using SSE transport, ensure the port is available:

# Check port usage
lsof -i :3000  # macOS/Linux
netstat -ano | findstr :3000  # Windows

Advanced Configuration

Environment Variables

Pass environment variables to your MCP server:

{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["server.js"],
      "env": {
        "API_KEY": "your-api-key",
        "DEBUG": "true",
        "TIMEOUT": "30000"
      }
    }
  }
}

Using with Docker

You can containerize your MCP server, similar to using Puppeteer with Docker:

FROM node:18-alpine

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .

CMD ["node", "index.js"]

Run the containerized server:

docker build -t my-mcp-server .
docker run -i my-mcp-server

Configure in your MCP client:

{
  "mcpServers": {
    "docker-server": {
      "command": "docker",
      "args": ["run", "-i", "my-mcp-server"]
    }
  }
}

Best Practices

  1. Use Virtual Environments: Always isolate Python dependencies in virtual environments
  2. Version Control: Track your server code and configuration in Git
  3. Error Handling: Implement robust error handling similar to handling errors in Puppeteer
  4. Logging: Add comprehensive logging for debugging
  5. Security: Never hardcode API keys; use environment variables
  6. Testing: Write tests for your MCP tools before deployment
  7. Documentation: Document your tools' capabilities and parameters

Next Steps

After installing your MCP server, you can:

  • Explore the Model Context Protocol documentation
  • Build custom tools for web scraping and data extraction
  • Integrate multiple MCP servers for comprehensive workflows
  • Share your MCP servers with the community

With your MCP server properly installed and configured, you can now leverage the power of AI-assisted automation for web scraping, data processing, and much more.

Try WebScraping.AI for Your Web Scraping Needs

Looking for a powerful web scraping solution? WebScraping.AI provides an LLM-powered API that combines Chromium JavaScript rendering with rotating proxies for reliable data extraction.

Key Features:

  • AI-powered extraction: Ask questions about web pages or extract structured data fields
  • JavaScript rendering: Full Chromium browser support for dynamic content
  • Rotating proxies: Datacenter and residential proxies from multiple countries
  • Easy integration: Simple REST API with SDKs for Python, Ruby, PHP, and more
  • Reliable & scalable: Built for developers who need consistent results

Getting Started:

Get page content with AI analysis:

curl "https://api.webscraping.ai/ai/question?url=https://example.com&question=What is the main topic?&api_key=YOUR_API_KEY"

Extract structured data:

curl "https://api.webscraping.ai/ai/fields?url=https://example.com&fields[title]=Page title&fields[price]=Product price&api_key=YOUR_API_KEY"

Try in request builder

Related Questions

Get Started Now

WebScraping.AI provides rotating proxies, Chromium rendering and built-in HTML parser for web scraping
Icon