MCP Server Configuration Examples

This guide provides practical configuration examples and best practices for setting up MCP servers with Pylee. Each example includes security considerations and common customizations.

Configuration File Structure

MCP servers are configured through JSON configuration files. The basic structure includes server definitions with command execution parameters:

{
  "mcpServers": {
    "server-name": {
      "command": "executable",
      "args": ["argument1", "argument2"],
      "env": {
        "VARIABLE": "value"
      },
      "cwd": "/working/directory"
    }
  }
}

File System Server Configurations

Basic File Access

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/username/Documents"
      ]
    }
  }
}

Restricted File Access

{
  "mcpServers": {
    "secure-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/opt/app/data",
        "--allowed-extensions",
        ".txt,.md,.json",
        "--max-file-size",
        "10MB",
        "--read-only"
      ],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

Multiple Directory Access

{
  "mcpServers": {
    "docs-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/username/Documents"
      ]
    },
    "projects-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/username/Projects"
      ]
    }
  }
}

Database Server Configurations

PostgreSQL Server

{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "localhost",
        "--port", "5432",
        "--database", "myapp"
      ],
      "env": {
        "POSTGRES_USER": "readonly_user",
        "POSTGRES_PASSWORD": "secure_password",
        "POSTGRES_SSL_MODE": "require"
      }
    }
  }
}

SQLite Server

{
  "mcpServers": {
    "sqlite": {
      "command": "python",
      "args": [
        "-m", "mcp_server_sqlite",
        "/path/to/database.db",
        "--read-only"
      ]
    }
  }
}

MySQL Server

{
  "mcpServers": {
    "mysql": {
      "command": "uvx",
      "args": [
        "mcp-server-mysql",
        "--host", "localhost",
        "--port", "3306",
        "--database", "production_db"
      ],
      "env": {
        "MYSQL_USER": "mcp_reader",
        "MYSQL_PASSWORD": "${MYSQL_PASSWORD}",
        "MYSQL_SSL_CA": "/etc/ssl/certs/ca-certificates.crt"
      }
    }
  }
}

API Integration Servers

GitHub Server

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}",
        "GITHUB_API_BASE_URL": "https://api.github.com"
      }
    }
  }
}

REST API Server

{
  "mcpServers": {
    "api-server": {
      "command": "node",
      "args": ["/path/to/custom-api-server.js"],
      "env": {
        "API_BASE_URL": "https://api.example.com",
        "API_KEY": "${API_KEY}",
        "API_TIMEOUT": "30000",
        "RATE_LIMIT": "100"
      }
    }
  }
}

Slack Integration

{
  "mcpServers": {
    "slack": {
      "command": "uvx",
      "args": ["mcp-server-slack"],
      "env": {
        "SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}",
        "SLACK_APP_TOKEN": "${SLACK_APP_TOKEN}",
        "SLACK_WORKSPACE": "your-workspace"
      }
    }
  }
}

Development vs Production Configurations

Development Configuration

{
  "mcpServers": {
    "dev-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/dev/workspace",
        "--allow-symlinks",
        "--verbose"
      ],
      "env": {
        "NODE_ENV": "development",
        "DEBUG": "mcp:*"
      }
    },
    "dev-database": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "localhost",
        "--database", "myapp_dev"
      ],
      "env": {
        "POSTGRES_USER": "dev_user",
        "POSTGRES_PASSWORD": "dev_password"
      }
    }
  }
}

Production Configuration

{
  "mcpServers": {
    "prod-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/opt/app/data",
        "--read-only",
        "--max-file-size", "5MB",
        "--allowed-extensions", ".txt,.json,.csv"
      ],
      "env": {
        "NODE_ENV": "production",
        "LOG_LEVEL": "error"
      }
    },
    "prod-database": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "${DB_HOST}",
        "--port", "${DB_PORT}",
        "--database", "${DB_NAME}",
        "--connection-pool-size", "10",
        "--read-only"
      ],
      "env": {
        "POSTGRES_USER": "${DB_USER}",
        "POSTGRES_PASSWORD": "${DB_PASSWORD}",
        "POSTGRES_SSL_MODE": "require",
        "POSTGRES_SSL_CERT": "/etc/ssl/client-cert.pem",
        "POSTGRES_SSL_KEY": "/etc/ssl/client-key.pem"
      }
    }
  }
}

