Skip to main content
Glama

current_project

Confirm active Optimizely DXP project context before critical operations by displaying name, ID, and environment access details.

Instructions

📌 Show currently active project context. INSTANT: <1s. Returns name, ID, and environment access for the project currently in use. Use to confirm project context before critical operations. No parameters. Returns active project info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that executes the logic for the current_project tool. It checks for last used project via env var, falls back to ProjectTools.getCurrentProject(), handles errors gracefully, and returns structured data with a formatted message about the current project.
    static async handleGetCurrentProject(_args: any = {}): Promise<any> { try { // DXP-36: Improved error handling for getting current project let currentProject: any = null; // Check for last used project first const lastUsed = process.env.MCP_LAST_USED_PROJECT; if (lastUsed) { try { const result = ProjectTools.switchProject(lastUsed); if (result.success) { currentProject = result.project; } } catch (lastUsedError: any) { // Last used project might be corrupted, continue to fallback if (process.env.DEBUG) { console.error('Error accessing last used project:', lastUsedError.message); } } } // Fall back to default project if (!currentProject) { try { currentProject = ProjectTools.getCurrentProject(); } catch (getCurrentError: any) { return ResponseBuilder.error( '❌ **Configuration Error**\n\n' + 'Unable to determine current project due to configuration issues.\n\n' + `**Error details**: ${getCurrentError.message}\n\n` + '💡 **Next steps**:\n' + '1. Check your project configuration\n' + '2. Use `list_projects` to see available projects\n' + '3. Use `switch_project` to select a valid project', { error: 'Configuration error', details: getCurrentError.message } ); } } if (!currentProject) { // DXP-36: More helpful message when no project is active let projects; try { projects = ProjectTools.getConfiguredProjects(); } catch (configError: any) { return ResponseBuilder.error( '❌ **No Active Project & Configuration Error**\n\n' + 'No project is currently active and there are configuration issues.\n\n' + `**Configuration error**: ${configError.message}\n\n` + '💡 **Next steps**:\n' + '1. Fix your project configuration\n' + '2. Add a valid project environment variable\n' + '3. Refer to setup documentation', { error: 'No active project and config error', details: configError.message } ); } const projectNames = projects.map((p: any) => p.name).filter(Boolean); if (projectNames.length === 0) { return ResponseBuilder.error( '❌ **No Projects Configured**\n\n' + 'No projects are configured in your environment.\n\n' + '💡 **To configure a project**, add an environment variable like:\n' + '```\n' + 'MYPROJECT="id=your-project-id;key=your-api-key;secret=your-secret"\n' + '```\n\n' + 'Then use `switch_project MYPROJECT` to activate it.', { error: 'No projects configured', availableProjects: [] } ); } else { return ResponseBuilder.error( `❌ **No Active Project**\n\n` + `${projectNames.length} project(s) are configured but none is currently active.\n\n` + `**Available projects**:\n${projectNames.map((n: string) => ` • ${n}`).join('\n')}\n\n` + `💡 Use \`switch_project <name>\` to activate a project.`, { error: 'No active project', availableProjects: projectNames } ); } } return ResponseBuilder.successWithStructuredData( { projectName: currentProject.name, projectId: currentProject.projectId, isDefault: currentProject.isDefault || false, source: lastUsed === currentProject.name ? 'last_used' : 'default' }, `📌 **Current Project: ${currentProject.name}**\n\n` + `• Project ID: ${currentProject.projectId}\n` + `• Environments: ${currentProject.environments.join(', ')}\n` + `${currentProject.isDefault ? '• Default: Yes ⭐\n' : ''}\n` + `${lastUsed === currentProject.name ? '• Source: Last used project\n' : ''}\n` + `💡 Use \`switch_project\` to change projects` ); } catch (unexpectedError: any) { // DXP-36: Handle any unexpected errors return ResponseBuilder.error( '❌ **Unexpected Error**\n\n' + 'An unexpected error occurred while getting the current project.\n\n' + `**Error details**: ${unexpectedError.message}\n\n` + '💡 **Troubleshooting**:\n' + '1. Check your project configuration\n' + '2. Try restarting the MCP server\n' + '3. Contact support if the issue persists', { error: 'Unexpected error', details: unexpectedError.message } ); } }
  • Core helper method getCurrentProject() used by the tool handler. Retrieves configured projects, prioritizes projectId if given, then last used from env, then first project as default.
    static getCurrentProject(projectId: string | null = null): ProjectConfig | null { const projects = this.getConfiguredProjects(); // If projectId specified, find that project if (projectId) { const project = projects.find(p => p.projectId === projectId || p.name === projectId); if (project) return project; } // Check for last used project from switch_project const lastUsed = process.env.MCP_LAST_USED_PROJECT; if (lastUsed) { const project = projects.find(p => p.name === lastUsed || p.name.toLowerCase() === lastUsed.toLowerCase() ); if (project) return project; } // Return first project as default return projects[0] || null; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JaxonDigital/optimizely-dxp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server