Copied to Clipboard
Gemini CLI settings.json
The default Gemini CLI settings.json has an entry for the Python source:
{"mcpServers":{"aws-https-python":{"httpUrl":"http://127.0.0.1:8080/mcp"}}}
Validation with Gemini CLI
Leave the HTTP server running and open a new terminal.
Gemini CLI is restarted and the MCP connection over HTTP to the Python Code is validated. The full Gemini CLI Session will start:
admin@ip-172-31-70-211:~/gemini-cli-aws/mcp-https-python-aws$gemini
▝▜▄ Gemini CLI v0.33.1
▝▜▄
▗▟▀ Logged in with Google /auth
▝▀ Gemini Code Assist Standard /upgrade
>/mcp list
Configured MCP servers:
🟢 aws-https-python - Ready (1 tool)
Tools:
- mcp_aws-https-python_greet
And you can then connect to the MCP Server over HTTP:
> greet two snakes!
✦ I will greet two snakes using the available greeting tool.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Action Required │
│ │
│ ? greet (aws-https-python MCP Server) {"param":"two snakes"} │
│ │
│ ... first 4 lines hidden (Ctrl+O to show) ... │
│ (press Ctrl+O to expand MCP tool details) │
│ Allow execution of MCP tool "greet" from server "aws-https-python"? │
│ │
│ 1. Allow once │
│ 2. Allow tool for this session │
│ 3. Allow all server tools for this session │
│ ●くろまる 4. Allow tool for all future sessions │
│ 5. No, suggest changes (esc) │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The greet tool in this MCP server returns the parameter it receives. When called with "two snakes", it returned:
two snakes
Accessing the Python MCP Server Remotely
Now that the basic MCP functionality has been tested locally and verified with Gemini CLI- the Python server code can be verified remotely.
First- retrieve the public IP address of the EC2 instance and check that port 8080 is open for Internet traffic:
> what is the external IP address of the EC2 Instance
✦ I will list the EC2 instances to find their external IP addresses.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ Shell aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, PublicIpAddress, Stat... │
│ │
│ ----------------------------------------------------- │
│ | DescribeInstances | │
│ +----------------------+-----------------+----------+ │
│ | i-03456018d00d13504 | 3.236.173.161 | running | │
│ +----------------------+-----------------+----------+ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The external IP address of the EC2 instance is 3.236.173.161.
✦ I will check the inbound rules for the security group sg-079649e89ed485925 to see if port 8080 is open to external
traffic.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ Shell aws ec2 describe-security-groups --group-ids sg-079649e89ed485925 --query 'SecurityGroups[*].IpPerm... │
│ │
│ ... first 3 lines hidden (Ctrl+O to show) ... │
│ "IpProtocol": "tcp", │
│ "FromPort": 8080, │
│ "ToPort": 8080, │
│ "UserIdGroupPairs": [], │
│ "IpRanges": [ │
│ { │
│ "CidrIp": "0.0.0.0/0" │
│ } │
│ ], │
│ "Ipv6Ranges": [], │
│ "PrefixListIds": [] │
│ } │
✦ Port 8080 is open to all external traffic (0.0.0.0/0) for the EC2 instance i-03456018d00d13504 via security group
sg-079649e89ed485925.
Leave the MCP server running in the EC2 instance and switch to your local environment. Update the local Gemini settings.json with the MCP server and IP address of the EC2 instance:
{"mcpServers":{"aws-https-python":{"httpUrl":"http://3.236.173.161:8080/mcp"}}}
then validate the connection to the MCP server running in EC2 with your local Gemini CLI Client:
> /mcp list
Configured MCP servers:
🟢 aws-https-python - Ready (1 tool)
Tools:
- mcp_aws-https-python_greet
> greet Hello EC2 MCP!
✦ I'll call the greet tool for you.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Action Required │
│ │
│ ? greet (aws-https-python MCP Server) {"param":"Hello EC2 MCP!"} │
│ │
│ ... first 4 lines hidden (Ctrl+O to show) ... │
│ (press Ctrl+O to expand MCP tool details) │
│ Allow execution of MCP tool "greet" from server "aws-https-python"? │
│ │
│ 1. Allow once │
│ 2. Allow tool for this session │
│ 3. Allow all server tools for this session │
│ ●くろまる 4. Allow tool for all future sessions │
│ 5. No, suggest changes (esc) │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ I'll call the greet tool for you.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ greet (aws-https-python MCP Server) {"param":"Hello EC2 MCP!"} │
│ │
│ Hello EC2 MCP! │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ OK. I've greeted EC2 MCP.
Summary
The strategy for using Python for MCP development with Gemini CLI and AWS was validated with a incremental step by step approach.
A minimal HTTP transport MCP Server was started from Python source code and validated with Gemini CLI running as a MCP client in the same local environment.
The HTTP server was then tested remotely from the AWS EC2 instance.
This approach can be extended to more complex deployments using other MCP transports and Cloud based options.