Security-Focused Configurations

Sandboxed File Server

{
  "mcpServers": {
    "sandboxed-fs": {
      "command": "docker",
      "args": [
        "run", "--rm",
        "--user", "1000:1000",
        "--read-only",
        "--tmpfs", "/tmp",
        "--volume", "/opt/app/data:/data:ro",
        "--network", "none",
        "mcp-filesystem-server:latest",
        "/data"
      ]
    }
  }
}

Authenticated API Server

{
  "mcpServers": {
    "secure-api": {
      "command": "node",
      "args": ["/opt/mcp/secure-api-server.js"],
      "env": {
        "API_BASE_URL": "https://api.internal.company.com",
        "CLIENT_ID": "${OAUTH_CLIENT_ID}",
        "CLIENT_SECRET": "${OAUTH_CLIENT_SECRET}",
        "REFRESH_TOKEN": "${OAUTH_REFRESH_TOKEN}",
        "TOKEN_ENDPOINT": "https://auth.company.com/oauth/token",
        "ALLOWED_SCOPES": "read:data,read:users"
      }
    }
  }
}

Network-Isolated Database

{
  "mcpServers": {
    "isolated-db": {
      "command": "docker",
      "args": [
        "run", "--rm",
        "--network", "mcp-internal",
        "--env-file", "/etc/mcp/db.env",
        "mcp-postgres-server:latest"
      ]
    }
  }
}

Custom Server Configurations

Python Custom Server

{
  "mcpServers": {
    "custom-python": {
      "command": "python",
      "args": [
        "-m", "my_custom_server",
        "--config", "/etc/mcp/custom-config.json"
      ],
      "cwd": "/opt/my-mcp-server",
      "env": {
        "PYTHONPATH": "/opt/my-mcp-server",
        "CONFIG_PATH": "/etc/mcp/custom-config.json",
        "LOG_LEVEL": "INFO"
      }
    }
  }
}

Node.js Custom Server

{
  "mcpServers": {
    "custom-node": {
      "command": "node",
      "args": [
        "dist/server.js",
        "--port", "3001",
        "--host", "127.0.0.1"
      ],
      "cwd": "/opt/custom-mcp-server",
      "env": {
        "NODE_ENV": "production",
        "PORT": "3001",
        "HOST": "127.0.0.1",
        "CONFIG_FILE": "/etc/mcp/server-config.json"
      }
    }
  }
}

Environment-Specific Examples

Docker Compose Integration

{
  "mcpServers": {
    "compose-db": {
      "command": "docker",
      "args": [
        "compose",
        "-f", "/opt/mcp/docker-compose.yml",
        "exec", "-T", "postgres",
        "mcp-server-postgres"
      ],
      "cwd": "/opt/mcp",
      "env": {
        "COMPOSE_PROJECT_NAME": "mcp-stack"
      }
    }
  }
}

Kubernetes Pod Execution

{
  "mcpServers": {
    "k8s-server": {
      "command": "kubectl",
      "args": [
        "exec", "-n", "mcp-namespace",
        "deployment/mcp-server",
        "--", "mcp-server-postgres"
      ],
      "env": {
        "KUBECONFIG": "/etc/kubernetes/admin.conf"
      }
    }
  }
}

Advanced Configuration Patterns

Multi-Environment Setup

{
  "mcpServers": {
    "primary-db": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "${PRIMARY_DB_HOST}",
        "--database", "${PRIMARY_DB_NAME}"
      ],
      "env": {
        "POSTGRES_USER": "${PRIMARY_DB_USER}",
        "POSTGRES_PASSWORD": "${PRIMARY_DB_PASSWORD}"
      }
    },
    "analytics-db": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "${ANALYTICS_DB_HOST}",
        "--database", "${ANALYTICS_DB_NAME}",
        "--read-only"
      ],
      "env": {
        "POSTGRES_USER": "${ANALYTICS_DB_USER}",
        "POSTGRES_PASSWORD": "${ANALYTICS_DB_PASSWORD}"
      }
    }
  }
}

Load-Balanced Configuration

