localwp-mcp 0.1.0 → 0.1.1

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 CHANGED
@@ -1,62 +1,21 @@
1
1
  # localwp-mcp
2
2
 
3
- `localwp-mcp` is an MCP server for LocalWP projects.
3
+ `localwp-mcp` gives AI agents direct access to LocalWP sites through MCP.
4
4
 
5
- It discovers Local sites from Local's own metadata, resolves the correct Local PHP and MySQL runtimes for each site, and gives AI agents simple access to:
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
6
 
7
- - Local site discovery
8
- - Local logs and doctor-style diagnostics
9
- - site-aware WP-CLI
10
- - safe SQL reads
11
- - full SQL access when you opt into it
12
- - database export/import
13
- - Local-friendly backups
14
- - restore workflows
15
- - machine-readable Local diagnostics
16
- - MCP resources and prompts
7
+ ## What You Can Do
17
8
 
18
- ## Project Docs
9
+ - inspect Local sites and their runtime details
10
+ - run WP-CLI against the correct site
11
+ - query the WordPress database
12
+ - allow full database writes when you want unrestricted local development
13
+ - read recent logs and run site health checks
14
+ - export, import, back up, and restore LocalWP sites
19
15
 
20
- - [Contributing](./CONTRIBUTING.md)
21
- - [Security Policy](./SECURITY.md)
22
- - [Release Checklist](./docs/RELEASE_CHECKLIST.md)
23
- - [Windows Test Handoff](./docs/WINDOWS_TEST_HANDOFF.md)
16
+ ## Install
24
17
 
25
- ## Profiles
26
-
27
- The package now has only 2 profiles:
28
-
29
- - `safe`
30
- Good default. Read-focused SQL plus safe WP-CLI inspection commands.
31
- - `full-access`
32
- Best for local development when you want the agent to fully work on the site and database.
33
-
34
- `safe` is the default.
35
-
36
- ## Tools
37
-
38
- - `list_local_sites`
39
- - `local_environment_check`
40
- - `local_doctor`
41
- - `local_logs`
42
- - `local_site_info`
43
- - `backup_site`
44
- - `db_export`
45
- - `db_import`
46
- - `restore_backup`
47
- - `mysql_query`
48
- Safe profile SQL reads only.
49
- - `mysql_execute`
50
- Full-access profile single-statement SQL execution.
51
- - `mysql_schema`
52
- Accepts `table` and also `tableName` as a compatibility alias.
53
- - `execute_wp_cli`
54
-
55
- ## Quick Setup
56
-
57
- ### npm
58
-
59
- Once published, the simplest MCP config is:
18
+ Use `npx` in your MCP client:
60
19
 
61
20
  ```json
62
21
  {
@@ -65,23 +24,20 @@ Once published, the simplest MCP config is:
65
24
  "command": "npx",
66
25
  "args": ["localwp-mcp"],
67
26
  "env": {
68
- "LOCAL_SITE_NAME": "plovercrm",
69
- "LOCALWP_MCP_PROFILE": "full-access"
27
+ "LOCALWP_MCP_PROFILE": "safe"
70
28
  }
71
29
  }
72
30
  }
73
31
  }
74
32
  ```
75
33
 
76
- If you want the cautious default instead, set:
34
+ You can also install it globally:
77
35
 
78
- ```json
79
- {
80
- "LOCALWP_MCP_PROFILE": "safe"
81
- }
36
+ ```bash
37
+ npm install -g localwp-mcp
82
38
  ```
83
39
 
84
- After a global install, you can also use:
40
+ Then use:
85
41
 
86
42
  ```json
87
43
  {
@@ -96,134 +52,192 @@ After a global install, you can also use:
96
52
  }
97
53
  ```
98
54
 
99
- ### From Source
100
-
101
- If you are running from a local clone:
55
+ If you want the MCP to focus on one site by default, set:
102
56
 
103
- ```bash
104
- pnpm install
105
- pnpm build
57
+ ```json
58
+ {
59
+ "LOCAL_SITE_NAME": "example-site"
60
+ }
106
61
  ```
107
62
 
