MCP Server Installation Guide

This guide provides detailed instructions for installing and configuring various types of MCP (Model Context Protocol) servers to work with Pylee.

Prerequisites

Before installing any MCP server, ensure you have:

  • Node.js (v18 or later) for JavaScript/TypeScript servers
  • Python (v3.8 or later) for Python servers
  • Git for cloning repositories
  • Command line access with appropriate permissions

Installation Methods

The fastest way to get started with official MCP servers:

# Install and run a server directly
npx -y @modelcontextprotocol/server-filesystem /path/to/directory

Method 2: Global Installation

For servers you’ll use frequently:

# Install globally
npm install -g @modelcontextprotocol/server-filesystem

# Run the server
mcp-server-filesystem /path/to/directory

Method 3: Python Servers with UV/UVX

For Python-based servers:

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Run Python servers
uvx mcp-server-git --repository /path/to/repo

Method 4: Manual Installation

For custom or development servers:

# Clone the repository
git clone https://github.com/your-org/your-mcp-server.git
cd your-mcp-server

# Install dependencies
npm install  # or pip install -r requirements.txt

# Build if necessary
npm run build

# Run the server
npm start  # or python -m your_server

File System Server

Provides secure file operations with configurable access controls.

# Using NPX (recommended)
npx -y @modelcontextprotocol/server-filesystem /Users/username/Documents

# Using UV for Python version
uvx mcp-server-filesystem --base-directory /Users/username/Documents

Configuration:

  • Restrict access to specific directories
  • Set read-only or read-write permissions
  • Configure file type filters

Database Servers

PostgreSQL Server

# Install the PostgreSQL MCP server
npm install -g mcp-server-postgres

# Or use with uvx
uvx mcp-server-postgres --host localhost --port 5432 --database myapp

Environment Variables:

export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_USER=myuser
export POSTGRES_PASSWORD=mypassword
export POSTGRES_DATABASE=mydatabase

SQLite Server

# Using Python
uvx mcp-server-sqlite /path/to/database.db

# Using Node.js
npx -y @modelcontextprotocol/server-sqlite /path/to/database.db

Web and API Servers

Fetch Server

For web scraping and content retrieval:

# Install and run
npx -y @modelcontextprotocol/server-fetch

# With custom user agent
npx -y @modelcontextprotocol/server-fetch --user-agent "MyBot/1.0"

GitHub Server

For GitHub API integration:

# Install
npm install -g @modelcontextprotocol/server-github

# Set up environment
export GITHUB_PERSONAL_ACCESS_TOKEN=your_token_here

# Run
mcp-server-github

Memory and Knowledge Servers

Memory Server

Provides persistent memory using knowledge graphs:

# Install and run
npx -y @modelcontextprotocol/server-memory

# With custom data directory
npx -y @modelcontextprotocol/server-memory --data-dir /path/to/memory

Sequential Thinking Server

For dynamic problem-solving:

# Install and run
npx -y @modelcontextprotocol/server-sequential-thinking

Custom Server Installation

Creating a Custom Server

  1. Choose your SDK:

    # TypeScript/JavaScript
    npm install @modelcontextprotocol/sdk
    
    # Python
    pip install mcp
    
  2. Create your server structure:

    // server.ts
    import { Server } from '@modelcontextprotocol/sdk/server/index.js';
    import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
    
    const server = new Server(
      {
        name: 'my-custom-server',
        version: '1.0.0',
      },
      {
        capabilities: {
          tools: {},
          resources: {},
        },
      }
    );
    
    // Add your tools and resources here
    
    async function main() {
      const transport = new StdioServerTransport();
      await server.connect(transport);
    }
    
    main().catch(console.error);
    
  3. Build and test:

    # Build your server
    npm run build
    
    # Test locally
    node dist/server.js
    

Installing from Source

# Clone your server repository
git clone https://github.com/your-org/your-mcp-server.git
cd your-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

# Create a global link (optional)
npm link

# Test the installation
your-mcp-server --help

Configuration After Installation

