localwp-mcp 0.1.3 → 0.1.5

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/LICENSE CHANGED
@@ -1,15 +1,15 @@
1
- ISC License
2
-
3
- Copyright (c) 2026
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
1
+ ISC License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,212 +1,227 @@
1
- # localwp-mcp
2
-
3
- `localwp-mcp` gives AI agents direct access to LocalWP sites through MCP.
4
-
5
- It automatically finds your Local sites, uses the correct Local PHP and MySQL runtimes for each one, and lets an agent work with WordPress through WP-CLI, MySQL, logs, diagnostics, backups, and restore flows.
6
-
7
- ## What You Can Do
8
-
9
- - inspect Local sites and their runtime details
10
- - start, stop, and restart Local sites
11
- - list, read, search, write, and delete files inside a selected Local site
12
- - run WP-CLI against the correct site
13
- - query the WordPress database
14
- - allow full database writes when you want unrestricted local development
15
- - read recent logs and run site health checks
16
- - export, import, back up, and restore LocalWP sites
17
-
18
- ## Install
19
-
20
- Use `npx` in your MCP client:
21
-
22
- ```json
23
- {
24
- "mcpServers": {
25
- "localwp": {
26
- "command": "npx",
27
- "args": ["localwp-mcp"],
28
- "env": {
29
- "LOCALWP_MCP_PROFILE": "safe"
30
- }
31
- }
32
- }
33
- }
34
- ```
35
-
36
- You can also install it globally:
37
-
38
- ```bash
39
- npm install -g localwp-mcp
40
- ```
41
-
42
- Then use:
43
-
44
- ```json
45
- {
46
- "mcpServers": {
47
- "localwp": {
48
- "command": "localwp-mcp",
49
- "env": {
50
- "LOCALWP_MCP_PROFILE": "safe"
51
- }
52
- }
53
- }
54
- }
55
- ```
56
-
57
- If you want the MCP to focus on one site by default, set:
58
-
59
- ```json
60
- {
61
- "LOCAL_SITE_NAME": "example-site"
62
- }
63
- ```
64
-
65
- ## Access Modes
66
-
67
- `localwp-mcp` has 2 access modes:
68
-
69
- - `safe`
70
- Best default for most people. Safe WordPress inspection commands, diagnostics, logs, database reads, and backup/export flows.
71
- - `full-access`
72
- Best when you want the agent to fully work on your local site, including SQL writes, imports, and restore operations.
73
-
74
- `safe` is the default.
75
-
76
- To enable full local access:
77
-
78
- ```json
79
- {
80
- "LOCALWP_MCP_PROFILE": "full-access"
81
- }
82
- ```
83
-
84
- ## First Things To Try
85
-
86
- Start with:
87
-
88
- - `local_environment_check`
89
- - `local_doctor`
90
- - `list_local_sites`
91
-
92
- Those will tell you:
93
-
94
- - which Local sites were discovered
95
- - whether the site is running
96
- - which Local runtimes were resolved
97
- - whether WP-CLI and MySQL are reachable
98
-
99
- ## Common Workflows
100
-
101
- ### Inspect a Site
102
-
103
- Use:
104
-
105
- - `local_site_info`
106
- - `local_doctor`
107
- - `local_logs`
108
-
109
- ### Work With Site Files
110
-
111
- Use:
112
-
113
- - `list_site_files`
114
- - `read_site_file`
115
- - `search_site_files`
116
- - `write_site_file`
117
- - `delete_site_file`
118
-
119
- These tools are always scoped to the selected site's root directory.
120
-
121
- - In `safe`, you can list, read, and search files.
122
- - In `full-access`, you can also write and delete files.
123
-
124
- ### Control a Local Site
125
-
126
- Use:
127
-
128
- - `start_local_site`
129
- - `stop_local_site`
130
- - `restart_local_site`
131
-
132
- ### Work With WordPress
133
-
134
- Use:
135
-
136
- - `execute_wp_cli`
137
-
138
- Examples:
139
-
140
- - list plugins
141
- - inspect options
142
- - list posts or users
143
- - run plugin-specific WP-CLI commands
144
-
145
- ### Work With the Database
146
-
147
- Use:
148
-
149
- - `mysql_query`
150
- Read-only SQL in `safe`
151
- - `mysql_execute`
152
- Full SQL execution in `full-access`
153
- - `mysql_schema`
154
- Table listing and table description helpers
155
-
1
+ # localwp-mcp
2
+
3
+ `localwp-mcp` gives AI agents direct access to LocalWP sites through MCP.
4
+
5
+ It automatically finds your Local sites, uses the correct Local PHP and MySQL runtimes for each one, and lets an agent work with WordPress through WP-CLI, MySQL, logs, diagnostics, backups, and restore flows.
6
+
7
+ ## What You Can Do
8
+
9
+ - inspect Local sites and their runtime details
10
+ - start, stop, and restart Local sites
11
+ - list, read, search, write, and delete files inside a selected Local site
12
+ - run WP-CLI against the correct site
13
+ - query the WordPress database
14
+ - allow full database writes when you want unrestricted local development
15
+ - read recent logs and run site health checks
16
+ - export, import, back up, and restore LocalWP sites
17
+
18
+ ## Install
19
+
20
+ Use `npx` in your MCP client:
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "localwp": {
26
+ "command": "npx",
27
+ "args": ["localwp-mcp"],
28
+ "env": {
29
+ "LOCALWP_MCP_PROFILE": "safe"
30
+ }
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ You can also install it globally:
37
+
38
+ ```bash
39
+ npm install -g localwp-mcp
40
+ ```
41
+
42
+ Then use:
43
+
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "localwp": {
48
+ "command": "localwp-mcp",
49
+ "env": {
50
+ "LOCALWP_MCP_PROFILE": "safe"
51
+ }
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ If you want the MCP to focus on one site by default, set:
58
+
59
+ ```json
60
+ {
61
+ "LOCAL_SITE_NAME": "example-site"
62
+ }
63
+ ```
64
+
65
+ ## Access Modes
66
+
67
+ `localwp-mcp` has 2 access modes:
68
+
69
+ - `safe`
70
+ Best default for most people. Safe WordPress inspection commands, diagnostics, logs, database reads, and backup/export flows.
71
+ - `full-access`
72
+ Best when you want the agent to fully work on your local site, including SQL writes, imports, and restore operations.
73
+
74
+ `safe` is the default.
75
+
76
+ To enable full local access:
77
+
78
+ ```json
79
+ {
80
+ "LOCALWP_MCP_PROFILE": "full-access"
81
+ }
82
+ ```
83
+
84
+ ## First Things To Try
85
+
86
+ Start with:
87
+
88
+ - `local_environment_check`
89
+ - `local_doctor`
90
+ - `list_local_sites`
91
+
92
+ Those will tell you:
93
+
94
+ - which Local sites were discovered
95
+ - whether the site is running
96
+ - which Local runtimes were resolved
97
+ - whether WP-CLI and MySQL are reachable
98
+
99
+ ## Common Workflows
100
+
101
+ ### Inspect a Site
102
+
103
+ Use:
104
+
105
+ - `local_site_info`
106
+ - `local_doctor`
107
+ - `local_logs`
108
+
109
+ ### Work With Site Files
110
+
111
+ Use:
112
+
113
+ - `list_site_files`
114
+ - `read_site_file`
115
+ - `search_site_files`
116
+ - `write_site_file`
117
+ - `delete_site_file`
118
+
119
+ These tools are always scoped to the selected site's root directory.
120
+
121
+ - In `safe`, you can list, read, and search files.
122
+ - In `full-access`, you can also write and delete files.
123
+
124
+ ### Control a Local Site
125
+
126
+ Use:
127
+
128
+ - `start_local_site`
129
+ - `stop_local_site`
130
+ - `restart_local_site`
131
+
132
+ ### Work With WordPress
133
+
134
+ Use:
135
+
136
+ - `execute_wp_cli`
137
+
138
+ Examples:
139
+
140
+ - list plugins
141
+ - inspect options
142
+ - list posts or users
143
+ - run plugin-specific WP-CLI commands
144
+
145
+ ### Work With the Database
146
+
147
+ Use:
148
+
149
+ - `mysql_query`
150
+ Read-only SQL in `safe`
151
+ - `mysql_execute`
152
+ Full SQL execution in `full-access`
153
+ - `mysql_schema`
154
+ Table listing and table description helpers
155
+
156
156
  ### Back Up or Restore a Site
157
157
 
158
158
  Use:
159
159
 
160
160
  - `backup_site`
161
+ - `list_backups`
162
+ - `delete_backup`
163
+ - `cleanup_backups`
161
164
  - `db_export`
162
165
  - `db_import`
163
166
  - `restore_backup`
164
-
165
- `backup_site` supports:
166
-
167
- - `database`
168
- - `full`
169
-
167
+
168
+ `backup_site` supports:
169
+
170
+ - `database`
171
+ - `full`
172
+
170
173
  The `full` backup format is folder-based and includes the site's `app`, `conf`, and `logs` directories plus a fresh SQL dump.
171
174
 
172
- ## Built-In Capabilities
173
-
174
- ### Tools
175
-
176
- - `list_local_sites`
177
- - `start_local_site`
178
- - `stop_local_site`
179
- - `restart_local_site`
180
- - `local_environment_check`
181
- - `local_doctor`
182
- - `local_logs`
183
- - `local_site_info`
184
- - `list_site_files`
185
- - `read_site_file`
186
- - `search_site_files`
187
- - `write_site_file`
188
- - `delete_site_file`
189
- - `execute_wp_cli`
190
- - `mysql_query`
191
- - `mysql_execute`
175
+ If you want to manage backup storage over time:
176
+
177
+ - `list_backups`
178
+ Shows the managed backup directories and SQL artifacts for a site.
179
+ - `delete_backup`
180
+ Removes one managed backup artifact in `full-access`.
181
+ - `cleanup_backups`
182
+ Cleans up older backups by age and/or retention count in `full-access`.
183
+
184
+ ## Built-In Capabilities
185
+
186
+ ### Tools
187
+
188
+ - `list_local_sites`
189
+ - `start_local_site`
190
+ - `stop_local_site`
191
+ - `restart_local_site`
192
+ - `local_environment_check`
193
+ - `local_doctor`
194
+ - `local_logs`
195
+ - `local_site_info`
196
+ - `list_site_files`
197
+ - `read_site_file`
198
+ - `search_site_files`
199
+ - `write_site_file`
200
+ - `delete_site_file`
201
+ - `execute_wp_cli`
202
+ - `mysql_query`
203
+ - `mysql_execute`
192
204
  - `mysql_schema`
193
205
  - `db_export`
194
206
  - `db_import`
195
207
  - `backup_site`
208
+ - `list_backups`
209
+ - `delete_backup`
210
+ - `cleanup_backups`
196
211
  - `restore_backup`
197
-
198
- ### MCP Resources
199
-
200
- - `localwp://sites`
201
- - `localwp://sites/{siteName}/summary`
202
- - `localwp://sites/{siteName}/doctor`
203
- - `localwp://sites/{siteName}/logs`
204
-
205
- ### MCP Prompts
206
-
207
- - `diagnose_local_site`
208
- - `restore_local_site`
209
-
212
+
213
+ ### MCP Resources
214
+
215
+ - `localwp://sites`
216
+ - `localwp://sites/{siteName}/summary`
217
+ - `localwp://sites/{siteName}/doctor`
218
+ - `localwp://sites/{siteName}/logs`
219
+
220
+ ### MCP Prompts
221
+
222
+ - `diagnose_local_site`
223
+ - `restore_local_site`
224
+
210
225
  ## Platform Support
211
226
 
212
227
  `localwp-mcp` is designed for:
@@ -217,38 +232,45 @@ The `full` backup format is folder-based and includes the site's `app`, `conf`,
217
232
 
218
233
  It supports both current Local `lightning-services` layouts and older `site-binaries` layouts.
219
234
 
220
- ## Useful Environment Variables
221
-
222
- Most users only need these:
223
-
224
- - `LOCALWP_MCP_PROFILE`
225
- - `LOCAL_SITE_NAME`
226
- - `LOCAL_SITE_ID`
227
- - `LOCALWP_MCP_BACKUPS_DIR`
235
+ Live validation has been completed on:
228
236
 
229
- Advanced override variables also exist for custom Local layouts, but most installations do not need them.
230
-
231
- ## Troubleshooting
232
-
233
- If the MCP does not find your site or cannot run WP-CLI/MySQL:
234
-
235
- 1. Start the site in Local.
236
- 2. Run `local_environment_check`.
237
- 3. Run `local_doctor`.
238
- 4. Check `local_logs`.
239
-
240
- Those tools are the fastest way to see whether the problem is:
241
-
242
- - site selection
243
- - Local metadata resolution
244
- - WP-CLI resolution
245
- - MySQL connectivity
246
- - missing or stopped Local services
247
-
248
- ## For Contributors
249
-
250
- Contributor and maintainer docs live outside the main user guide:
237
+ - macOS
238
+ - Windows
251
239
 
252
- - [CONTRIBUTING.md](./CONTRIBUTING.md)
253
- - [SECURITY.md](./SECURITY.md)
254
- - [Maintainer Docs](./docs/maintainers/README.md)
240
+ Linux support is implemented in the code paths and tests, but has not yet been live-validated on a machine with LocalWP.
241
+
242
+ ## Useful Environment Variables
243
+
244
+ Most users only need these:
245
+
246
+ - `LOCALWP_MCP_PROFILE`
247
+ - `LOCAL_SITE_NAME`
248
+ - `LOCAL_SITE_ID`
249
+ - `LOCALWP_MCP_BACKUPS_DIR`
250
+
251
+ Advanced override variables also exist for custom Local layouts, but most installations do not need them.
252
+
253
+ ## Troubleshooting
254
+
255
+ If the MCP does not find your site or cannot run WP-CLI/MySQL:
256
+
257
+ 1. Start the site in Local.
258
+ 2. Run `local_environment_check`.
259
+ 3. Run `local_doctor`.
260
+ 4. Check `local_logs`.
261
+
262
+ Those tools are the fastest way to see whether the problem is:
263
+
264
+ - site selection
265
+ - Local metadata resolution
266
+ - WP-CLI resolution
267
+ - MySQL connectivity
268
+ - missing or stopped Local services
269
+
270
+ ## For Contributors
271
+
272
+ Contributor and maintainer docs live outside the main user guide:
273
+
274
+ - [CONTRIBUTING.md](./CONTRIBUTING.md)
275
+ - [SECURITY.md](./SECURITY.md)
276
+ - [Maintainer Docs](./docs/maintainers/README.md)
@@ -0,0 +1,121 @@
1
+ import type { BackupArtifactCategory, BackupScope, SiteContext } from "./types.js";
2
+ export declare const backupArtifactCategories: readonly ["full_backup", "database_backup", "pre_restore_backup", "database_export", "pre_import_backup", "sql_file"];
3
+ interface BackupArtifact {
4
+ path: string;
5
+ absolutePath: string;
6
+ kind: "file" | "directory";
7
+ category: BackupArtifactCategory;
8
+ createdAt: string;
9
+ modifiedAt: string;
10
+ sizeBytes: number;
11
+ manifestPath: string | null;
12
+ manifestCreatedAt: string | null;
13
+ scope: BackupScope | null;
14
+ }
15
+ export declare function listManagedBackups(context: SiteContext, options?: {
16
+ rootPath?: string;
17
+ }): Promise<{
18
+ site: {
19
+ id: string;
20
+ name: string;
21
+ status: string;
22
+ domain: string | undefined;
23
+ path: string;
24
+ wpRoot: string;
25
+ localVersion: string | undefined;
26
+ phpVersion: string | null;
27
+ mysqlVersion: string | null;
28
+ httpPort: number | null;
29
+ mysqlPort: number | null;
30
+ };
31
+ selectionMethod: string | undefined;
32
+ accessProfile: import("./types.js").AccessProfile;
33
+ backupRoot: string;
34
+ artifacts: BackupArtifact[];
35
+ }>;
36
+ export declare function deleteManagedBackup(context: SiteContext, options: {
37
+ backupPath: string;
38
+ rootPath?: string;
39
+ missingOk?: boolean;
40
+ }): Promise<{
41
+ targetPath: string;
42
+ deleted: boolean;
43
+ existedBefore: boolean;
44
+ missingOk: boolean;
45
+ site: {
46
+ id: string;
47
+ name: string;
48
+ status: string;
49
+ domain: string | undefined;
50
+ path: string;
51
+ wpRoot: string;
52
+ localVersion: string | undefined;
53
+ phpVersion: string | null;
54
+ mysqlVersion: string | null;
55
+ httpPort: number | null;
56
+ mysqlPort: number | null;
57
+ };
58
+ selectionMethod: string | undefined;
59
+ accessProfile: import("./types.js").AccessProfile;
60
+ backupRoot: string;
61
+ artifacts: BackupArtifact[];
62
+ } | {
63
+ targetPath: string;
64
+ deleted: boolean;
65
+ existedBefore: boolean;
66
+ deletedArtifact: BackupArtifact;
67
+ missingOk: boolean;
68
+ site: {
69
+ id: string;
70
+ name: string;
71
+ status: string;
72
+ domain: string | undefined;
73
+ path: string;
74
+ wpRoot: string;
75
+ localVersion: string | undefined;
76
+ phpVersion: string | null;
77
+ mysqlVersion: string | null;
78
+ httpPort: number | null;
79
+ mysqlPort: number | null;
80
+ };
81
+ selectionMethod: string | undefined;
82
+ accessProfile: import("./types.js").AccessProfile;
83
+ backupRoot: string;
84
+ artifacts: BackupArtifact[];
85
+ }>;
86
+ export declare function cleanupManagedBackups(context: SiteContext, options?: {
87
+ rootPath?: string;
88
+ categories?: BackupArtifactCategory[];
89
+ olderThanDays?: number;
90
+ keepLatest?: number;
91
+ dryRun?: boolean;
92
+ }): Promise<{
93
+ categories: BackupArtifactCategory[];
94
+ olderThanDays: number | null;
95
+ keepLatest: number | null;
96
+ dryRun: boolean;
97
+ deletedCount: number;
98
+ reclaimedBytesEstimate: number;
99
+ deletedArtifacts: BackupArtifact[];
100
+ candidateArtifacts: BackupArtifact[];
101
+ retainedArtifacts: BackupArtifact[];
102
+ site: {
103
+ id: string;
104
+ name: string;
105
+ status: string;
106
+ domain: string | undefined;
107
+ path: string;
108
+ wpRoot: string;
109
+ localVersion: string | undefined;
110
+ phpVersion: string | null;
111
+ mysqlVersion: string | null;
112
+ httpPort: number | null;
113
+ mysqlPort: number | null;
114
+ };
115
+ selectionMethod: string | undefined;
116
+ accessProfile: import("./types.js").AccessProfile;
117
+ backupRoot: string;
118
+ artifacts: BackupArtifact[];
119
+ }>;
120
+ export declare function resolveManagedBackupRoot(context: SiteContext, rootPath?: string): string;
121
+ export {};