Skip to main content
Glama
JaxonDigital

Optimizely DXP MCP Server

by JaxonDigital

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;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: it's a read-only operation (implied by 'Show'), returns specific data (name, ID, environment access), has performance characteristics ('INSTANT: <1s'), and has no side effects. However, it doesn't mention error cases or authentication requirements, leaving minor gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and well-structured: it starts with the core purpose, includes performance and return details, provides usage guidance, and ends with parameter infoβ€”all in four efficient sentences with no redundant information. Every sentence adds value, making it front-loaded and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (0 parameters, no output schema, no annotations), the description is nearly complete: it covers purpose, usage, behavior, and returns. However, without an output schema, it could benefit from more detail on the return format (e.g., structure of 'active project info'), though the listed fields (name, ID, environment access) mitigate this. It's adequate but has a minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so the baseline is 4. The description reinforces this by explicitly stating 'No parameters', which adds clarity and prevents confusion. No additional parameter details are needed, making this sufficient.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Show currently active project context') and resource ('project'), distinguishing it from siblings like 'get_project' or 'list_projects' by focusing on the active/current context rather than general project retrieval. It explicitly defines what information is returned (name, ID, environment access), making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool ('Use to confirm project context before critical operations'), which directly informs the agent about its role in workflows. It distinguishes it from alternatives by emphasizing the 'active' context, and the 'No parameters' note helps avoid misuse. This is comprehensive usage guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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