{
  "mcpServers": {
    "api-primary": {
      "command": "node",
      "args": ["/opt/api-server/server.js"],
      "env": {
        "API_ENDPOINT": "https://api1.example.com",
        "INSTANCE_ID": "primary"
      }
    },
    "api-secondary": {
      "command": "node",
      "args": ["/opt/api-server/server.js"],
      "env": {
        "API_ENDPOINT": "https://api2.example.com",
        "INSTANCE_ID": "secondary"
      }
    }
  }
}

Configuration Management

Environment Variables File

Create a .env file for your configuration:

# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=production
DB_USER=mcp_user
DB_PASSWORD=secure_password

# API Configuration
API_KEY=your-secret-api-key
GITHUB_TOKEN=your-github-token

# File System Configuration
DATA_DIRECTORY=/opt/app/data
LOG_DIRECTORY=/var/log/mcp

# Security Configuration
SSL_CERT_PATH=/etc/ssl/certs/server.crt
SSL_KEY_PATH=/etc/ssl/private/server.key

Configuration Validation

{
  "mcpServers": {
    "validated-server": {
      "command": "node",
      "args": [
        "/opt/mcp/server.js",
        "--validate-config"
      ],
      "env": {
        "CONFIG_SCHEMA": "/opt/mcp/schema.json",
        "STRICT_VALIDATION": "true"
      }
    }
  }
}

Monitoring and Logging

Enhanced Logging Configuration

{
  "mcpServers": {
    "monitored-server": {
      "command": "node",
      "args": ["/opt/server.js"],
      "env": {
        "LOG_LEVEL": "info",
        "LOG_FORMAT": "json",
        "LOG_FILE": "/var/log/mcp/server.log",
        "METRICS_ENABLED": "true",
        "METRICS_PORT": "9090"
      }
    }
  }
}

Health Check Configuration

{
  "mcpServers": {
    "health-checked-server": {
      "command": "node",
      "args": [
        "/opt/server.js",
        "--health-check-port", "8080",
        "--health-check-path", "/health"
      ],
      "env": {
        "HEALTH_CHECK_INTERVAL": "30000",
        "SHUTDOWN_TIMEOUT": "10000"
      }
    }
  }
}

Best Practices

Security Best Practices

  1. Use environment variables for sensitive data
  2. Enable read-only mode when possible
  3. Restrict file access to specific directories
  4. Use strong authentication for database connections
  5. Enable SSL/TLS for network connections
  6. Run servers with minimal privileges
  7. Use container isolation when available

Performance Best Practices

  1. Configure connection pooling for databases
  2. Set appropriate timeouts for network operations
  3. Enable caching when beneficial
  4. Monitor resource usage and set limits
  5. Use efficient serialization formats
  6. Optimize query patterns for data access

Operational Best Practices

  1. Use descriptive server names
  2. Document configuration choices
  3. Implement proper logging
  4. Set up health checks
  5. Plan for graceful shutdowns
  6. Version your configurations
  7. Test configurations thoroughly

Configuration File Locations

System-wide Configuration

# Linux/macOS
/etc/mcp/config.json
/usr/local/etc/mcp/config.json

# Windows
C:\ProgramData\MCP\config.json

User-specific Configuration

# Linux/macOS
~/.mcp/config.json
~/.config/mcp/config.json

# Windows
%APPDATA%\MCP\config.json

Project-specific Configuration

# In your project directory
./mcp.config.json
./.mcp/config.json

Troubleshooting Configuration Issues

Common Problems

  1. Invalid JSON syntax - Use a JSON validator
  2. Missing environment variables - Check variable names and values
  3. Incorrect file paths - Verify paths exist and are accessible
  4. Permission issues - Check file and directory permissions
  5. Port conflicts - Ensure ports are available
  6. Command not found - Verify executables are in PATH

Debug Configuration

{
  "mcpServers": {
    "debug-server": {
      "command": "node",
      "args": ["/opt/server.js", "--debug"],
      "env": {
        "DEBUG": "mcp:*",
        "NODE_ENV": "development",
        "VERBOSE": "true"
      }
    }
  }
}

For more information, see:

MCP Server Configuration Examples