Environment Setup

Create a .env file for your server configuration:

# Database servers
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
DATABASE_POOL_SIZE=10

# API servers
API_KEY=your-api-key-here
API_BASE_URL=https://api.example.com

# File servers
BASE_DIRECTORY=/path/to/allowed/directory
READ_ONLY=true

# Security
ALLOWED_ORIGINS=http://localhost:3000,https://app.pyleeai.com
MAX_REQUEST_SIZE=10MB

System Service Setup (Linux/macOS)

For production deployments, set up your server as a system service:

# Create a systemd service file
sudo nano /etc/systemd/system/mcp-server.service
[Unit]
Description=MCP Server
After=network.target

[Service]
Type=simple
User=mcp
WorkingDirectory=/opt/mcp-server
ExecStart=/usr/bin/node /opt/mcp-server/dist/server.js
Restart=always
RestartSec=10
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
# Enable and start the service
sudo systemctl enable mcp-server
sudo systemctl start mcp-server

Docker Installation

Using Official Images

# Pull and run a server image
docker run -d \
  --name mcp-filesystem \
  -v /host/path:/container/path \
  -p 3000:3000 \
  modelcontextprotocol/server-filesystem

Building Custom Images

# Dockerfile
FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --only=production

COPY . .
RUN npm run build

EXPOSE 3000

CMD ["node", "dist/server.js"]
# Build and run
docker build -t my-mcp-server .
docker run -d --name my-server -p 3000:3000 my-mcp-server

Verification and Testing

Test Server Installation

# Test if server starts correctly
your-mcp-server --help

# Test with sample data
echo '{"jsonrpc": "2.0", "method": "ping", "id": 1}' | your-mcp-server

Connection Testing

# Test server connectivity
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "initialize", "id": 1, "params": {}}'

Debug Mode

Enable debug logging for troubleshooting:

# Enable debug output
DEBUG=mcp:* your-mcp-server

# Or set environment variable
export DEBUG=mcp:*
your-mcp-server

Common Installation Issues

Permission Errors

# Fix npm permissions
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules

# Use nvm for Node.js management
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install --lts

Missing Dependencies

# Install build tools (Ubuntu/Debian)
sudo apt-get install build-essential python3-dev

# Install build tools (macOS)
xcode-select --install

# Install build tools (Windows)
npm install --global windows-build-tools

Path Issues

# Add to your shell profile (.bashrc, .zshrc, etc.)
export PATH="$HOME/.local/bin:$PATH"
export PATH="/usr/local/bin:$PATH"

# Reload your shell
source ~/.bashrc  # or ~/.zshrc

Performance Optimization

Resource Limits

# Set memory limits
export NODE_OPTIONS="--max-old-space-size=4096"

# Set process limits
ulimit -n 65536  # File descriptors
ulimit -u 32768  # Processes

Connection Pooling

For database servers, configure connection pooling:

// Database configuration
const config = {
  host: process.env.DB_HOST,
  port: process.env.DB_PORT,
  database: process.env.DB_NAME,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  max: 20,  // Maximum connections
  idleTimeoutMillis: 30000,
  connectionTimeoutMillis: 2000,
};

Security Considerations

Access Control

# Create dedicated user for MCP servers
sudo useradd -r -s /bin/false mcp-server

# Set file permissions
sudo chown -R mcp-server:mcp-server /opt/mcp-server
sudo chmod 750 /opt/mcp-server

Network Security

# Firewall configuration (ufw)
sudo ufw allow from 127.0.0.1 to any port 3000
sudo ufw deny 3000

# Or use iptables
sudo iptables -A INPUT -s 127.0.0.1 -p tcp --dport 3000 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 3000 -j DROP

Next Steps

After installation:

  1. Configure your server - Set up environment variables and configuration files
  2. Test connectivity - Verify the server responds to requests
  3. Add to Pylee - Register your server in the Pylee dashboard
  4. Monitor performance - Set up logging and monitoring
  5. Secure your setup - Implement proper access controls and authentication

For more information, see:

MCP Server Installation Guide

This guide provides detailed instructions for installing and configuring various types of MCP (Model Context Protocol) servers to work with Pylee.

Prerequisites

Before installing any MCP server, ensure you have:

  • Node.js (v18 or later) for JavaScript/TypeScript servers
  • Python (v3.8 or later) for Python servers
  • Git for cloning repositories
  • Command line access with appropriate permissions

Installation Methods

The fastest way to get started with official MCP servers:

# Install and run a server directly
npx -y @modelcontextprotocol/server-filesystem /path/to/directory

Method 2: Global Installation

For servers you’ll use frequently:

# Install globally
npm install -g @modelcontextprotocol/server-filesystem

# Run the server
mcp-server-filesystem /path/to/directory

Method 3: Python Servers with UV/UVX

For Python-based servers:

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Run Python servers
uvx mcp-server-git --repository /path/to/repo

Method 4: Manual Installation

For custom or development servers:

# Clone the repository
git clone https://github.com/your-org/your-mcp-server.git
cd your-mcp-server

# Install dependencies
npm install  # or pip install -r requirements.txt

# Build if necessary
npm run build

# Run the server
npm start  # or python -m your_server

File System Server

Provides secure file operations with configurable access controls.

# Using NPX (recommended)
npx -y @modelcontextprotocol/server-filesystem /Users/username/Documents

# Using UV for Python version
uvx mcp-server-filesystem --base-directory /Users/username/Documents

Configuration:

  • Restrict access to specific directories
  • Set read-only or read-write permissions
  • Configure file type filters

Database Servers

PostgreSQL Server

# Install the PostgreSQL MCP server
npm install -g mcp-server-postgres

# Or use with uvx
uvx mcp-server-postgres --host localhost --port 5432 --database myapp

Environment Variables:

export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_USER=myuser
export POSTGRES_PASSWORD=mypassword
export POSTGRES_DATABASE=mydatabase

SQLite Server

# Using Python
uvx mcp-server-sqlite /path/to/database.db

# Using Node.js
npx -y @modelcontextprotocol/server-sqlite /path/to/database.db

Web and API Servers

Fetch Server

For web scraping and content retrieval:

# Install and run
npx -y @modelcontextprotocol/server-fetch

# With custom user agent
npx -y @modelcontextprotocol/server-fetch --user-agent "MyBot/1.0"

GitHub Server

For GitHub API integration:

# Install
npm install -g @modelcontextprotocol/server-github

# Set up environment
export GITHUB_PERSONAL_ACCESS_TOKEN=your_token_here

# Run
mcp-server-github

Memory and Knowledge Servers

Memory Server

Provides persistent memory using knowledge graphs:

# Install and run
npx -y @modelcontextprotocol/server-memory

# With custom data directory
npx -y @modelcontextprotocol/server-memory --data-dir /path/to/memory

Sequential Thinking Server

For dynamic problem-solving:

# Install and run
npx -y @modelcontextprotocol/server-sequential-thinking

Custom Server Installation

Creating a Custom Server

  1. Choose your SDK:

    # TypeScript/JavaScript
    npm install @modelcontextprotocol/sdk
    
    # Python
    pip install mcp
    
  2. Create your server structure:

    // server.ts
    import { Server } from '@modelcontextprotocol/sdk/server/index.js';
    import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
    
    const server = new Server(
      {
        name: 'my-custom-server',
        version: '1.0.0',
      },
      {
        capabilities: {
          tools: {},
          resources: {},
        },
      }
    );
    
    // Add your tools and resources here
    
    async function main() {
      const transport = new StdioServerTransport();
      await server.connect(transport);
    }
    
    main().catch(console.error);
    
  3. Build and test:

    # Build your server
    npm run build
    
    # Test locally
    node dist/server.js
    

Installing from Source

# Clone your server repository
git clone https://github.com/your-org/your-mcp-server.git
cd your-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

# Create a global link (optional)
npm link

# Test the installation
your-mcp-server --help

Configuration After Installation

