DEV Community

xbill for Google Developer Experts

Posted on • Originally published at xbill999.Medium on

Deploying a Rust MCP Server to Azure AKS

The rmcp crate and standard Rust libraries are used to build a basic MCP Server in Rust. This MCP Server is then built and deployed to Azure AKS and validated locally with Gemini CLI.

Even More MCP Demos?

You Betcha! Just wait for the COBOL MCP- its coming.

Why not just use Python?

Python has traditionally been the main coding language for ML and AI tools. One of the strengths of the MCP protocol is that the actual implementation details are independent of the development language. The reality is that not every project is coded in Python- and MCP allows you to use the latest AI appt roaches with other coding languages.

What is this Tutorial Trying to Do?

Building on previous tutorials, the goal is to extend a Rust MCP server with basic support for deployment to Azure.

What is Rust?

Rust is a high performance, memory safe, compiled language:

Rust

Rust provides memory safe operations beyond C/C++ and also can provide exceptional performance gains as it is compiled directly to native binaries.

So is this the Real Deal (tm)?

So what is different about this lab compared to all the others out there?

This is one of the first deep dives into deploying a Rust based MCP server hosted on Azure. The Azure AKS service was targeted for general Kubernates compatiblity.

Rust Setup

Instructions to install Rust are available here:

Getting started

For a Linux like environment the command looks like this:

curl — proto ‘=https’ — tlsv1.2 -sSf https://sh.rustup.rs | sh
Enter fullscreen mode Exit fullscreen mode

Rust also depends on a working C compiler and OpenSSL setup. For a Debian 12 system — install the basic tools for development:

sudo apt install build-essential
sudo apt install libssl-dev
sudo apt install pkg-config
sudo apt-get install libudev-dev
sudo apt install make
sudo apt install git
Enter fullscreen mode Exit fullscreen mode

Gemini CLI

If not pre-installed you can download the Gemini CLI to interact with the source files and provide real-time assistance:

npm install -g @google/gemini-cli
Enter fullscreen mode Exit fullscreen mode

Testing the Gemini CLI Environment

Once you have all the tools and the correct Node.js version in place- you can test the startup of Gemini CLI. You will need to authenticate with a Key or your Google Account:

▝▜▄ Gemini CLI v0.33.1
    ▝▜▄
   ▗▟▀ Logged in with Google /auth
  ▝▀ Gemini Code Assist Standard /upgrade no sandbox (see /docs) /model Auto (Gemini 3) | 239.8 MB
Enter fullscreen mode Exit fullscreen mode

Azure Kubernates Service

Azure Kubernetes Service (AKS) is a fully managed, serverless Kubernetes service on Microsoft Azure that simplifies deploying, scaling, and managing containerized applications. It handles critical tasks like health monitoring, maintenance, and automated upgrades, reducing operational complexity. AKS is used for microservices, DevOps, and cloud-native app development.

More details are available here:

https://azure.microsoft.com/en-us/products/kubernetes-service

Isn’t that Overkill? A whole Cluster Just for some MCP?!

An entire cluster is a large deployment for just a basic MCP server. The goal was to validate that MCP servers could be deployed — and that opens the door for more complex deployments that can take advantage of the full services in the cluster.

Why would I want Gemini CLI with Azure? Isn’t that a Google Thing?

Yes- Gemini CLI leverages the Google Cloud console and Gemini models but it is also open source and platform agnostic. Many applications are already cross-cloud so this enables familiar tools to be run natively on Microsoft Azure.

Azure CLI

The Azure Command-Line Interface (CLI) is a cross-platform tool used to connect to Azure and execute administrative commands on your cloud resources. [1, 2]

It allows you to manage services like virtual machines, storage accounts, and networks through a terminal using either interactive prompts or automated scripts.

More information is here:

What is the Azure CLI?

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-azure
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 Azure credentials:

xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ az login
Enter fullscreen mode Exit fullscreen mode

Finally install the packages and dependencies:

cd ~/gemini-cli-azure/mcp-aks-rust-azure
Enter fullscreen mode Exit fullscreen mode

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-aks-rust-azure 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-azure/mcp-aks-rust-azure$ make
Building the Rust project...
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.46s
xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ 
Enter fullscreen mode Exit fullscreen mode