108
- Then point your MCP client at the built entrypoint:
63
+ ## Access Modes
64
+
65
+ `localwp-mcp` has 2 access modes:
66
+
67
+ - `safe`
68
+ Best default for most people. Safe WordPress inspection commands, diagnostics, logs, database reads, and backup/export flows.
69
+ - `full-access`
70
+ Best when you want the agent to fully work on your local site, including SQL writes, imports, and restore operations.
71
+
72
+ `safe` is the default.
73
+
74
+ To enable full local access:
109
75
 
110
76
  ```json
111
77
  {
112
- "mcpServers": {
113
- "localwp": {
114
- "command": "node",
115
- "args": [
116
- "/Users/your-user/Projects/MCP-Servers/localwp-mcp/dist/index.js"
117
- ],
118
- "env": {
119
- "LOCAL_SITE_NAME": "plovercrm",
120
- "LOCALWP_MCP_PROFILE": "full-access"
121
- }
122
- }
123
- }
78
+ "LOCALWP_MCP_PROFILE": "full-access"
124
79
  }
125
80
  ```
126
81
 
127
- ## Recommended First Command
82
+ ## First Things To Try
83
+
84
+ Start with:
85
+
86
+ - `local_environment_check`
87
+ - `local_doctor`
88
+ - `list_local_sites`
89
+
90
+ Those will tell you:
128
91
 
129
- Run `local_environment_check` or `local_doctor` first on any machine. They show:
92
+ - which Local sites were discovered
93
+ - whether the site is running
94
+ - which Local runtimes were resolved
95
+ - whether WP-CLI and MySQL are reachable
130
96
 
131
- - resolved Local metadata paths
132
- - resolved Local app-resource paths
133
- - WP-CLI/tooling resolution
134
- - optional WP-CLI and MySQL probes for a selected site
135
- - log availability and practical next steps
97
+ ## Common Workflows
136
98
 
137
- That makes support and cross-platform debugging much easier.
99
+ ### Inspect a Site
138
100
 
139
- ## Backups and Database Transfers
101
+ Use:
102
+
103
+ - `local_site_info`
104
+ - `local_doctor`
105
+ - `local_logs`
106
+
107
+ ### Work With WordPress
108
+
109
+ Use:
110
+
111
+ - `execute_wp_cli`
112
+
113
+ Examples:
114
+
115
+ - list plugins
116
+ - inspect options
117
+ - list posts or users
118
+ - run plugin-specific WP-CLI commands
119
+
120
+ ### Work With the Database
121
+
122
+ Use:
123
+
124
+ - `mysql_query`
125
+ Read-only SQL in `safe`
126
+ - `mysql_execute`
127
+ Full SQL execution in `full-access`
128
+ - `mysql_schema`
129
+ Table listing and table description helpers
130
+
131
+ ### Back Up or Restore a Site
132
+
133
+ Use:
140
134
 
141
135
  - `backup_site`
142
- Creates a backup folder for the selected site.
143
- - `backup_site` with `scope=database`
144
- Creates a timestamped backup folder with a fresh SQL dump.
145
- - `backup_site` with `scope=full`
146
- Copies the site's `app`, `conf`, and `logs` directories and writes a fresh SQL dump into `app/sql`.
147
136
  - `db_export`
148
- Writes a SQL file directly. Good when you only want the database.
149
137
  - `db_import`
150
- Imports either a `.sql` file or a `backup_site` directory. Requires `full-access`.
151
138
  - `restore_backup`
152
- Restores from a `.sql` file or a `backup_site` directory. In `full-access`, it can also restore `app`, `conf`, and `logs` from a full backup.
153
139
 
154
- The full backup is intentionally folder-based instead of shelling out to platform-specific `zip` or `tar` commands. That keeps the MCP predictable across macOS, Windows, and Linux, and it stays close to Local's own site-folder restore shape.
140
+ `backup_site` supports:
141
+
142
+ - `database`
143
+ - `full`
144
+
145
+ The `full` backup format is folder-based and includes the site's `app`, `conf`, and `logs` directories plus a fresh SQL dump.
146
+
147
+ ## Built-In Capabilities
148
+
149
+ ### Tools
150
+
151
+ - `list_local_sites`
152
+ - `local_environment_check`
153
+ - `local_doctor`
154
+ - `local_logs`
155
+ - `local_site_info`
156
+ - `execute_wp_cli`
157
+ - `mysql_query`
158
+ - `mysql_execute`
159
+ - `mysql_schema`
160
+ - `db_export`
161
+ - `db_import`
162
+ - `backup_site`
163
+ - `restore_backup`
164
+
165
+ ### MCP Resources
155
166
 