Environment Setup

Create a .env file for your server configuration:

# Database servers
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
DATABASE_POOL_SIZE=10

# API servers
API_KEY=your-api-key-here
API_BASE_URL=https://api.example.com

# File servers
BASE_DIRECTORY=/path/to/allowed/directory
READ_ONLY=true

# Security
ALLOWED_ORIGINS=http://localhost:3000,https://app.pyleeai.com
MAX_REQUEST_SIZE=10MB

System Service Setup (Linux/macOS)

For production deployments, set up your server as a system service:

# Create a systemd service file
sudo nano /etc/systemd/system/mcp-server.service
[Unit]
Description=MCP Server
After=network.target

[Service]
Type=simple
User=mcp
WorkingDirectory=/opt/mcp-server
ExecStart=/usr/bin/node /opt/mcp-server/dist/server.js
Restart=always
RestartSec=10
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
# Enable and start the service
sudo systemctl enable mcp-server
sudo systemctl start mcp-server

Docker Installation

Using Official Images

# Pull and run a server image
docker run -d \
  --name mcp-filesystem \
  -v /host/path:/container/path \
  -p 3000:3000 \
  modelcontextprotocol/server-filesystem

Building Custom Images

# Dockerfile
FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --only=production

COPY . .
RUN npm run build

EXPOSE 3000

CMD ["node", "dist/server.js"]
# Build and run
docker build -t my-mcp-server .
docker run -d --name my-server -p 3000:3000 my-mcp-server

Verification and Testing

Test Server Installation

# Test if server starts correctly
your-mcp-server --help

# Test with sample data
echo '{"jsonrpc": "2.0", "method": "ping", "id": 1}' | your-mcp-server

Connection Testing

# Test server connectivity
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "initialize", "id": 1, "params": {}}'

Debug Mode

Enable debug logging for troubleshooting:

# Enable debug output
DEBUG=mcp:* your-mcp-server

# Or set environment variable
export DEBUG=mcp:*
your-mcp-server

Common Installation Issues

Permission Errors

# Fix npm permissions
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules

# Use nvm for Node.js management
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install --lts

Missing Dependencies

# Install build tools (Ubuntu/Debian)
sudo apt-get install build-essential python3-dev

# Install build tools (macOS)
xcode-select --install

# Install build tools (Windows)
npm install --global windows-build-tools

Path Issues

# Add to your shell profile (.bashrc, .zshrc, etc.)
export PATH="$HOME/.local/bin:$PATH"
export PATH="/usr/local/bin:$PATH"

# Reload your shell
source ~/.bashrc  # or ~/.zshrc

Performance Optimization

Resource Limits

# Set memory limits
export NODE_OPTIONS="--max-old-space-size=4096"

# Set process limits
ulimit -n 65536  # File descriptors
ulimit -u 32768  # Processes

Connection Pooling

For database servers, configure connection pooling:

// Database configuration
const config = {
  host: process.env.DB_HOST,
  port: process.env.DB_PORT,
  database: process.env.DB_NAME,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  max: 20,  // Maximum connections
  idleTimeoutMillis: 30000,
  connectionTimeoutMillis: 2000,
};

Security Considerations

Access Control

# Create dedicated user for MCP servers
sudo useradd -r -s /bin/false mcp-server

# Set file permissions
sudo chown -R mcp-server:mcp-server /opt/mcp-server
sudo chmod 750 /opt/mcp-server

Network Security

# Firewall configuration (ufw)
sudo ufw allow from 127.0.0.1 to any port 3000
sudo ufw deny 3000

# Or use iptables
sudo iptables -A INPUT -s 127.0.0.1 -p tcp --dport 3000 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 3000 -j DROP

Next Steps

After installation:

  1. Configure your server - Set up environment variables and configuration files
  2. Test connectivity - Verify the server responds to requests
  3. Add to Pylee - Register your server in the Pylee dashboard
  4. Monitor performance - Set up logging and monitoring
  5. Secure your setup - Implement proper access controls and authentication

For more information, see: