Math MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Math MCP Serveradd 15 and 25"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Math MCP Server on Google Kubernetes Engine (GKE)
An enterprise-grade, secure, and production-ready implementation of a remote Model Context Protocol (MCP) Server deployed to Google Kubernetes Engine (GKE) using the modern GKE Gateway API.
This repository implements the architecture outlined in the Google Cloud guide: Build and Deploy a Remote MCP Server to GKE in 30 Minutes.
ποΈ Architecture & Clean Coding Standards
Unlike basic tutorial code, this repository follows strict Domain-Driven Design (DDD) and Clean Code principles to ensure that the server is robust, maintainable, and easily extendable.
π Core Principles Applied
Separation of Concerns (DDD):
Domain Layer (
src/domain): Contains the core business logic (MathService) and domain invariants. It has zero dependencies on the transport protocol or framework (FastMCP/Starlette).Transport Layer (
src/transport): Handles protocol-specific transport (FastMCP tools and HTTP routes) and acts as an adapter, delegating requests to the Domain Layer.
Robust Guard Clauses & Validation: Complete validation of input boundaries. Errors are intercepted at the domain boundary, raising domain-specific exceptions (
InvalidInputError), which are safely handled and translated at the transport layer.Enterprise-Grade Logging: Zero
print()statements are used. Standard pythonloggingis configured with meaningful contexts, log levels, timestamps, and line numbers.Strict Type Annotations: 100% type-annotated code, facilitating static analysis and reducing runtime type mismatch bugs.
Google-Style Docstrings: All modules, classes, and methods are fully documented following the Google style guide.
Robust Integration Testing: Real integration test client verifying not only successful scenarios but also asserting that domain boundary rules (guard clauses) successfully intercept invalid inputs.
Related MCP server: Calculator MCP Server
π Repository Structure
gke-mcp-server/
βββ Dockerfile # Multi-stage optimized Docker build using Astral uv
βββ README.md # Comprehensive documentation and deployment guide
βββ deployment.yaml # Kubernetes Deployment and Service resource definitions
βββ gateway.yaml # GKE Gateway API, GCPBackendPolicy, and HealthCheckPolicy
βββ pyproject.toml # Astral uv dependency and environment configuration
βββ server.py # Main application entrypoint configuring global logging
βββ test_mcp_server.py # Integration test suite validating success and boundary cases
βββ src/
βββ __init__.py
βββ domain/
β βββ __init__.py
β βββ exceptions.py # Custom domain-level exceptions (e.g. InvalidInputError)
β βββ services.py # Core Domain service containing business logic & validations
βββ transport/
βββ __init__.py
βββ mcp_server.py # Transport layer registering FastMCP tools & health endpointsπ Local Development & Quickstart
We use uv as our Python project manager for extremely fast, reproducible installations.
1. Prerequisites
Ensure you have the following installed on your local machine:
Python 3.10+ (Python 3.11/3.12 recommended)
uv(Astral's package manager)
2. Install Dependencies
Run the following command to set up the virtual environment and sync dependencies:
uv sync3. Run the Server Locally
To start the Math MCP server on port 3000 locally:
uv run server.pyYou should see logging indicating the server has booted:
[2026-06-19 14:48:26] [INFO] [math_mcp_server] - Starting streamable-http server...4. Run Integration Tests
While the local server is running, execute the integration tests in a separate terminal:
uv run test_mcp_server.pyThe test client will connect to the server, list the available tools, run calculations, and assert correctness of outputs and domain constraints:
[INFO] [test_mcp_client] - Verification PASSED: 15 + 25 = 40
[INFO] [test_mcp_client] - Verification PASSED: 50 - 15 = 35
[INFO] [test_mcp_client] - Verification PASSED: Server successfully intercepted input.βΈοΈ Production Deployment to GKE
This section describes how to containerize the server and deploy it to a secure, scalable GKE Autopilot cluster using Google-Managed SSL Certificates and the Kubernetes Gateway API.
1. Environment Setup
Configure your active Google Cloud project and region variables:
export PROJECT_ID=$(gcloud config get-value project)
export REGION=us-central1
# Authenticate with Google Cloud
gcloud auth login
gcloud config set project $PROJECT_ID2. Create the GKE Cluster
Initiate a GKE Autopilot cluster optimized for cost and fast scaling:
gcloud container clusters create-auto mcp-cluster \
--region $REGION \
--release-channel rapid \
--async3. Build & Register Container Image
Set up a Google Artifact Registry repository to host the Docker image:
# Create the Docker repository
gcloud artifacts repositories create mcp-repo \
--repository-format=docker \
--location=$REGION
# Build and push the image using Google Cloud Build
gcloud builds submit --tag $REGION-docker.pkg.dev/$PROJECT_ID/mcp-repo/math-mcp-server:latest .4. Deploy Workloads to GKE
Once the cluster creation is complete, fetch cluster credentials:
# Verify cluster status
gcloud container clusters list
# Get cluster kubectl credentials
gcloud container clusters get-credentials mcp-cluster --region $REGIONNow, update the container image path in deployment.yaml with your actual project details (replace REGION and PROJECT_ID), and apply the manifest:
# Apply deployment and service
kubectl apply -f deployment.yaml
# Verify pods are successfully running
kubectl get pods -l app=mcp-serverπ Securing & Routing Traffic (GKE Gateway API)
Instead of using legacy Ingress, this deployment uses the modern GKE L7 Gateway API combined with Google-Managed SSL Certificates for production-grade security.
1. Reserve Static External IP
Reserve a global static IP for the Gateway:
gcloud compute addresses create mcp-server-ip --global
# Retrieve the IP address
export MCP_SERVER_IP=$(gcloud compute addresses describe mcp-server-ip --global --format="value(address)")
echo "Your Static Load Balancer IP: $MCP_SERVER_IP"Important: Go to your DNS provider and point your domain's DNS A record (e.g., mcp.yourdomain.com) to $MCP_SERVER_IP.
2. Create Google-Managed SSL Certificate
Replace mcp.yourdomain.com with your fully-qualified domain name:
gcloud compute ssl-certificates create mcp-cert --domains mcp.yourdomain.com --global3. Apply Gateway Routing Configuration
Modify gateway.yaml to replace mcp.yourdomain.com with your domain, then deploy the routing rules:
kubectl apply -f gateway.yamlThe GKE Gateway controller will automatically provision a Cloud Load Balancer, bind the global static IP, attach the Google-managed SSL certificate, and route /mcp prefixes to the backend service.
4. Verify Routing Features
Session Affinity (
GCPBackendPolicy): Configures client-IP affinity to ensure SSE stream sessions from the same client stay anchored to the same backend pod.Health Checks (
HealthCheckPolicy): Routes external GKE health check probes directly to the custom/healthzStarlette route on port3000.
Check the status of the gateway provisioning:
kubectl get gateway mcp-gateway5. Run Production Integration Test
Point the test client to your secure production domain to run tests over SSL:
export MCP_SERVER_URL="https://mcp.yourdomain.com/mcp"
uv run test_mcp_server.pyπ§Ή Cleanup Resources
To prevent recurring charges on your Google Cloud project, tear down all resources when finished:
# Delete Kubernetes resources
kubectl delete -f gateway.yaml
kubectl delete -f deployment.yaml
# Delete global static resources
gcloud compute addresses delete mcp-server-ip --global --quiet
gcloud compute ssl-certificates delete mcp-cert --quiet
# Delete Artifact Registry repository
gcloud artifacts repositories delete mcp-repo --location=$REGION --quiet
# Delete GKE Cluster
gcloud container clusters delete mcp-cluster --region $REGION --quietπ License
This project is licensed under the MIT License.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/unrealandychan/gke-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server