then lint check the code:

xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ make
Building the Rust project...
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.41s
xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ 
Enter fullscreen mode Exit fullscreen mode

and run local tests:

xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ make test
Running tests...
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.12s
     Running unittests src/main.rs (target/debug/deps/mcp_aks_rust_azure-4889150be0912418)

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

xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ 
Enter fullscreen mode Exit fullscreen mode

The last step is to build the production version:

xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ make release
Building Release...
    Finished `release` profile [optimized] target(s) in 0.38s
xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$
Enter fullscreen mode Exit fullscreen mode

The MCP server can be started locally:

xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ make start
Building Release...
    Finished `release` profile [optimized] target(s) in 0.12s
Starting the MCP server...
Server started with PID 29458
Enter fullscreen mode Exit fullscreen mode

The MCP tool can then be tested locally:

🟢 local-rust - Ready (1 tool)
  Tools:
  - mcp_local-rust_greeting

 > mcp_local-rust_greeting hello local

  Executing Greeting Tool: Executing the greeting tool on the local Rust MCP server.

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ greeting (local-rust MCP Server) {"message":"hello local"} │
│ │
│ Hello World MCP! hello local │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  Greeting Completed: Greeting successful. Standing by for next instruction.

✦ Hello World MCP! hello local

Enter fullscreen mode Exit fullscreen mode

Deploy To AKS

A basic Dockerfile is used to build an image for deployment:

xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ make deploy
Building the Docker image...
[+] Building 1.1s (14/14) FINISHED docker:default
 => [internal] load build definition from Dockerfile 0.0s
Enter fullscreen mode Exit fullscreen mode

Get the deployment status:

xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ make status
mcp-aks-rust-azure PID file exists but process is not running.
Checking AKS status for mcp-aks-penguin...
Name State K8sVersion
--------------- --------- ------------
mcp-aks-penguin Succeeded 1.34
Kubernetes Services:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
mcp-server-service LoadBalancer 10.0.238.5 4.149.219.223 80:32338/TCP 42m
Kubernetes Pods:
NAME READY STATUS RESTARTS AGE
mcp-server-deployment-5687cdc977-qpdd7 1/1 Running 0 42m
Enter fullscreen mode Exit fullscreen mode

Get the Endpoint:

xbill@penguin:~/gemini-cli-azure/mcp-aks-rust-azure$ make endpoint
AKS Endpoint:
4.149.219.223
Enter fullscreen mode Exit fullscreen mode

Check Gemini MCP settings:

{
  "mcpServers": {
    "mcp-aks-rust-azure": {
      "httpUrl": "http://4.149.219.223/mcp"
    },
    "local-rust": {
      "httpUrl": "http://127.0.0.1:8080/mcp"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

The service will be visible on the Azure console:

Final Test

Start up Gemini CLI and check the MCP server status:

/mcp list  

🟢 mcp-aks-rust-azure - Ready (1 tool)
  Tools:
  - mcp_mcp-aks-rust-azure_greeting


 > mcp_mcp-aks-rust-azure_greeting Hello AKS!

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ greeting (mcp-aks-rust-azure MCP Server) {"message":"Hello AKS!"} │
│ │
│ Hello World MCP! Hello AKS! │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  Initializing AKS Rust MCP Project Assistant: 
  I am assisting with the development and deployment of the `mcp-aks-rust-azure` MCP server on AKS.

✦ Hello World MCP! Hello AKS!
Enter fullscreen mode Exit fullscreen mode

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 Azure AKS. The remote MCP server was validated with Gemini CLI locally.

Top comments (2)

Collapse
 
mournfulcord profile image
MournfulCord

Using Gemini CLI against an Azure-hosted Rust MCP server is a cross-cloud combo you don't see written up often. The language-agnostic angle of MCP is underrated, too; people assume Python or nothing. Nice to have a concrete AKS example out there. Nice write-up.

Collapse
 
xbill profile image
xbill Google Developer Experts

The positive side effect is that I have a set of scripts that can use to successfully deploy - so for the next project I have working baseline to start from. The single binary Dockerfiles can be very picky