Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Built for WordPress agencies and site managers who want AI assistance with their

## Quick Start

> **Pre-Release Notice:** This MCP server requires the MainWP Abilities API, which is currently in development. Until the pull request is merged, you'll need to use the `initial-abilities-api-intergration` branch of MainWP Dashboard:
> **Pre-Release Notice:** This MCP server requires the MainWP Abilities API, which is currently in development. Until the pull request is merged, you'll need to use the `initial-issues-abilities-api` branch of MainWP Dashboard (PR2):
>
> ```bash
> cd /path/to/your/mainwp-dashboard
> git fetch origin
> git checkout initial-abilities-api-intergration
> git checkout initial-issues-abilities-api
> ```
>
> Once the PR is merged, you can switch back to the main branch.
Expand Down Expand Up @@ -408,6 +408,14 @@ For Windsurf and other hosts, see the [Installation Guide](docs/installation.md)
| `MAINWP_RETRY_BASE_DELAY` | No | `1000` | Base delay between retries in milliseconds |
| `MAINWP_RETRY_MAX_DELAY` | No | `2000` | Maximum delay between retries in milliseconds |

> **⚠️ Security Warning: SSL Verification**
>
> Setting `MAINWP_SKIP_SSL_VERIFY=true` disables SSL certificate verification, making your connection vulnerable to man-in-the-middle (MITM) attacks.
>
> **Only use for:** Local development with self-signed certificates or isolated test environments.
>
> **Never use in production** or on untrusted networks.

For the complete list of variables and configuration file options, see the [Configuration Guide](docs/configuration.md).

### Configuration File
Expand Down
930 changes: 284 additions & 646 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mainwp-mcp",
"version": "1.0.0-alpha.14",
"version": "1.0.0-alpha.15",
"description": "MCP Server for MainWP Dashboard - Exposes MainWP Abilities API as MCP tools",
"type": "module",
"main": "dist/index.js",
Expand Down Expand Up @@ -41,14 +41,14 @@
"devDependencies": {
"@eslint/js": "^9.39.2",
"@types/node": "^20.10.0",
"@vitest/coverage-v8": "^2.1.0",
"@vitest/coverage-v8": "^3.2.4",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"prettier": "^3.7.4",
"tsx": "^4.6.0",
"typescript": "^5.3.0",
"typescript-eslint": "^8.50.0",
"vitest": "^2.1.0"
"vitest": "^3.2.4"
},
"engines": {
"node": ">=18.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/abilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('executeAbility', () => {
expect(calls[1][1].method).toBe('GET');
});

it('should use POST for non-readonly abilities', async () => {
it('should use DELETE for destructive abilities', async () => {
mockFetch.mockResolvedValueOnce({
ok: true,
json: async () => sampleAbilities,
Expand All @@ -334,7 +334,7 @@ describe('executeAbility', () => {
await executeAbility(baseConfig, 'mainwp/delete-site-v1', { site_id: 1, confirm: true });

const calls = mockFetch.mock.calls;
expect(calls[1][1].method).toBe('POST');
expect(calls[1][1].method).toBe('DELETE');
});

it('should throw when ability not found', async () => {
Expand Down
9 changes: 8 additions & 1 deletion src/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ export async function executeAbility(
}

const isReadonly = ability.meta?.annotations?.readonly ?? false;
const isDestructive = ability.meta?.annotations?.destructive ?? false;
const url = `${baseUrl}/abilities/${abilityName}/run`;
const hasInput = input && Object.keys(input).length > 0;

Expand All @@ -366,8 +367,14 @@ export async function executeAbility(
// GET request for read-only abilities, with optional params as query string
const queryString = hasInput ? serializeToPhpQueryString(input) : '';
response = await customFetch(url + queryString, { method: 'GET' });
} else if (isDestructive) {
// DELETE request for destructive abilities (Dashboard requires DELETE method)
response = await customFetch(url, {
method: 'DELETE',
body: JSON.stringify({ input: input ?? {} }),
});
} else {
// POST request for non-readonly abilities
// POST request for non-destructive write operations
response = await customFetch(url, {
method: 'POST',
body: JSON.stringify({ input: input ?? {} }),
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { formatErrorResponse, McpErrorFactory, McpError } from './errors.js';

// Server metadata
const SERVER_NAME = 'mainwp-mcp';
const SERVER_VERSION = '1.0.0-alpha.14';
const SERVER_VERSION = '1.0.0-alpha.15';

// Completion limits
const MAX_COMPLETION_SUGGESTIONS = 20;
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/abilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('Abilities Integration', () => {
expect(execCall[1].method).toBe('GET');
});

it('should execute destructive ability with POST', async () => {
it('should execute destructive ability with DELETE', async () => {
mockFetch.mockResolvedValueOnce({
ok: true,
json: async () => abilitiesFixture,
Expand All @@ -227,9 +227,9 @@ describe('Abilities Integration', () => {

expect(result).toEqual({ success: true, deleted: true });

// Verify POST was used
// Verify DELETE was used for destructive abilities
const execCall = mockFetch.mock.calls[1];
expect(execCall[1].method).toBe('POST');
expect(execCall[1].method).toBe('DELETE');
});

it('should handle execution errors', async () => {
Expand Down