mcp-wordpress 1.1.2 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/bin/mcp-wordpress.js +1 -1
- package/dist/client/api.d.ts +10 -10
- package/dist/client/api.js +157 -157
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts +2 -2
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js +72 -72
- package/dist/client/auth.js.map +1 -1
- package/dist/client/managers/AuthenticationManager.d.ts +2 -2
- package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
- package/dist/client/managers/AuthenticationManager.js +50 -46
- package/dist/client/managers/AuthenticationManager.js.map +1 -1
- package/dist/client/managers/BaseManager.d.ts +1 -1
- package/dist/client/managers/BaseManager.d.ts.map +1 -1
- package/dist/client/managers/BaseManager.js +9 -9
- package/dist/client/managers/BaseManager.js.map +1 -1
- package/dist/client/managers/RequestManager.d.ts +2 -2
- package/dist/client/managers/RequestManager.js +15 -15
- package/dist/client/managers/index.d.ts +3 -3
- package/dist/client/managers/index.js +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -61
- package/dist/index.js.map +1 -1
- package/dist/tools/auth.d.ts +2 -2
- package/dist/tools/auth.js +31 -31
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/comments.d.ts +2 -2
- package/dist/tools/comments.js +79 -79
- package/dist/tools/media.d.ts +2 -2
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js +80 -80
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts +2 -2
- package/dist/tools/pages.js +75 -75
- package/dist/tools/posts.d.ts +2 -2
- package/dist/tools/posts.js +94 -94
- package/dist/tools/site.d.ts +2 -2
- package/dist/tools/site.js +60 -60
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts +2 -2
- package/dist/tools/taxonomies.js +89 -89
- package/dist/tools/users.d.ts +2 -2
- package/dist/tools/users.js +68 -68
- package/dist/tools/users.js.map +1 -1
- package/dist/types/mcp.d.ts +1 -1
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +10 -6
- package/dist/utils/debug.js.map +1 -1
- package/dist/utils/toolWrapper.js +3 -3
- package/docs/developer/GITHUB_ACTIONS_SETUP.md +208 -0
- package/docs/developer/MAINTENANCE.md +307 -0
- package/docs/developer/MIGRATION_GUIDE.md +172 -0
- package/docs/developer/NPM_AUTH_SETUP.md +142 -0
- package/docs/developer/REFACTORING.md +196 -0
- package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +126 -0
- package/docs/releases/RELEASE_NOTES_v1.1.2.md +173 -0
- package/docs/user-guides/CLAUDE_DESKTOP_SETUP.md +187 -0
- package/package.json +4 -3
- package/src/client/api.ts +229 -229
- package/src/client/auth.ts +135 -136
- package/src/client/managers/AuthenticationManager.ts +148 -105
- package/src/client/managers/BaseManager.ts +15 -12
- package/src/client/managers/RequestManager.ts +17 -17
- package/src/client/managers/index.ts +3 -3
- package/src/index.ts +141 -114
- package/src/server.ts +1 -1
- package/src/tools/auth.ts +36 -36
- package/src/tools/comments.ts +90 -90
- package/src/tools/media.ts +89 -91
- package/src/tools/pages.ts +86 -86
- package/src/tools/posts.ts +106 -106
- package/src/tools/site.ts +71 -71
- package/src/tools/taxonomies.ts +102 -102
- package/src/tools/users.ts +77 -77
- package/src/types/client.ts +1 -1
- package/src/types/index.ts +1 -1
- package/src/types/mcp.ts +36 -16
- package/src/types/wordpress.ts +1 -1
- package/src/utils/debug.ts +63 -39
- package/src/utils/error.ts +1 -1
- package/src/utils/toolWrapper.ts +4 -4
- package/dist/client/WordPressClient.d.ts +0 -81
- package/dist/client/WordPressClient.d.ts.map +0 -1
- package/dist/client/WordPressClient.js +0 -354
- package/dist/client/WordPressClient.js.map +0 -1
- package/dist/tools/base.d.ts +0 -37
- package/dist/tools/base.d.ts.map +0 -1
- package/dist/tools/base.js +0 -60
- package/dist/tools/base.js.map +0 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Maintenance Guide - MCP WordPress
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document outlines automated and manual processes to keep the project secure, up-to-date, and well-maintained.
|
|
6
|
+
|
|
7
|
+
## Automated Maintenance
|
|
8
|
+
|
|
9
|
+
### NPM Package Configuration
|
|
10
|
+
|
|
11
|
+
#### `.npmignore` File Maintenance
|
|
12
|
+
The `.npmignore` file is automatically checked before each publication:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Runs automatically before npm publish
|
|
16
|
+
npm run prepublishOnly
|
|
17
|
+
|
|
18
|
+
# Manual check
|
|
19
|
+
npm run check:ignore
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**What it checks:**
|
|
23
|
+
- ✅ **Security files** are excluded (`.env`, `.npmrc`, `*.pem`, `*.key`, credentials)
|
|
24
|
+
- ✅ **Test files** are excluded (`tests/`, `*.test.js`, `coverage/`)
|
|
25
|
+
- ✅ **Development files** are excluded (`src/`, config files, IDE settings)
|
|
26
|
+
- ✅ **CI/CD files** are excluded (`.github/`, various CI configs)
|
|
27
|
+
- ✅ **Logs and temporary files** are excluded
|
|
28
|
+
- ✅ **Documentation** is selectively included (README, LICENSE, CHANGELOG only)
|
|
29
|
+
|
|
30
|
+
#### Files Excluded from NPM Package
|
|
31
|
+
The following are **never** published to NPM:
|
|
32
|
+
|
|
33
|
+
**Security & Secrets:**
|
|
34
|
+
- `.env*` files
|
|
35
|
+
- `.npmrc` (contains auth tokens)
|
|
36
|
+
- `*.pem`, `*.key`, `*.cert` (certificates/keys)
|
|
37
|
+
- `credentials/`, `secrets/`, `auth/` directories
|
|
38
|
+
- `*.token`, `*.credentials` files
|
|
39
|
+
|
|
40
|
+
**Development Files:**
|
|
41
|
+
- `src/` (source TypeScript - only `dist/` is published)
|
|
42
|
+
- `tests/`, `coverage/`, test configuration files
|
|
43
|
+
- `tsconfig.json`, `eslint.config.js`
|
|
44
|
+
- `.vscode/`, `.idea/` (IDE settings)
|
|
45
|
+
|
|
46
|
+
**CI/CD & Git:**
|
|
47
|
+
- `.git/`, `.github/`
|
|
48
|
+
- `.gitignore`, `.gitattributes`
|
|
49
|
+
- CI configuration files (`.travis.yml`, `.circleci/`, etc.)
|
|
50
|
+
|
|
51
|
+
**Logs & Temporary:**
|
|
52
|
+
- `logs/`, `*.log`, `debug/`
|
|
53
|
+
- `tmp/`, `temp/`, `*.tmp`
|
|
54
|
+
- `test-results/`, `test-reports/`
|
|
55
|
+
|
|
56
|
+
**Documentation (Selective):**
|
|
57
|
+
- ❌ Development docs: `TODO.md`, `REFACTORING.md`, `MIGRATION_GUIDE.md`
|
|
58
|
+
- ❌ Release docs: `COMMUNITY_ANNOUNCEMENT_*.md`, `RELEASE_NOTES_*.md`
|
|
59
|
+
- ❌ Setup docs: `NPM_AUTH_SETUP.md`, `CLAUDE_DESKTOP_SETUP.md`
|
|
60
|
+
- ✅ User docs: `README.md`, `LICENSE`, `CHANGELOG.md`
|
|
61
|
+
|
|
62
|
+
### Scripts for Maintenance
|
|
63
|
+
|
|
64
|
+
#### Ignore Files Sync (`scripts/sync-ignore-files.js`)
|
|
65
|
+
Ensures `.gitignore` and `.npmignore` stay synchronized and secure:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Check ignore files manually
|
|
69
|
+
npm run check:ignore
|
|
70
|
+
|
|
71
|
+
# Automatically runs before publish
|
|
72
|
+
npm run prepublishOnly
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Features:**
|
|
76
|
+
- Verifies security patterns are in place
|
|
77
|
+
- Checks for missing patterns in both files
|
|
78
|
+
- Validates that sensitive files are properly excluded
|
|
79
|
+
- Reports summary statistics
|
|
80
|
+
|
|
81
|
+
#### Pre-commit Hooks
|
|
82
|
+
Automated checks before each commit:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Runs automatically on git commit
|
|
86
|
+
npm run pre-commit
|
|
87
|
+
|
|
88
|
+
# Manual run
|
|
89
|
+
npx lint-staged
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**What runs:**
|
|
93
|
+
- ESLint fixes on TypeScript/JavaScript
|
|
94
|
+
- Prettier formatting
|
|
95
|
+
- Markdown linting
|
|
96
|
+
- Package.json sorting
|
|
97
|
+
|
|
98
|
+
### Package.json Scripts Integration
|
|
99
|
+
|
|
100
|
+
The following scripts help maintain file integrity:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"scripts": {
|
|
105
|
+
"check:ignore": "node scripts/sync-ignore-files.js",
|
|
106
|
+
"prepublishOnly": "npm run build && npm run check:ignore",
|
|
107
|
+
"pre-commit": "lint-staged"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Manual Maintenance Tasks
|
|
113
|
+
|
|
114
|
+
### Weekly Tasks
|
|
115
|
+
|
|
116
|
+
1. **Dependency Updates**
|
|
117
|
+
```bash
|
|
118
|
+
npm audit
|
|
119
|
+
npm audit fix
|
|
120
|
+
npm outdated
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
2. **Security Review**
|
|
124
|
+
```bash
|
|
125
|
+
npm run check:ignore
|
|
126
|
+
git status # Ensure no sensitive files are staged
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
3. **Test Coverage Review**
|
|
130
|
+
```bash
|
|
131
|
+
npm run test:coverage
|
|
132
|
+
npm run health
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Monthly Tasks
|
|
136
|
+
|
|
137
|
+
1. **Comprehensive Security Review**
|
|
138
|
+
- Check `.gitignore` and `.npmignore` for new patterns
|
|
139
|
+
- Review npm audit results
|
|
140
|
+
- Verify no credentials in commit history
|
|
141
|
+
|
|
142
|
+
2. **Documentation Updates**
|
|
143
|
+
- Update README.md with new features
|
|
144
|
+
- Review and update CLAUDE.md
|
|
145
|
+
- Check all markdown files for accuracy
|
|
146
|
+
|
|
147
|
+
3. **Dependency Major Updates**
|
|
148
|
+
```bash
|
|
149
|
+
npm update
|
|
150
|
+
npm run test
|
|
151
|
+
npm run build
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Before Each Release
|
|
155
|
+
|
|
156
|
+
1. **Pre-publication Checklist**
|
|
157
|
+
```bash
|
|
158
|
+
# 1. Build and test everything
|
|
159
|
+
npm run build
|
|
160
|
+
npm test
|
|
161
|
+
npm run test:tools
|
|
162
|
+
npm run health
|
|
163
|
+
|
|
164
|
+
# 2. Check ignore files
|
|
165
|
+
npm run check:ignore
|
|
166
|
+
|
|
167
|
+
# 3. Verify no sensitive data
|
|
168
|
+
npm publish --dry-run
|
|
169
|
+
|
|
170
|
+
# 4. Check package contents
|
|
171
|
+
npx pkgfiles
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
2. **Security Verification**
|
|
175
|
+
- Verify `.npmrc` is not in the package
|
|
176
|
+
- Check that no `.env` files are included
|
|
177
|
+
- Ensure no credential files are packaged
|
|
178
|
+
- Review the file list from `npm publish --dry-run`
|
|
179
|
+
|
|
180
|
+
## Security Best Practices
|
|
181
|
+
|
|
182
|
+
### File Exclusion Patterns
|
|
183
|
+
|
|
184
|
+
**Always exclude from NPM:**
|
|
185
|
+
```
|
|
186
|
+
.env*
|
|
187
|
+
.npmrc
|
|
188
|
+
*.pem
|
|
189
|
+
*.key
|
|
190
|
+
*.cert
|
|
191
|
+
credentials/
|
|
192
|
+
secrets/
|
|
193
|
+
*.token
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Always exclude from Git:**
|
|
197
|
+
```
|
|
198
|
+
.env
|
|
199
|
+
.npmrc
|
|
200
|
+
mcp-wordpress.config.json
|
|
201
|
+
*.log
|
|
202
|
+
node_modules/
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Credential Management
|
|
206
|
+
|
|
207
|
+
1. **Local Development:**
|
|
208
|
+
- Store tokens in `~/.npmrc` or environment variables
|
|
209
|
+
- Never commit `.npmrc` to version control
|
|
210
|
+
- Use separate tokens for development vs. CI/CD
|
|
211
|
+
|
|
212
|
+
2. **CI/CD:**
|
|
213
|
+
- Use GitHub Secrets for `NPM_TOKEN`
|
|
214
|
+
- Use automation tokens (not personal tokens)
|
|
215
|
+
- Rotate tokens regularly
|
|
216
|
+
|
|
217
|
+
### Emergency Procedures
|
|
218
|
+
|
|
219
|
+
**If credentials are accidentally published:**
|
|
220
|
+
|
|
221
|
+
1. **Immediate Response:**
|
|
222
|
+
```bash
|
|
223
|
+
npm unpublish @aiondadotcom/mcp-wordpress@version
|
|
224
|
+
# Or deprecate if unpublish is not allowed
|
|
225
|
+
npm deprecate @aiondadotcom/mcp-wordpress@version "Security issue - use newer version"
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
2. **Credential Rotation:**
|
|
229
|
+
- Revoke compromised NPM tokens
|
|
230
|
+
- Rotate any exposed API keys
|
|
231
|
+
- Update GitHub secrets
|
|
232
|
+
- Regenerate any exposed credentials
|
|
233
|
+
|
|
234
|
+
3. **Republish:**
|
|
235
|
+
```bash
|
|
236
|
+
npm version patch
|
|
237
|
+
npm publish
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Monitoring and Alerts
|
|
241
|
+
|
|
242
|
+
### Automated Checks
|
|
243
|
+
|
|
244
|
+
The following run automatically:
|
|
245
|
+
- `prepublishOnly` before each npm publish
|
|
246
|
+
- `pre-commit` before each git commit
|
|
247
|
+
- CI/CD tests on every push/PR
|
|
248
|
+
|
|
249
|
+
### Manual Verification
|
|
250
|
+
|
|
251
|
+
Regular checks to perform:
|
|
252
|
+
```bash
|
|
253
|
+
# Check what would be published
|
|
254
|
+
npm publish --dry-run
|
|
255
|
+
|
|
256
|
+
# Verify ignore files are current
|
|
257
|
+
npm run check:ignore
|
|
258
|
+
|
|
259
|
+
# Check for sensitive files in working directory
|
|
260
|
+
git status --ignored
|
|
261
|
+
|
|
262
|
+
# Review recent commits for sensitive data
|
|
263
|
+
git log --oneline -10
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Tools and Dependencies
|
|
267
|
+
|
|
268
|
+
### Core Tools
|
|
269
|
+
- **ESLint**: Code quality and consistency
|
|
270
|
+
- **Prettier**: Code formatting
|
|
271
|
+
- **Husky**: Git hooks management
|
|
272
|
+
- **lint-staged**: Run linters on staged files
|
|
273
|
+
- **Jest**: Testing framework
|
|
274
|
+
|
|
275
|
+
### Security Tools
|
|
276
|
+
- **npm audit**: Vulnerability scanning
|
|
277
|
+
- **Custom scripts**: File exclusion verification
|
|
278
|
+
- **Git hooks**: Pre-commit security checks
|
|
279
|
+
|
|
280
|
+
### Maintenance Commands Summary
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
# Daily development
|
|
284
|
+
npm run dev
|
|
285
|
+
npm test
|
|
286
|
+
npm run lint
|
|
287
|
+
|
|
288
|
+
# Before commit
|
|
289
|
+
npm run pre-commit # (runs automatically)
|
|
290
|
+
|
|
291
|
+
# Before release
|
|
292
|
+
npm run build
|
|
293
|
+
npm run check:ignore
|
|
294
|
+
npm publish --dry-run
|
|
295
|
+
npm publish
|
|
296
|
+
|
|
297
|
+
# Security checks
|
|
298
|
+
npm audit
|
|
299
|
+
npm run check:ignore
|
|
300
|
+
git status --ignored
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
This maintenance approach ensures:
|
|
304
|
+
- 🔒 **Security**: No sensitive files ever published
|
|
305
|
+
- 📦 **Optimization**: Minimal package size
|
|
306
|
+
- 🔄 **Automation**: Critical checks run automatically
|
|
307
|
+
- 📋 **Consistency**: Standardized maintenance procedures
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Migration Guide: Single-Site to Multi-Site Configuration
|
|
2
|
+
|
|
3
|
+
This guide helps you migrate from the previous single-site configuration to the new multi-site configuration introduced in v2.0.0.
|
|
4
|
+
|
|
5
|
+
## Breaking Changes
|
|
6
|
+
|
|
7
|
+
### 1. Configuration Method Changed
|
|
8
|
+
|
|
9
|
+
**Old Method (Environment Variables):**
|
|
10
|
+
```bash
|
|
11
|
+
WORDPRESS_SITE_URL=https://example.com
|
|
12
|
+
WORDPRESS_USERNAME=admin
|
|
13
|
+
WORDPRESS_APP_PASSWORD=xxxx xxxx xxxx xxxx xxxx xxxx
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**New Method (Configuration File):**
|
|
17
|
+
Create a `mcp-wordpress.config.json` file:
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"sites": [
|
|
21
|
+
{
|
|
22
|
+
"id": "main",
|
|
23
|
+
"name": "My WordPress Site",
|
|
24
|
+
"config": {
|
|
25
|
+
"WORDPRESS_SITE_URL": "https://example.com",
|
|
26
|
+
"WORDPRESS_USERNAME": "admin",
|
|
27
|
+
"WORDPRESS_APP_PASSWORD": "xxxx xxxx xxxx xxxx xxxx xxxx"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. Tool Usage Changed
|
|
35
|
+
|
|
36
|
+
All tools now require a `site` parameter when multiple sites are configured.
|
|
37
|
+
|
|
38
|
+
**Old Usage:**
|
|
39
|
+
```
|
|
40
|
+
wp_list_posts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**New Usage:**
|
|
44
|
+
```
|
|
45
|
+
wp_list_posts --site="main"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Note: If only one site is configured, the `site` parameter is optional and that site will be used by default.
|
|
49
|
+
|
|
50
|
+
### 3. Tool Architecture Refactored
|
|
51
|
+
|
|
52
|
+
Tools have been refactored from function-based to class-based architecture:
|
|
53
|
+
- All tools are now organized into classes (e.g., `PostTools`, `PageTools`)
|
|
54
|
+
- Tool registration is centralized through `src/tools/index.ts`
|
|
55
|
+
- Each tool category has its own class file in `src/tools/`
|
|
56
|
+
|
|
57
|
+
## Migration Steps
|
|
58
|
+
|
|
59
|
+
### Step 1: Backup Your Configuration
|
|
60
|
+
|
|
61
|
+
Save your current environment variables:
|
|
62
|
+
```bash
|
|
63
|
+
cp .env .env.backup
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Step 2: Create Configuration File
|
|
67
|
+
|
|
68
|
+
Create `mcp-wordpress.config.json` in the project root:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"sites": [
|
|
73
|
+
{
|
|
74
|
+
"id": "main",
|
|
75
|
+
"name": "Your Site Name",
|
|
76
|
+
"config": {
|
|
77
|
+
"WORDPRESS_SITE_URL": "YOUR_SITE_URL",
|
|
78
|
+
"WORDPRESS_USERNAME": "YOUR_USERNAME",
|
|
79
|
+
"WORDPRESS_APP_PASSWORD": "YOUR_APP_PASSWORD",
|
|
80
|
+
"WORDPRESS_AUTH_METHOD": "app-password"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Replace the values with your actual configuration from `.env`.
|
|
88
|
+
|
|
89
|
+
### Step 3: Update Tool Usage
|
|
90
|
+
|
|
91
|
+
If you have scripts or automation using the tools, update them to include the site parameter:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Old
|
|
95
|
+
wp_create_post --title="Hello" --content="World"
|
|
96
|
+
|
|
97
|
+
# New (explicit site)
|
|
98
|
+
wp_create_post --site="main" --title="Hello" --content="World"
|
|
99
|
+
|
|
100
|
+
# New (implicit - only works with single site)
|
|
101
|
+
wp_create_post --title="Hello" --content="World"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Step 4: Test Your Configuration
|
|
105
|
+
|
|
106
|
+
Run the health check to verify your configuration:
|
|
107
|
+
```bash
|
|
108
|
+
npm run health
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Step 5: Remove Old Configuration (Optional)
|
|
112
|
+
|
|
113
|
+
Once verified, you can remove the old `.env` file:
|
|
114
|
+
```bash
|
|
115
|
+
rm .env
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Adding Multiple Sites
|
|
119
|
+
|
|
120
|
+
The main benefit of the new configuration is support for multiple WordPress sites:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"sites": [
|
|
125
|
+
{
|
|
126
|
+
"id": "site1",
|
|
127
|
+
"name": "Main Website",
|
|
128
|
+
"config": {
|
|
129
|
+
"WORDPRESS_SITE_URL": "https://site1.com",
|
|
130
|
+
"WORDPRESS_USERNAME": "admin1",
|
|
131
|
+
"WORDPRESS_APP_PASSWORD": "password1"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"id": "site2",
|
|
136
|
+
"name": "Blog",
|
|
137
|
+
"config": {
|
|
138
|
+
"WORDPRESS_SITE_URL": "https://blog.site2.com",
|
|
139
|
+
"WORDPRESS_USERNAME": "admin2",
|
|
140
|
+
"WORDPRESS_APP_PASSWORD": "password2"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Then use tools with specific sites:
|
|
148
|
+
```bash
|
|
149
|
+
wp_list_posts --site="site1"
|
|
150
|
+
wp_create_post --site="site2" --title="New Blog Post"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Backward Compatibility
|
|
154
|
+
|
|
155
|
+
The server maintains backward compatibility with environment variables. If no `mcp-wordpress.config.json` file is found, it will fall back to using environment variables as before.
|
|
156
|
+
|
|
157
|
+
## Troubleshooting
|
|
158
|
+
|
|
159
|
+
### Issue: "Site parameter is required"
|
|
160
|
+
**Solution:** When multiple sites are configured, you must specify which site to use with the `--site` parameter.
|
|
161
|
+
|
|
162
|
+
### Issue: "Site 'xyz' not found"
|
|
163
|
+
**Solution:** Check that the site ID in your command matches an ID in your configuration file.
|
|
164
|
+
|
|
165
|
+
### Issue: Tools not working after migration
|
|
166
|
+
**Solution:** Run `npm run health` to diagnose configuration issues.
|
|
167
|
+
|
|
168
|
+
## Need Help?
|
|
169
|
+
|
|
170
|
+
- Check the [CLAUDE.md](./CLAUDE.md) file for detailed documentation
|
|
171
|
+
- Run `npm run health` for system diagnostics
|
|
172
|
+
- Open an issue on GitHub if you encounter problems
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# NPM Authentication Setup
|
|
2
|
+
|
|
3
|
+
## Quick Setup for This Project
|
|
4
|
+
|
|
5
|
+
The project includes a pre-configured `.npmrc` file that uses environment variables:
|
|
6
|
+
|
|
7
|
+
1. **Set your NPM token as environment variable:**
|
|
8
|
+
```bash
|
|
9
|
+
export NPM_TOKEN="your_npm_token_here"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
2. **Or add to your shell profile:**
|
|
13
|
+
```bash
|
|
14
|
+
# Add to ~/.bashrc, ~/.zshrc, or ~/.profile
|
|
15
|
+
echo 'export NPM_TOKEN="your_npm_token_here"' >> ~/.zshrc
|
|
16
|
+
source ~/.zshrc
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
3. **Verify authentication:**
|
|
20
|
+
```bash
|
|
21
|
+
npm whoami
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
4. **Publish:**
|
|
25
|
+
```bash
|
|
26
|
+
npm publish
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Local NPM Authentication Methods
|
|
30
|
+
|
|
31
|
+
### Method 1: Using NPM Token (Recommended for Automation)
|
|
32
|
+
|
|
33
|
+
1. **Create an NPM automation token**:
|
|
34
|
+
- Log in to npmjs.com
|
|
35
|
+
- Go to Account Settings → Access Tokens
|
|
36
|
+
- Click "Generate New Token" → Choose "Automation" type
|
|
37
|
+
- Copy the generated token
|
|
38
|
+
|
|
39
|
+
2. **Store the token locally**:
|
|
40
|
+
|
|
41
|
+
Create or edit `~/.npmrc`:
|
|
42
|
+
```bash
|
|
43
|
+
echo "//registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN" >> ~/.npmrc
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or set it for this project only in `.npmrc` (in project root):
|
|
47
|
+
```bash
|
|
48
|
+
# Copy the example file
|
|
49
|
+
cp .npmrc.example .npmrc
|
|
50
|
+
|
|
51
|
+
# Edit .npmrc with your token (if not using environment variable)
|
|
52
|
+
echo "//registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN" > .npmrc
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
3. **Using environment variable** (more secure):
|
|
56
|
+
```bash
|
|
57
|
+
# Add to ~/.bashrc or ~/.zshrc
|
|
58
|
+
export NPM_TOKEN="your_npm_token_here"
|
|
59
|
+
|
|
60
|
+
# Then in .npmrc:
|
|
61
|
+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Method 2: Interactive Login
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm login
|
|
68
|
+
# Follow the prompts for username, password, email, and 2FA code
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This creates an entry in `~/.npmrc` automatically.
|
|
72
|
+
|
|
73
|
+
### Method 3: Using npm CLI with Token
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm config set //registry.npmjs.org/:_authToken YOUR_NPM_TOKEN
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Security Best Practices
|
|
80
|
+
|
|
81
|
+
1. **Never commit `.npmrc` with tokens** to version control
|
|
82
|
+
- Add `.npmrc` to `.gitignore` if storing tokens there
|
|
83
|
+
- Use environment variables for tokens
|
|
84
|
+
|
|
85
|
+
2. **Use different tokens for different purposes**:
|
|
86
|
+
- Personal development: Read-only or Publish token
|
|
87
|
+
- CI/CD: Automation token (like your NPM_TOKEN in GitHub secrets)
|
|
88
|
+
- Team projects: Shared organization tokens
|
|
89
|
+
|
|
90
|
+
3. **Token permissions**:
|
|
91
|
+
- **Read-only**: Can only install packages
|
|
92
|
+
- **Publish**: Can publish new versions
|
|
93
|
+
- **Automation**: Best for CI/CD, can publish but has restrictions
|
|
94
|
+
|
|
95
|
+
## Publishing with Token
|
|
96
|
+
|
|
97
|
+
Once authenticated, publish with:
|
|
98
|
+
```bash
|
|
99
|
+
npm publish
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Or with explicit registry:
|
|
103
|
+
```bash
|
|
104
|
+
npm publish --registry https://registry.npmjs.org/
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Verifying Authentication
|
|
108
|
+
|
|
109
|
+
Check if you're logged in:
|
|
110
|
+
```bash
|
|
111
|
+
npm whoami
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## GitHub Actions Setup (Already Done)
|
|
115
|
+
|
|
116
|
+
Your `NPM_TOKEN` is already stored in GitHub secrets. For automated publishing via GitHub Actions, use:
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
- name: Setup Node.js
|
|
120
|
+
uses: actions/setup-node@v3
|
|
121
|
+
with:
|
|
122
|
+
node-version: '18'
|
|
123
|
+
registry-url: 'https://registry.npmjs.org'
|
|
124
|
+
|
|
125
|
+
- name: Publish to NPM
|
|
126
|
+
run: npm publish
|
|
127
|
+
env:
|
|
128
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Troubleshooting
|
|
132
|
+
|
|
133
|
+
1. **401 Unauthorized**: Token is invalid or expired
|
|
134
|
+
2. **403 Forbidden**: Token lacks publish permissions
|
|
135
|
+
3. **E402**: Package requires payment (for private packages)
|
|
136
|
+
|
|
137
|
+
## Revoking Tokens
|
|
138
|
+
|
|
139
|
+
If a token is compromised:
|
|
140
|
+
1. Go to npmjs.com → Account Settings → Access Tokens
|
|
141
|
+
2. Find the token and click "Revoke"
|
|
142
|
+
3. Generate a new token and update your configurations
|