156
- ## Resources and Prompts
167
+ - `localwp://sites`
168
+ - `localwp://sites/{siteName}/summary`
169
+ - `localwp://sites/{siteName}/doctor`
170
+ - `localwp://sites/{siteName}/logs`
157
171
 
158
- This MCP now also exposes lightweight resources and prompts:
172
+ ### MCP Prompts
159
173
 
160
- - Resource: `localwp://sites`
161
- JSON catalog of discovered Local sites.
162
- - Resource template: `localwp://sites/{siteName}/summary`
163
- Per-site Local resolution summary.
164
- - Resource template: `localwp://sites/{siteName}/doctor`
165
- Per-site doctor output.
166
- - Resource template: `localwp://sites/{siteName}/logs`
167
- Per-site recent logs.
168
- - Prompt: `diagnose_local_site`
169
- Helps an agent diagnose a LocalWP site with the MCP tools.
170
- - Prompt: `restore_local_site`
171
- Helps an agent restore a site from a SQL dump or backup directory.
174
+ - `diagnose_local_site`
175
+ - `restore_local_site`
172
176
 
173
- ## Platform Compatibility
177
+ ## Platform Support
174
178
 
175
- - `macOS`
176
- Uses Local metadata under `~/Library/Application Support/Local` and the standard Local app bundle resources.
177
- - `Windows`
178
- Uses Local metadata under `%APPDATA%\\Local` and searches both per-user and `Program Files` installs for Local resources.
179
- - `Linux`
180
- Uses Local metadata under `~/.config/Local` and the common `/opt/Local/resources/extraResources` install path.
179
+ `localwp-mcp` is designed for:
181
180
 
182
- The resolver supports both current `lightning-services` layouts and older `site-binaries` layouts.
181
+ - macOS
182
+ - Windows
183
+ - Linux
183
184
 
184
- ## Configuration
185
+ It supports both current Local `lightning-services` layouts and older `site-binaries` layouts.
185
186
 
186
- Optional environment variables:
187
+ ## Useful Environment Variables
188
+
189
+ Most users only need these:
187
190
 
188
191
  - `LOCALWP_MCP_PROFILE`
189
- `safe` or `full-access`
190
- - `LOCALWP_MCP_BACKUPS_DIR`
191
- Optional shared backup directory. If omitted, backups are written under each Local site's `localwp-mcp-backups` folder.
192
192
  - `LOCAL_SITE_NAME`
193
193
  - `LOCAL_SITE_ID`
194
- - `LOCAL_APP_SUPPORT_DIR`
195
- - `LOCAL_EXTRA_RESOURCES_DIRS`
196
- - `LOCAL_RUN_DIR`
197
- - `LOCAL_LIGHTNING_SERVICES_DIR`
198
- - `LOCAL_LIGHTNING_SERVICES_DIRS`
199
- - `LOCAL_SITES_JSON`
200
- - `LOCAL_SITE_STATUSES_JSON`
201
- - `LOCAL_WP_CLI_PHAR`
202
- - `LOCAL_WP_CLI_CONFIG`
203
- - `LOCAL_HELPER_BIN_DIRS`
204
- - `LOCAL_MYSQL_HOST`
194
+ - `LOCALWP_MCP_BACKUPS_DIR`
195
+
196
+ Advanced override variables also exist for custom Local layouts, but most installations do not need them.
197
+
198
+ ## Troubleshooting
205
199
 
206
- ## Why It Stays Simple
200
+ If the MCP does not find your site or cannot run WP-CLI/MySQL:
207
201
 
208
- - plain TypeScript
209
- - `pnpm`
210
- - `tsc`
211
- - stdio transport
202
+ 1. Start the site in Local.
203
+ 2. Run `local_environment_check`.
204
+ 3. Run `local_doctor`.
205
+ 4. Check `local_logs`.
212
206
 
213
- There is no bundler here because this is a Node MCP server and the simpler build is easier to debug and maintain.
207
+ Those tools are the fastest way to see whether the problem is:
214
208
 