This guide provides practical configuration examples and best practices for setting up MCP servers with Pylee. Each example includes security considerations and common customizations.

Configuration File Structure

MCP servers are configured through JSON configuration files. The basic structure includes server definitions with command execution parameters:

{
  "mcpServers": {
    "server-name": {
      "command": "executable",
      "args": ["argument1", "argument2"],
      "env": {
        "VARIABLE": "value"
      },
      "cwd": "/working/directory"
    }
  }
}

File System Server Configurations

Basic File Access

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/username/Documents"
      ]
    }
  }
}

Restricted File Access

{
  "mcpServers": {
    "secure-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/opt/app/data",
        "--allowed-extensions",
        ".txt,.md,.json",
        "--max-file-size",
        "10MB",
        "--read-only"
      ],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

Multiple Directory Access

{
  "mcpServers": {
    "docs-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/username/Documents"
      ]
    },
    "projects-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/username/Projects"
      ]
    }
  }
}

Database Server Configurations

PostgreSQL Server

{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "localhost",
        "--port", "5432",
        "--database", "myapp"
      ],
      "env": {
        "POSTGRES_USER": "readonly_user",
        "POSTGRES_PASSWORD": "secure_password",
        "POSTGRES_SSL_MODE": "require"
      }
    }
  }
}

SQLite Server

{
  "mcpServers": {
    "sqlite": {
      "command": "python",
      "args": [
        "-m", "mcp_server_sqlite",
        "/path/to/database.db",
        "--read-only"
      ]
    }
  }
}

MySQL Server

{
  "mcpServers": {
    "mysql": {
      "command": "uvx",
      "args": [
        "mcp-server-mysql",
        "--host", "localhost",
        "--port", "3306",
        "--database", "production_db"
      ],
      "env": {
        "MYSQL_USER": "mcp_reader",
        "MYSQL_PASSWORD": "${MYSQL_PASSWORD}",
        "MYSQL_SSL_CA": "/etc/ssl/certs/ca-certificates.crt"
      }
    }
  }
}

API Integration Servers

GitHub Server

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}",
        "GITHUB_API_BASE_URL": "https://api.github.com"
      }
    }
  }
}

REST API Server

{
  "mcpServers": {
    "api-server": {
      "command": "node",
      "args": ["/path/to/custom-api-server.js"],
      "env": {
        "API_BASE_URL": "https://api.example.com",
        "API_KEY": "${API_KEY}",
        "API_TIMEOUT": "30000",
        "RATE_LIMIT": "100"
      }
    }
  }
}

Slack Integration

{
  "mcpServers": {
    "slack": {
      "command": "uvx",
      "args": ["mcp-server-slack"],
      "env": {
        "SLACK_BOT_TOKEN": "${SLACK_BOT_TOKEN}",
        "SLACK_APP_TOKEN": "${SLACK_APP_TOKEN}",
        "SLACK_WORKSPACE": "your-workspace"
      }
    }
  }
}

Development vs Production Configurations

Development Configuration

{
  "mcpServers": {
    "dev-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/dev/workspace",
        "--allow-symlinks",
        "--verbose"
      ],
      "env": {
        "NODE_ENV": "development",
        "DEBUG": "mcp:*"
      }
    },
    "dev-database": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "localhost",
        "--database", "myapp_dev"
      ],
      "env": {
        "POSTGRES_USER": "dev_user",
        "POSTGRES_PASSWORD": "dev_password"
      }
    }
  }
}

Production Configuration

{
  "mcpServers": {
    "prod-filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/opt/app/data",
        "--read-only",
        "--max-file-size", "5MB",
        "--allowed-extensions", ".txt,.json,.csv"
      ],
      "env": {
        "NODE_ENV": "production",
        "LOG_LEVEL": "error"
      }
    },
    "prod-database": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "${DB_HOST}",
        "--port", "${DB_PORT}",
        "--database", "${DB_NAME}",
        "--connection-pool-size", "10",
        "--read-only"
      ],
      "env": {
        "POSTGRES_USER": "${DB_USER}",
        "POSTGRES_PASSWORD": "${DB_PASSWORD}",
        "POSTGRES_SSL_MODE": "require",
        "POSTGRES_SSL_CERT": "/etc/ssl/client-cert.pem",
        "POSTGRES_SSL_KEY": "/etc/ssl/client-key.pem"
      }
    }
  }
}

