~/.cursor/mcp.json (or .cursor/mcp.json in a project):' ),
'code' => $json(
array(
'mcpServers' => array(
'wordpress' => array(
'url' => $url,
'headers' => $headers,
),
),
)
),
),
'vscode' => array(
'label' => 'VS Code',
'kind' => 'Copilot · config file',
'icon' => 'visualstudiocode',
'steps' => array( 'Add this to .vscode/mcp.json in your workspace:' ),
'code' => $json(
array(
'servers' => array(
'wordpress' => array(
'type' => 'http',
'url' => $url,
'headers' => $headers,
),
),
)
),
),
'gemini' => array(
'label' => 'Gemini CLI',
'kind' => 'Config file',
'icon' => 'googlegemini',
'steps' => array( 'Add this to ~/.gemini/settings.json:' ),
'code' => $json(
array(
'mcpServers' => array(
'wordpress' => array(
'httpUrl' => $url,
'headers' => $headers,
),
),
)
),
),
'windsurf' => array(
'label' => 'Windsurf',
'kind' => 'Config file',
'icon' => 'windsurf',
'steps' => array( 'Add this to ~/.codeium/windsurf/mcp_config.json:' ),
'code' => $json(
array(
'mcpServers' => array(
'wordpress' => array(
'serverUrl' => $url,
'headers' => $headers,
),
),
)
),
),
'other' => array(
'label' => 'Other',
'kind' => 'Any MCP client · test',
'icon' => 'modelcontextprotocol',
'steps' => array(
'Any MCP client that supports the Streamable HTTP transport works. Send the key as Authorization: Bearer <key> or X-API-Key: <key>. Test the connection with:',
),
'code' => sprintf(
"curl -s %s \\\n -H \"Content-Type: application/json\" \\\n -H \"Accept: application/json, text/event-stream\" \\\n -H \"X-API-Key: %s\" \\\n -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}'",
$url,
$key
),
),
);
// Setup prompts: a chat message the user pastes into an AI app that can run commands or
// edit files, so the agent connects itself. Not possible for Claude web/desktop or ChatGPT,
// whose connectors can only be added in their settings screens.
$verify = 'Once the server is loaded (after any restart or refresh), list the tools the "wordpress" server provides and call wp_site_info to confirm which WordPress site you are connected to.';
// Node-based clients give each address only 250 ms to connect when a host has both IPv4 and
// IPv6 records, so an unreachable IPv6 plus a slow IPv4 handshake fails as "fetch failed: AggregateError".
$host = wp_parse_url( $url, PHP_URL_HOST );
$verify .= "\n\nIf the connection fails with \"fetch failed\", \"AggregateError\", \"ETIMEDOUT\" or \"ENETUNREACH\" even though the URL opens in a browser, the cause is usually on my computer, not the site: "
. $host . " has an IPv6 address my network cannot reach, and the IPv4 connection takes longer than the 250 ms that Node.js gives each address. Fix it like this:\n"
. '1. Look up the IPv4 address of ' . $host . " (for example with nslookup, dig or ping -4).\n"
. "2. Check the diagnosis: a plain Node.js fetch() of the server URL fails, but the same request run with NODE_OPTIONS=--network-family-autoselection-attempt-timeout=2000 gets an HTTP response.\n"
. '3. Ask me to add the line "