@aashari/mcp-server-aws-sso
Version:
Node.js/TypeScript MCP server for AWS Single Sign-On (SSO). Enables AI systems (LLMs) with tools to initiate SSO login (device auth flow), list accounts/roles, and securely execute AWS CLI commands using temporary credentials. Streamlines AI interaction w
32 lines (31 loc) • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultAwsRegion = getDefaultAwsRegion;
const child_process_1 = require("child_process");
/**
* Gets the default AWS region from environment variables or AWS CLI configuration
* @returns The AWS region string
*/
function getDefaultAwsRegion() {
// First check environment variables (AWS SDKs check these first)
const envRegion = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION;
if (envRegion) {
return envRegion;
}
// If environment variables aren't set, try to get from AWS CLI config
try {
// Use the working AWS CLI binary path to avoid "cannot execute binary file" errors
const cliRegion = (0, child_process_1.execSync)('/usr/local/aws-cli/aws configure get region', {
encoding: 'utf8',
}).trim();
if (cliRegion) {
return cliRegion;
}
}
catch {
// Silently continue to fallback - this is expected in many environments
// where AWS CLI isn't configured or the binary path is different
}
// Fallback to a default region
return 'ap-southeast-1';
}