Skip to main content
Glama

set_default_environment

Set a specific environment as the default for your project to ensure consistent API testing and development workflows across your team.

Instructions

Set an environment as the default for the project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentIdYesEnvironment ID to set as default

Implementation Reference

  • Core implementation of the set_default_environment tool. Validates environmentId, initializes BackendClient and EnvironmentService, calls setDefaultEnvironment on the service, and returns formatted MCPToolResponse.
    export async function handleSetDefaultEnvironment(args: any): Promise<McpToolResponse> { try { const { environmentId } = args; if (!environmentId) { return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: 'Environment ID is required' }, null, 2) } ] }; } const instances = await getInstances(); // Create environment service const envService = new EnvironmentService( instances.backendClient.getBaseUrl(), instances.backendClient.getToken() ); // Set as default const success = await envService.setDefaultEnvironment(environmentId); if (!success) { return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: 'Failed to set environment as default' }, null, 2) } ] }; } return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: 'Environment set as default successfully', data: { environmentId, setAt: new Date().toISOString() } }, null, 2) } ] }; } catch (error: any) { return { content: [ { type: 'text', text: JSON.stringify({ success: false, error: error.message || 'Unknown error occurred while setting default environment' }, null, 2) } ] }; } }
  • MCP tool definition including name, description, input schema (requiring environmentId string), and reference to handler.
    export const setDefaultEnvironmentTool: McpTool = { name: 'set_default_environment', description: 'Set an environment as the default for the project', inputSchema: { type: 'object', properties: { environmentId: { type: 'string', description: 'Environment ID to set as default' } }, required: ['environmentId'] }, handler: handleSetDefaultEnvironment };
  • Registers setDefaultEnvironmentTool in the environmentTools array, which is exported and included in main ALL_TOOLS.
    export const environmentTools = [ listEnvironmentsTool, getEnvironmentDetailsTool, createEnvironmentTool, updateEnvironmentVariablesTool, setDefaultEnvironmentTool, deleteEnvironmentTool
  • Dynamic handler registration in main tools index, importing and delegating to the core handler function.
    'set_default_environment': async (args: any) => { const { handleSetDefaultEnvironment } = await import('./environment/handlers/updateHandler.js'); return handleSetDefaultEnvironment(args); },
  • Main tool registry including environmentTools (which contains setDefaultEnvironmentTool) in ALL_TOOLS.
    export const ALL_TOOLS: McpTool[] = [ ...CORE_TOOLS, ...AUTH_TOOLS, ...environmentTools,

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/martin-1103/mcp2'

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