How aashari/mcp-server-aws-sso works
Project Type and Purpose
• This is a Node.js/TypeScript CLI/MCP‐server library (package name @aashari/mcp-server-aws-sso) that implements the Model Context Protocol (MCP) over a command-based interface.
• Purpose: Expose AWS SSO flows (login, status, list accounts, execute CLI/EC2 commands) as MCP “tools” so that LLM-powered clients can securely authenticate and interact with AWS resources.
File Structure
Top‐level:
• src/cli – CLI entrypoints and argument parsing
• src/controllers – Controllers translate CLI/MCP requests into service calls and format responses
• src/services – Business logic for AWS SSO device flow, account listing, AWS CLI exec, EC2 SSM exec
• src/tools – MCP tool definitions (mapping MCP tool names to controller methods)
• src/utils – Cross-cutting concerns: caching, config, logging, error handling, retry, transport (stdin/stdout)
• tests are collocated with controllers, services, CLI under .test.ts files
Config and Packaging:
• package.json, scripts/, .github/workflows – CI, release, linting
• .npmrc, .prettierrc, eslint.config.mjs – style & publishing rules
README for Additional Insights
• Describes the four MCP tools (aws_sso_login, aws_sso_status, aws_sso_ls_accounts, aws_sso_exec_command, aws_sso_ec2_exec_command) and corresponding CLI commands (login, status, ls-accounts, exec-command, ec2-exec-command).
• Explains AWS SSO device flow, temporary credential rotation, and tool usage patterns.
a. Main Components
1. CLI/MCP Interface
• CLI Parsers (src/cli/index.ts & individual .cli.ts files)
• MCP Transport (stdin/stdout)
2. Controller Layer (src/controllers)
• Receives parsed commands or MCP payloads, orchestrates services, and applies formatters
3. Service Layer (src/services)
• AWS SSO Auth Core (device flow / polling)
• AWS SSO Accounts Service (list accounts & roles)
• AWS SSO Exec Service (invoke AWS CLI subprocess)
• AWS SSO EC2 Service (SSM shell exec via AWS SDK)
4. Tool Definitions (src/tools)
• Maps MCP tool names and parameter schemas to controller invocations
5. Utility Modules (src/utils)
• Config loader, caching, logging, error handling, retry, transport
6. External Systems
• AWS SSO Device Authorization API
• AWS IAM Identity Center (accounts & roles)
• AWS Cloud (EC2, SSM)
• AWS CLI subprocess (shell out)
b. Component Relationships and Data Flow
• User invokes mcp-aws-sso <command> or LLM client writes MCP JSON →
CLI Parser reads args/JSON → Controller → Service → AWS API/CLI → Service
→ Controller applies formatter → Transport (stdout/JSON) back to user.
• Controllers depend on Services and Formatter utilities.
• Services depend on Utility modules (caching, HTTP, retry).
• Tools layer injects controller methods into the MCP server registry.
c. Architectural Patterns
• Layered (CLI → Controller → Service → External)
• Dependency Injection via import boundaries
• Single Responsibility: controllers orchestrate, services implement logic, utils cross-cut
• Adapter pattern: AWS SDK & CLI calls are wrapped by service interfaces
• Plugin/Registry: tools register themselves under MCP server’s handlers
d. Key Technologies
• Node.js, TypeScript
• AWS SDK v3 (SSO, SSM) & AWS CLI subprocess
• Commander (or custom parser) for CLI
• Model Context Protocol over STDIN/STDOUT
• Jest/Mocha for tests