Skip to main content

mcp-ephemeral-k8s

Release Build status codecov Commit activity License

A Python library for spawning ephemeral Model Context Protocol (MCP) servers on Kubernetes using Server-Sent Events (SSE).

Features

  • Supports multiple runtimes:
    • Node.js (via npx)
    • Python (via uvx)
  • Works with mcp-proxy for uvx or npx runtimes
  • Supports both local kubeconfig and in-cluster configuration
  • Can be run as MCP server

Usage

Running the MCP Server

uvx mcp-ephemeral-k8s

Using the Library

import asyncio
from mcp_ephemeral_k8s import KubernetesSessionManager, presets

async def main():
    async with KubernetesSessionManager() as session_manager:
        mcp_server = await session_manager.create_mcp_server(
            presets.K8S_MCP_SERVER, wait_for_ready=True, expose_port=True
        )
        print(mcp_server.sse_url)

if __name__ == "__main__":
    asyncio.run(main())
Job 'mcp-ephemeral-k8s-proxy-1762291156-x17zuayy' in unknown state, waiting...
http://mcp-ephemeral-k8s-proxy-1762291156-x17zuayy.default.svc.cluster.local:8080/sse

Installation

Prerequisites

  • Docker
  • Kind or any Kubernetes cluster with valid kubectl configuration

Option 1: Using uvx (Recommended)

uvx mcp-ephemeral-k8s

To connect to the MCP server, use the following config:

{
   "mcp-ephemeral-k8s": {
      "url": "http://localhost:8000/sse",
      "transport": "sse"
   }
}

Option 2: As a Python Package

pip install mcp-ephemeral-k8s
mcp-ephemeral-k8s

Option 3: Using Helm Chart

To install the Helm chart, run:

helm repo add mcp-ephemeral-k8s https://BobMerkus.github.io/mcp-ephemeral-k8s/
helm repo update
helm install mcp-ephemeral-k8s mcp-ephemeral-k8s/mcp-ephemeral-k8s

To upgrade the Helm chart, run:

helm upgrade -i mcp-ephemeral-k8s mcp-ephemeral-k8s/mcp-ephemeral-k8s

To install a specific version, run:

helm install mcp-ephemeral-k8s mcp-ephemeral-k8s/mcp-ephemeral-k8s --version <replace-with-version>

To uninstall the Helm chart, run:

helm uninstall mcp-ephemeral-k8s

Option 4: From Source

  1. Clone the repository

    git clone https://github.com/BobMerkus/mcp-ephemeral-k8s.git
    cd mcp-ephemeral-k8s
    
  2. Set up development environment

    make install
    
  3. Run pre-commit hooks

    make check
    
  4. Run tests

    make test
    
  5. Build Docker images

    make docker-build-local
    make docker-build-local-proxy
    
  6. Load images to cluster

    kind load docker-image ghcr.io/bobmerkus/mcp-ephemeral-k8s:latest
    kind load docker-image ghcr.io/bobmerkus/mcp-ephemeral-k8s-proxy:latest
    
  7. Install Helm chart

    helm upgrade -i mcp-ephemeral-k8s charts/mcp-ephemeral-k8s --set image.tag=latest
    
  8. Port forward the MCP server

    kubectl port-forward svc/mcp-ephemeral-k8s 8000:8000
    
  9. Visit the FastAPI server

    npx @modelcontextprotocol/inspector --sse http://localhost:8000/sse
    

Metadata

Release files for mcp-ephemeral-k8s 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-ephemeral-k8s 0.0.4
File Size Uploaded
mcp_ephemeral_k8s-0.0.4.tar.gz 150.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-ephemeral-k8s 0.0.4
File Interpreter ABI Platform
mcp_ephemeral_k8s-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 174.8 kB

Release files / mcp_ephemeral_k8s-0.0.4.tar.gz

Download URL mcp_ephemeral_k8s-0.0.4.tar.gz
Size 150.3 kB
Tags Source
SHA-256 checksum
How to use checksums
43344499f7a52cd402850e463f208932ac98b51c751817f3c5a7fd2ec29d615a
BLAKE2b-256 checksum
How to use checksums
46041fbc8a27a8a95ecf25579b33506d713e3beac79072649905e51c59e4c4ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.7

Release files / mcp_ephemeral_k8s-0.0.4-py3-none-any.whl

Download URL mcp_ephemeral_k8s-0.0.4-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
297eed4b57d7e3f4cb01e4035f6341cef8a7e2b4b42f0eb1a70be16530153cf1
BLAKE2b-256 checksum
How to use checksums
41d5f302cb31671711eb877a17ed0f45fcdc9060b40c2c940bb51afb0e3b37e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page