Security-Focused Configurations

Sandboxed File Server

{
  "mcpServers": {
    "sandboxed-fs": {
      "command": "docker",
      "args": [
        "run", "--rm",
        "--user", "1000:1000",
        "--read-only",
        "--tmpfs", "/tmp",
        "--volume", "/opt/app/data:/data:ro",
        "--network", "none",
        "mcp-filesystem-server:latest",
        "/data"
      ]
    }
  }
}

Authenticated API Server

{
  "mcpServers": {
    "secure-api": {
      "command": "node",
      "args": ["/opt/mcp/secure-api-server.js"],
      "env": {
        "API_BASE_URL": "https://api.internal.company.com",
        "CLIENT_ID": "${OAUTH_CLIENT_ID}",
        "CLIENT_SECRET": "${OAUTH_CLIENT_SECRET}",
        "REFRESH_TOKEN": "${OAUTH_REFRESH_TOKEN}",
        "TOKEN_ENDPOINT": "https://auth.company.com/oauth/token",
        "ALLOWED_SCOPES": "read:data,read:users"
      }
    }
  }
}

Network-Isolated Database

{
  "mcpServers": {
    "isolated-db": {
      "command": "docker",
      "args": [
        "run", "--rm",
        "--network", "mcp-internal",
        "--env-file", "/etc/mcp/db.env",
        "mcp-postgres-server:latest"
      ]
    }
  }
}

Custom Server Configurations

Python Custom Server

{
  "mcpServers": {
    "custom-python": {
      "command": "python",
      "args": [
        "-m", "my_custom_server",
        "--config", "/etc/mcp/custom-config.json"
      ],
      "cwd": "/opt/my-mcp-server",
      "env": {
        "PYTHONPATH": "/opt/my-mcp-server",
        "CONFIG_PATH": "/etc/mcp/custom-config.json",
        "LOG_LEVEL": "INFO"
      }
    }
  }
}

Node.js Custom Server

{
  "mcpServers": {
    "custom-node": {
      "command": "node",
      "args": [
        "dist/server.js",
        "--port", "3001",
        "--host", "127.0.0.1"
      ],
      "cwd": "/opt/custom-mcp-server",
      "env": {
        "NODE_ENV": "production",
        "PORT": "3001",
        "HOST": "127.0.0.1",
        "CONFIG_FILE": "/etc/mcp/server-config.json"
      }
    }
  }
}

Environment-Specific Examples

Docker Compose Integration

{
  "mcpServers": {
    "compose-db": {
      "command": "docker",
      "args": [
        "compose",
        "-f", "/opt/mcp/docker-compose.yml",
        "exec", "-T", "postgres",
        "mcp-server-postgres"
      ],
      "cwd": "/opt/mcp",
      "env": {
        "COMPOSE_PROJECT_NAME": "mcp-stack"
      }
    }
  }
}

Kubernetes Pod Execution

{
  "mcpServers": {
    "k8s-server": {
      "command": "kubectl",
      "args": [
        "exec", "-n", "mcp-namespace",
        "deployment/mcp-server",
        "--", "mcp-server-postgres"
      ],
      "env": {
        "KUBECONFIG": "/etc/kubernetes/admin.conf"
      }
    }
  }
}

Advanced Configuration Patterns

Multi-Environment Setup

{
  "mcpServers": {
    "primary-db": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "${PRIMARY_DB_HOST}",
        "--database", "${PRIMARY_DB_NAME}"
      ],
      "env": {
        "POSTGRES_USER": "${PRIMARY_DB_USER}",
        "POSTGRES_PASSWORD": "${PRIMARY_DB_PASSWORD}"
      }
    },
    "analytics-db": {
      "command": "uvx",
      "args": [
        "mcp-server-postgres",
        "--host", "${ANALYTICS_DB_HOST}",
        "--database", "${ANALYTICS_DB_NAME}",
        "--read-only"
      ],
      "env": {
        "POSTGRES_USER": "${ANALYTICS_DB_USER}",
        "POSTGRES_PASSWORD": "${ANALYTICS_DB_PASSWORD}"
      }
    }
  }
}

