This directory contains scripts and utilities for integrating the MCP SysOperator server with LocalStack, allowing you to test AWS operations locally without real AWS credentials.
LocalStack is a cloud service emulator that runs in a single container on your laptop or in your CI environment. It allows you to run AWS applications or Lambda functions without connecting to a remote AWS cloud.
This integration enables you to:
- Test IaC that use AWS services locally
- Develop and test AWS operations without incurring AWS costs
- Run tests without requiring real AWS credentials
- Validate your infrastructure code before deploying to real AWS
- Node.js 18 or higher
- npm or yarn
- Ansible installed and in PATH
- LocalStack installed and running
- awslocal CLI installed
# Install LocalStack
pip install localstack
# Install awslocal CLI
pip install awscli-local
# Start LocalStack
localstack start- localstack_test.mjs: Basic test script for running Ansible playbooks with LocalStack
- localstack_aws_operations.mjs: Utility library for AWS operations using LocalStack
- test_mcp_with_localstack.mjs: Comprehensive test script for MCP Ansible server with LocalStack
- mcp_localstack_patch.js: Documentation for modifying the MCP Ansible server to use LocalStack
# Run the basic test script
node localstack/localstack_test.mjs
# Run the AWS operations utility
node localstack/localstack_aws_operations.mjs
# Run the comprehensive test script
node localstack/test_mcp_with_localstack.mjsTo modify the MCP Ansible server to use LocalStack instead of real AWS:
-
Edit
src/ansible-mcp-server/common/utils.ts:- Replace
aws --versionwithawslocal --versionincheckAwsCliInstalled() - Replace
aws sts get-caller-identitywithawslocal sts get-caller-identityincheckAwsCredentials()
- Replace
-
Rebuild the server:
npm run build
When creating Ansible playbooks for LocalStack, use shell commands with awslocal instead of AWS modules:
- name: List S3 buckets
shell: awslocal s3 ls
register: s3_buckets
- name: Display buckets
debug:
var: s3_buckets.stdout_linesThe following AWS services have been tested with this integration:
- S3: Create buckets, upload files, list objects
- CloudFormation: Create stacks, deploy templates
- EC2: List instances (creating instances requires AMI setup in LocalStack)
For a complete integration of the MCP SysOperator server with LocalStack:
- Create a fork of the MCP SysOperator server repository
- Modify the utils.ts file to use awslocal instead of aws
- Modify the aws.ts file to use shell commands with awslocal instead of AWS modules
- Add a flag or environment variable to toggle between real AWS and LocalStack
- Rebuild the server and test with LocalStack
This approach allows you to use the MCP SysOperator server with LocalStack for testing without affecting the ability to use it with real AWS when needed.