215
- ## Development
209
+ - site selection
210
+ - Local metadata resolution
211
+ - WP-CLI resolution
212
+ - MySQL connectivity
213
+ - missing or stopped Local services
214
+
215
+ ## From Source
216
+
217
+ If you are running from a local clone instead of npm:
216
218
 
217
219
  ```bash
218
220
  pnpm install
219
- pnpm check
220
- pnpm test
221
221
  pnpm build
222
- node dist/index.js
223
222
  ```
224
223
 
225
- For contribution and release workflows, see:
224
+ Then point your MCP client at:
225
+
226
+ ```json
227
+ {
228
+ "mcpServers": {
229
+ "localwp": {
230
+ "command": "node",
231
+ "args": ["/path/to/localwp-mcp/dist/index.js"]
232
+ }
233
+ }
234
+ }
235
+ ```
236
+
237
+ ## For Contributors
238
+
239
+ Contributor and maintainer docs live outside the main user guide:
226
240
 
227
241
  - [CONTRIBUTING.md](./CONTRIBUTING.md)
228
242
  - [SECURITY.md](./SECURITY.md)
229
- - [docs/RELEASE_CHECKLIST.md](./docs/RELEASE_CHECKLIST.md)
243
+ - [Maintainer Docs](./docs/maintainers/README.md)
package/dist/prompts.js CHANGED
@@ -7,7 +7,7 @@ export function registerPrompts(server) {
7
7
  siteName: z
8
8
  .string()
9
9
  .optional()
10
- .describe("Optional Local site name, for example 'woo'."),
10
+ .describe("Optional Local site name, for example 'example-site'."),
11
11
  },
12
12
  }, async ({ siteName }) => {
13
13
  const target = siteName
@@ -36,7 +36,7 @@ export function registerPrompts(server) {
36
36
  argsSchema: {
37
37
  siteName: z
38
38
  .string()
39
- .describe("Local site name to restore, for example 'woo'."),
39
+ .describe("Local site name to restore, for example 'example-site'."),
40
40
  sourcePath: z
41
41
  .string()
42
42
  .describe("Path to the .sql file or backup_site directory to restore."),
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CA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C,4DAA4D,CAAC;SAC1E;KACF,EACD,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;QACjC,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;4BACJ,2BAA2B,QAAQ,WAAW,UAAU,IAAI;4BAC5D,gFAAgF;4BAChF,4DAA4D;4BAC5D,6GAA6G;4BAC7G,+FAA+F;yBAChG,CAAC,IAAI,CAAC,GAAG,CAAC;qBACZ;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -7,7 +7,7 @@ export const siteSelectorSchema = {
7
7
  siteName: z
8
8
  .string()
9
9
  .optional()
10
- .describe("Optional Local site name, for example 'plovercrm'."),
10
+ .describe("Optional Local site name, for example 'example-site'."),
11
11
  };
12
12
  export const logScopeSchema = z
13
13
  .enum(["site", "global", "all"])
@@ -1 +1 @@
1
- {"version":3,"file":"tool-schemas.js","sourceRoot":"","sources":["../src/tool-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,kDAAkD,CAAC;IAC/D,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,oDAAoD,CAAC;CAClE,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;KAC/B,QAAQ,EAAE;KACV,QAAQ,CACP,0EAA0E,CAC3E,CAAC;AAEJ,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,IAAI,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;KAC1B,QAAQ,EAAE;KACV,QAAQ,CACP,6GAA6G,CAC9G,CAAC"}
1
+ {"version":3,"file":"tool-schemas.js","sourceRoot":"","sources":["../src/tool-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,kDAAkD,CAAC;IAC/D,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,uDAAuD,CAAC;CACrE,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;KAC/B,QAAQ,EAAE;KACV,QAAQ,CACP,0EAA0E,CAC3E,CAAC;AAEJ,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,IAAI,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;KAC1B,QAAQ,EAAE;KACV,QAAQ,CACP,6GAA6G,CAC9G,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "localwp-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A LocalWP-aware MCP server for WordPress developers with simple safe and full-access profiles, logs, doctor diagnostics, SQL access, backups, restore flows, MCP resources/prompts, and site-aware WP-CLI.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.32.1",