@stellarwp/mcp-node-config
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

⚙️ Node Config (@stellarwp/mcp-node-config)

A lightweight configuration management library for CLI MCP servers with WordPress integration support.

📦 What is this?

This package provides a simple, type-safe way to manage environment-based configuration for MCP servers, with built-in WordPress-specific configuration validation and error handling.

✨ Features

  • 🛡️ Type Safety: Full TypeScript support with strict typing
  • ⚡ Environment Variables: Automatic environment variable loading with dotenvx
  • ✅ Validation: Built-in configuration validation and missing config detection
  • 🚫 Silent Operation: Designed to work silently in MCP server environments

🚀 Getting Started

Prerequisites

  • Node.js 18+ or Bun 1.2.20+
  • Environment variables for WordPress configuration

Installation

# Install the package
bun add @stellarwp/mcp-node-config

# Or with npm
npm install @stellarwp/mcp-node-config

Environment Setup

Copy the .env.example file in your project root and fill out the correct values for your environment:

WP_REST_URL=https://your-site.com/wp-json/wp/v2/
WP_USERNAME=your_username
WP_APP_PASSWORD=your_application_password

# Uncomment to disable SSL certificate verification for local server development. Should not be enabled on production!
# NODE_TLS_REJECT_UNAUTHORIZED=0

💡 Local Development Tip: When developing on a local environment where SSL certificates wouldn't validate (e.g., localhost with self-signed certs), you can set NODE_TLS_REJECT_UNAUTHORIZED=0 in your environment variables. This is particularly important when using the API Fetch package to connect to local WordPress installations. Note: This should only be used in development environments, never in production.

🔧 Usage

Basic Configuration

#!/usr/bin/env node

// Import env first to load environment variables
import '@stellarwp/mcp-node-config/env';

import { config } from '@stellarwp/mcp-node-config';

// Check if configuration is valid
if (!config.isValid()) {
    const missing = config.getMissingConfig();
    throw new Error(`Missing required env vars: ${missing.join(', ')}`);
}

// Access configuration values
console.log('WordPress REST URL:', config.wpRestUrl);
console.log('Username:', config.wpUsername);

📚 API Reference

Configuration Object

The config object provides the following properties and methods:

Properties

  • wpRestUrl: string - WordPress REST API base URL
  • wpUsername: string - WordPress username for authentication
  • wpAppPassword: string - WordPress application password

Methods

  • getMissingConfig(): string[] - Returns array of missing environment variable names
  • isValid(): boolean - Returns true if all required configuration is present

Environment Variables

Variable Description Required
WP_REST_URL WordPress REST API base URL Yes
WP_USERNAME WordPress username Yes
WP_APP_PASSWORD WordPress application password Yes
NODE_TLS_REJECT_UNAUTHORIZED Set to 0 for local development with invalid SSL certs No

Readme

Keywords

none

Package Sidebar

Install

npm i @stellarwp/mcp-node-config

Weekly Downloads

213

Version

1.0.1

License

none

Unpacked Size

372 kB

Total Files

12

Last publish

Collaborators

  • borkweb
  • bordoni
  • lucatume
  • jfrydman