Load-Balanced Configuration

{
  "mcpServers": {
    "api-primary": {
      "command": "node",
      "args": ["/opt/api-server/server.js"],
      "env": {
        "API_ENDPOINT": "https://api1.example.com",
        "INSTANCE_ID": "primary"
      }
    },
    "api-secondary": {
      "command": "node",
      "args": ["/opt/api-server/server.js"],
      "env": {
        "API_ENDPOINT": "https://api2.example.com",
        "INSTANCE_ID": "secondary"
      }
    }
  }
}

Configuration Management

Environment Variables File

Create a .env file for your configuration:

# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=production
DB_USER=mcp_user
DB_PASSWORD=secure_password

# API Configuration
API_KEY=your-secret-api-key
GITHUB_TOKEN=your-github-token

# File System Configuration
DATA_DIRECTORY=/opt/app/data
LOG_DIRECTORY=/var/log/mcp

# Security Configuration
SSL_CERT_PATH=/etc/ssl/certs/server.crt
SSL_KEY_PATH=/etc/ssl/private/server.key

Configuration Validation

{
  "mcpServers": {
    "validated-server": {
      "command": "node",
      "args": [
        "/opt/mcp/server.js",
        "--validate-config"
      ],
      "env": {
        "CONFIG_SCHEMA": "/opt/mcp/schema.json",
        "STRICT_VALIDATION": "true"
      }
    }
  }
}

Monitoring and Logging

Enhanced Logging Configuration

{
  "mcpServers": {
    "monitored-server": {
      "command": "node",
      "args": ["/opt/server.js"],
      "env": {
        "LOG_LEVEL": "info",
        "LOG_FORMAT": "json",
        "LOG_FILE": "/var/log/mcp/server.log",
        "METRICS_ENABLED": "true",
        "METRICS_PORT": "9090"
      }
    }
  }
}

Health Check Configuration

{
  "mcpServers": {
    "health-checked-server": {
      "command": "node",
      "args": [
        "/opt/server.js",
        "--health-check-port", "8080",
        "--health-check-path", "/health"
      ],
      "env": {
        "HEALTH_CHECK_INTERVAL": "30000",
        "SHUTDOWN_TIMEOUT": "10000"
      }
    }
  }
}

Best Practices

Security Best Practices

  1. Use environment variables for sensitive data
  2. Enable read-only mode when possible
  3. Restrict file access to specific directories
  4. Use strong authentication for database connections
  5. Enable SSL/TLS for network connections
  6. Run servers with minimal privileges
  7. Use container isolation when available

Performance Best Practices

  1. Configure connection pooling for databases
  2. Set appropriate timeouts for network operations
  3. Enable caching when beneficial
  4. Monitor resource usage and set limits
  5. Use efficient serialization formats
  6. Optimize query patterns for data access

Operational Best Practices

  1. Use descriptive server names
  2. Document configuration choices
  3. Implement proper logging
  4. Set up health checks
  5. Plan for graceful shutdowns
  6. Version your configurations
  7. Test configurations thoroughly

Configuration File Locations

System-wide Configuration

# Linux/macOS
/etc/mcp/config.json
/usr/local/etc/mcp/config.json

# Windows
C:\ProgramData\MCP\config.json

User-specific Configuration

# Linux/macOS
~/.mcp/config.json
~/.config/mcp/config.json

# Windows
%APPDATA%\MCP\config.json

Project-specific Configuration

# In your project directory
./mcp.config.json
./.mcp/config.json

Troubleshooting Configuration Issues

Common Problems

  1. Invalid JSON syntax - Use a JSON validator
  2. Missing environment variables - Check variable names and values
  3. Incorrect file paths - Verify paths exist and are accessible
  4. Permission issues - Check file and directory permissions
  5. Port conflicts - Ensure ports are available
  6. Command not found - Verify executables are in PATH

Debug Configuration

{
  "mcpServers": {
    "debug-server": {
      "command": "node",
      "args": ["/opt/server.js", "--debug"],
      "env": {
        "DEBUG": "mcp:*",
        "NODE_ENV": "development",
        "VERBOSE": "true"
      }
    }
  }
}

For more information, see: