And this is the direct URL to the console:
https://lightsail.aws.amazon.com/ls/webapp/home/containers
The Lightsail console will look similar to:
Setup the Basic Environment
At this point you should have a working Rust environment and a working Gemini CLI installation. All of the relevant code examples and documentation is available in GitHub.
The next step is to clone the GitHub repository to your local environment:
cd ~
git clone https://github.com/xbill9/gemini-cli-aws
Then run init.sh from the cloned directory.
The script will attempt to determine your shell environment and set the correct variables:
source init.sh
If your session times out or you need to re-authenticate- you can run the set_env.sh script to reset your environment variables:
source set_env.sh
Variables like PROJECT_ID need to be setup for use in the various build scripts- so the set_env script can be used to reset the environment if you time-out.
Refresh the AWS credentials:
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$aws login --remote
Browser will not be automatically opened.
xbill@penguin:~/gemini-cli-aws/mcp-ligthsail-rust-aws$source save-aws-creds.sh
Exporting AWS credentials...
Successfully saved credentials to .aws_creds
The Makefile will now automatically use these for deployments.
Finally install the packages and dependencies:
~/gemini-cli-aws/mcp-lightsail-rust-aws
make install
Build The Rust MCP Server
Some background information on building and configuring a Rust MCP server is here:
Building a Secure HTTP Transport MCP Server with Rust, and Gemini CLI
The mcp-lightsail-rust subdirectory has the complete Rust MCP server in one subdirectory.
Minimal System Information Tool Build
The first step is to build the basic tool directly with Rust. This allows the tool to be debugged and tested locally before adding the MCP layer.
First build the tool locally:
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$make
Building the Rust project...
Compiling mcp-lightsail-rust-aws v1.0.0 (/home/xbill/gemini-cli-aws/mcp-lightsail-rust-aws)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 7.67s
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$
then lint check the code:
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$make lint
Linting code...
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.61s
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$
and run local tests:
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$make test
Running tests...
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.22s
Running unittests src/main.rs (target/debug/deps/mcp_lightsail_rust_aws-926af5aee1927183)
running 1 test
test tests::test_greeting ... ok
test result: ok. 1 passed;0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
The last step is to build the production version:
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$make release
Building Release...
Compiling mcp-lightsail-rust-aws v1.0.0 (/home/xbill/gemini-cli-aws/mcp-lightsail-rust-aws)
Finished `release` profile [optimized] target(s) in 43.31s
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$
The MCP server can be started locally:
xbill@penguin:~/mcp-adk-rust/mcp-cloudrun-rust$make start
Building Release...
Finished `release` profile [optimized] target(s) in 0.14s
Starting the MCP server...
Server started with PID 1569
Then Gemini CLI is used as a MCP client:
🟢 local-rust - Ready (1 tool)
Tools:
- mcp_local-rust_greeting
The MCP tool can then be tested:
> mcp_local-rust_greeting local
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Action Required │
│ │
│ ? greeting (local-rust MCP Server) {"message":"local"} │
│ │
│ MCP Server: local-rust │
│ Tool: greeting │
│ │
│ MCP Tool Details: │
│ (press Ctrl+O to expand MCP tool details) │
│ Allow execution of MCP tool "greeting" from server "local-rust"? │
│ │
│ 1. Allow once │
│ 2. Allow tool for this session │
│ 3. Allow all server tools for this session │
│ ●くろまる 4. Allow tool for all future sessions ~/.gemini/policies/auto-saved.toml │
│ 5. No, suggest changes (esc) │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The mcp_local-rust_greeting tool was executed with the message "local", returning:
"Hello World MCP! local"
Deploy To LightSail
A basic Dockerfile is used to build an image for deployment:
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$make deploy
Building the Docker image...
[+] Building 5.3s (15/15) FINISHED docker:default
=>[internal] load build definition from Dockerfile 0.0s
Get the Endpoint:
xbill@penguin:~/gemini-cli-aws/mcp-lightsail-rust-aws$make endpoint
https://mcp-lightsail-rust-aws.6wpv8vensby5c.us-east-1.cs.amazonlightsail.com/
Check Gemini MCP settings:
{"mcpServers":{"aws-lightsail-rust":{"httpUrl":"https://mcp-lightsail-rust-aws.6wpv8vensby5c.us-east-1.cs.amazonlightsail.com/mcp"},"local-rust":{"httpUrl":"http://127.0.0.1:8080/mcp"}}}
The service will be visible on the LightSail console:
Final Test
Start up Gemini CLI and check the MCP server status:
🟢 aws-lightsail-rust - Ready (1 tool)
Tools:
- mcp_aws-lightsail-rust_greeting
> mcp_aws-lightsail-rust_greeting Hello LightSail!
Executing Lightsail Greeting: Executing the greeting tool for Amazon Lightsail Rust MCP server.
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ greeting (aws-lightsail-rust MCP Server) {"message":"Hello LightSail!"} │
│ │
│ Hello World MCP! Hello LightSail! │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The mcp_aws-lightsail-rust_greeting tool returned:
Hello World MCP! Hello LightSail!
Summary
A complete HTTP transport MCP server was built using Rust. This application was tested locally with Gemini CLI. Then, the entire solution was deployed to AWS LightSail. The remote MCP server was validated with Gemini CLI locally.