mysql_current_site
Retrieve details about the currently connected Local WordPress site, including its selection method. Use this to confirm the active site for development and analysis.
Instructions
Get information about the currently connected Local WordPress site, including how it was selected
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:220-259 (handler)Handler for the mysql_current_site tool. Returns information about the currently connected Local WordPress site, including site name, ID, path, domain, selection method, socket path, and port.
case 'mysql_current_site': { if (!currentSiteSelection) { return { content: [ { type: 'text', text: JSON.stringify( { error: 'No site selection information available', note: 'Using environment variables or default configuration', }, null, 2 ), }, ], }; } return { content: [ { type: 'text', text: JSON.stringify( { siteName: currentSiteSelection.siteName, siteId: currentSiteSelection.siteInfo.siteId, sitePath: currentSiteSelection.sitePath, domain: currentSiteSelection.domain, selectionMethod: currentSiteSelection.selectionMethod, socketPath: currentSiteSelection.siteInfo.socketPath, port: currentSiteSelection.siteInfo.port, }, null, 2 ), }, ], }; } - src/index.ts:114-122 (schema)Schema definition for mysql_current_site tool. No input parameters required.
{ name: 'mysql_current_site', description: 'Get information about the currently connected Local WordPress site, including how it was selected', inputSchema: { type: 'object', properties: {}, }, }, - src/index.ts:157-161 (registration)Registration of tools includes mysql_current_site via the ListToolsRequestSchema handler that returns the tools array.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools, }; }); - src/index.ts:27-28 (helper)Module-level state variable that stores the current site selection, populated at startup by getLocalMySQLConfig and used by the mysql_current_site handler.
// Store site selection for the mysql_current_site tool let currentSiteSelection: SiteSelectionResult | undefined; - src/local-detector.ts:439-466 (helper)This function performs site selection (via selectSite()) and returns the connection config with an embedded _siteSelection property. The _siteSelection is extracted at startup in index.ts and stored in currentSiteSelection for use by the mysql_current_site tool handler.
export function getLocalMySQLConfig(database?: string): { host?: string; port?: number; user: string; password: string; database?: string; socketPath?: string; multipleStatements?: boolean; timezone?: string; _siteSelection?: SiteSelectionResult; } { const selection = selectSite(); debugLog(`Selected site: ${selection.siteName} via ${selection.selectionMethod}`); debugLog(` Path: ${selection.sitePath}`); debugLog(` Domain: ${selection.domain}`); debugLog(` Socket: ${selection.siteInfo.socketPath}`); return { socketPath: selection.siteInfo.socketPath, user: 'root', password: 'root', database: database || 'local', multipleStatements: false, timezone: 'Z', _siteSelection: selection, }; }