Skip to main content
Glama
DEVELOPMENT_SETUP.mdβ€’12.7 kB
# Development Setup Guide This guide walks you through setting up a complete development environment for the MCP WordPress Server. ## πŸ”§ Prerequisites ### Required Software - **Node.js 18+** - [Download from nodejs.org](https://nodejs.org/) - **npm 9+** - Comes with Node.js - **Git** - [Download from git-scm.com](https://git-scm.com/) - **TypeScript 5+** - Installed via npm - **Docker & Docker Compose** - [Download from docker.com](https://docker.com/) ### Optional Tools - **VS Code** - Recommended IDE with TypeScript support - **GitHub CLI** - For GitHub integration (`gh`) - **WordPress Site** - For testing (or use Docker test environment) ## πŸš€ Quick Setup ### 1. Clone Repository ```bash git clone https://github.com/docdyhr/mcp-wordpress.git cd mcp-wordpress ``` ### 2. Install Dependencies ```bash # Install all dependencies npm ci # Install development tools globally (optional) npm install -g typescript @types/node jest ``` ### 3. Build Project ```bash # Initial build npm run build # Type checking npm run typecheck ``` ### 4. Run Tests ```bash # Run all tests npm test # Quick validation npm run test:fast ``` ## πŸ“ Project Structure ```text mcp-wordpress/ β”œβ”€β”€ src/ # TypeScript source code β”‚ β”œβ”€β”€ index.ts # Main MCP server entry point β”‚ β”œβ”€β”€ server.ts # Server compatibility layer β”‚ β”œβ”€β”€ types/ # TypeScript type definitions β”‚ β”‚ β”œβ”€β”€ wordpress.ts # WordPress REST API types β”‚ β”‚ β”œβ”€β”€ mcp.ts # MCP protocol types β”‚ β”‚ β”œβ”€β”€ client.ts # Client interface types β”‚ β”‚ └── index.ts # Type exports β”‚ β”œβ”€β”€ client/ # WordPress API client (modular) β”‚ β”‚ β”œβ”€β”€ WordPressClient.ts # Main client orchestrator β”‚ β”‚ β”œβ”€β”€ CachedWordPressClient.ts # Caching wrapper β”‚ β”‚ β”œβ”€β”€ api.ts # Legacy compatibility β”‚ β”‚ β”œβ”€β”€ auth.ts # Authentication utilities β”‚ β”‚ └── managers/ # Manager components β”‚ β”‚ β”œβ”€β”€ BaseManager.ts # Common functionality β”‚ β”‚ β”œβ”€β”€ AuthenticationManager.ts # Auth methods β”‚ β”‚ └── RequestManager.ts # HTTP operations β”‚ β”œβ”€β”€ tools/ # MCP tool implementations β”‚ β”‚ β”œβ”€β”€ posts.ts # Post management tools β”‚ β”‚ β”œβ”€β”€ pages.ts # Page management tools β”‚ β”‚ β”œβ”€β”€ media.ts # Media management tools β”‚ β”‚ β”œβ”€β”€ users.ts # User management tools β”‚ β”‚ β”œβ”€β”€ comments.ts # Comment management tools β”‚ β”‚ β”œβ”€β”€ taxonomies.ts # Categories/Tags tools β”‚ β”‚ β”œβ”€β”€ site.ts # Site settings tools β”‚ β”‚ β”œβ”€β”€ auth.ts # Authentication tools β”‚ β”‚ β”œβ”€β”€ cache.ts # Cache management tools β”‚ β”‚ β”œβ”€β”€ performance.ts # Performance monitoring tools β”‚ β”‚ └── index.ts # Tool registry β”‚ β”œβ”€β”€ cache/ # Intelligent caching system β”‚ β”‚ β”œβ”€β”€ CacheManager.ts # Core cache functionality β”‚ β”‚ β”œβ”€β”€ CacheInvalidation.ts # Cache invalidation logic β”‚ β”‚ └── types.ts # Cache type definitions β”‚ β”œβ”€β”€ performance/ # Performance monitoring system β”‚ β”‚ β”œβ”€β”€ PerformanceMonitor.ts # Core monitoring β”‚ β”‚ β”œβ”€β”€ MetricsCollector.ts # Metrics collection β”‚ β”‚ └── PerformanceAnalytics.ts # Analytics engine β”‚ β”œβ”€β”€ security/ # Security validation and utilities β”‚ β”‚ β”œβ”€β”€ InputValidator.ts # Input validation β”‚ β”‚ β”œβ”€β”€ SecurityConfig.ts # Security configuration β”‚ β”‚ └── SecurityUtils.ts # Security utilities β”‚ β”œβ”€β”€ docs/ # Documentation generation system β”‚ β”‚ β”œβ”€β”€ DocumentationGenerator.ts # Doc extraction β”‚ β”‚ └── MarkdownFormatter.ts # Markdown formatting β”‚ β”œβ”€β”€ server/ # Server infrastructure β”‚ β”‚ └── ToolRegistry.ts # Tool registration system β”‚ └── utils/ # Shared utility functions β”‚ └── debug.ts # Debug logging utilities β”œβ”€β”€ dist/ # Compiled JavaScript output β”œβ”€β”€ tests/ # Comprehensive test suite β”‚ β”œβ”€β”€ auth-headers-fix.test.js # Authentication tests β”‚ β”œβ”€β”€ config-loading.test.js # Configuration tests β”‚ β”œβ”€β”€ tool-validation.test.js # Tool validation tests β”‚ β”œβ”€β”€ typescript-build.test.js # Build tests β”‚ β”œβ”€β”€ env-loading.test.js # Environment tests β”‚ β”œβ”€β”€ unit/ # Unit tests β”‚ β”œβ”€β”€ security/ # Security tests β”‚ β”œβ”€β”€ performance/ # Performance tests β”‚ β”œβ”€β”€ cache/ # Cache tests β”‚ β”œβ”€β”€ property/ # Property-based tests β”‚ └── config/ # Configuration tests β”œβ”€β”€ scripts/ # Build, test, and utility scripts β”œβ”€β”€ docs/ # Documentation └── .github/workflows/ # CI/CD automation ``` ## πŸ”§ Development Commands ### Build System ```bash # TypeScript compilation npm run build # Compile to dist/ npm run build:watch # Watch mode compilation npm run typecheck # Type checking without output # Development mode npm run dev # Development with debug output DEBUG=true npm run dev # Enhanced debug logging ``` ### Testing Commands ```bash # Test execution npm test # Run main test suite npm run test:watch # Watch mode testing npm run test:coverage # Generate coverage report (50% threshold) npm run test:fast # Quick test run # Specific test suites npm run test:typescript # TypeScript build tests npm run test:security # Security validation tests npm run test:performance # Performance regression tests npm run test:cache # Cache system tests npm run test:config # Configuration validation tests npm run test:property # Property-based tests # Integration tests npm run test:tools # Tool functionality tests npm run test:auth # Authentication tests npm run test:mcp # MCP protocol tests npm run test:multisite # Multi-site configuration tests # Contract testing npm run test:contracts # Contract tests (mock) npm run test:contracts:live # Live WordPress contract tests # Docker test environment npm run test:with-env # Tests with Docker WordPress ./scripts/start-test-env.sh # Start test environment ``` ### Code Quality ```bash # Linting and formatting npm run lint # ESLint check npm run lint:fix # Auto-fix ESLint errors npm run format # Prettier formatting npm run format:check # Check formatting without changes # Security scanning npm run security:check # Quick vulnerability scan npm run security:scan # Comprehensive security scanning npm run security:test # Security policy validation npm run security:full # Complete security testing suite ``` ### Documentation ```bash # Documentation generation npm run docs:generate # Generate API documentation npm run docs:validate # Validate documentation completeness npm run docs:serve # Start local documentation server npm run docs:watch # Watch mode for documentation ``` ### Utility Commands ```bash # Status and diagnostics npm run status # Check connection status npm run health # Comprehensive system health check npm run setup # Interactive setup wizard # Maintenance npm run clean # Clean build artifacts npm run verify-claude # Verify Claude integration ``` ## 🐳 Docker Development Environment ### Test Environment Setup ```bash # Start complete test environment ./scripts/start-test-env.sh # Run tests with Docker environment npm run test:with-env # Stop test environment docker-compose -f docker-compose.test.yml down ``` ### Development with Docker ```bash # Build Docker image docker build -t mcp-wordpress-dev . # Run development container docker run --rm -it \ -v $(pwd):/app \ -w /app \ mcp-wordpress-dev npm run dev # Docker Compose for development docker-compose up --profile dev ``` ## βš™οΈ Configuration ### Environment Variables Create a `.env` file in the project root: ```env # WordPress connection (for testing) WORDPRESS_SITE_URL=https://your-test-site.com WORDPRESS_USERNAME=your-username WORDPRESS_APP_PASSWORD=xxxx xxxx xxxx xxxx xxxx xxxx WORDPRESS_AUTH_METHOD=app-password # Development settings DEBUG=true NODE_ENV=development LOG_LEVEL=debug # Test configuration WORDPRESS_TEST_URL=http://localhost:8081 PACT_LIVE_TESTING=false ``` ### Multi-Site Development Create `mcp-wordpress.config.json` for multi-site testing: ```json { "sites": [ { "id": "test-site", "name": "Test WordPress Site", "config": { "WORDPRESS_SITE_URL": "http://localhost:8081", "WORDPRESS_USERNAME": "admin", "WORDPRESS_APP_PASSWORD": "test test test test test test" } }, { "id": "dev-site", "name": "Development Site", "config": { "WORDPRESS_SITE_URL": "https://your-dev-site.com", "WORDPRESS_USERNAME": "dev_user", "WORDPRESS_APP_PASSWORD": "your-dev-password" } } ] } ``` ## πŸ§ͺ Testing WordPress Setup ### Option 1: Use Docker Test Environment (Recommended) ```bash # Automated test WordPress setup ./scripts/start-test-env.sh ``` This creates: - WordPress instance on `http://localhost:8081` - Admin user: `admin` / `password` - Pre-configured application password - MySQL database - Isolated from your development environment ### Option 2: Manual WordPress Setup 1. Install WordPress locally or use existing site 2. Enable Application Passwords (WordPress 5.6+) 3. Create application password for testing 4. Configure `.env` file with credentials ### Option 3: Use WordPress.com or Hosted Site 1. Use existing WordPress site 2. Create application password 3. Configure credentials in `.env` 4. Ensure REST API is accessible ## πŸ” IDE Setup (VS Code Recommended) ### Required Extensions ```json { "recommendations": [ "ms-vscode.vscode-typescript-next", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "bradlc.vscode-tailwindcss", "ms-vscode.vscode-json" ] } ``` ### Workspace Settings ```json { "typescript.preferences.includePackageJsonAutoImports": "on", "typescript.suggest.autoImports": true, "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "files.exclude": { "dist/": true, "node_modules/": true, "coverage/": true } } ``` ## πŸš€ First Development Task ### 1. Verify Setup ```bash # Check all systems npm run health # Run quick tests npm run test:fast # Check connection to WordPress npm run status ``` ### 2. Make a Small Change ```bash # Edit a tool description in src/tools/posts.ts # Run tests to verify npm test # Check linting npm run lint # Build project npm run build ``` ### 3. Test Integration ```bash # Test with Claude Desktop (if configured) npm run verify-claude # Or test with development mode npm run dev ``` ## πŸ› Common Development Issues ### TypeScript Errors ```bash # Check TypeScript configuration npm run typecheck # Clear and rebuild rm -rf dist/ npm run build ``` ### Test Failures ```bash # Run specific test suite npm run test:auth # Debug with verbose output DEBUG=true npm test # Check test environment ./scripts/start-test-env.sh npm run test:with-env ``` ### WordPress Connection Issues ```bash # Test WordPress REST API directly curl https://your-site.com/wp-json/wp/v2/ # Check authentication npm run status # Re-run setup wizard npm run setup ``` ### Docker Issues ```bash # Clean Docker environment docker-compose -f docker-compose.test.yml down -v docker system prune # Rebuild test environment ./scripts/start-test-env.sh ``` ## πŸ“š Next Steps 1. **[Architecture Guide](ARCHITECTURE.md)** - Understand the system design 2. **[API Reference](API_REFERENCE.md)** - Technical API documentation 3. **[Testing Guide](TESTING.md)** - Comprehensive testing information 4. **[Contributing Guidelines](CONTRIBUTING.md)** - How to contribute --- **Need help?** Check the [troubleshooting guide](../TROUBLESHOOTING.md) or create an issue on GitHub.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/docdyhr/mcp-wordpress'

If you have feedback or need assistance with the MCP directory API, please join our Discord server