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
| Name | Required | Description | Default |
|---|---|---|---|
| environmentId | Yes | Environment 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 };
- src/tools/environment/tools.ts:165-171 (registration)Registers setDefaultEnvironmentTool in the environmentTools array, which is exported and included in main ALL_TOOLS.export const environmentTools = [ listEnvironmentsTool, getEnvironmentDetailsTool, createEnvironmentTool, updateEnvironmentVariablesTool, setDefaultEnvironmentTool, deleteEnvironmentTool
- src/tools/index.ts:101-104 (registration)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); },
- src/tools/index.ts:30-33 (registration)Main tool registry including environmentTools (which contains setDefaultEnvironmentTool) in ALL_TOOLS.export const ALL_TOOLS: McpTool[] = [ ...CORE_TOOLS, ...AUTH_TOOLS, ...environmentTools,