AWS Labs EKS Model Context Protocol (MCP) Server

0.1.27 · active · verified Fri Apr 17

The `awslabs-eks-mcp-server` package provides a Python-based server implementation for the Model Context Protocol (MCP), designed specifically for AWS EKS environments. It enables machine learning models to be served and managed efficiently within Kubernetes. As an AWS Labs 'sample' project, it demonstrates best practices and patterns but may not carry the same long-term support or stability guarantees as official AWS SDKs. The current version is `0.1.27`, with a release cadence that reflects ongoing development in a pre-1.0 state.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a basic MCP server. It involves defining a custom `ModelProvider` class that implements the necessary methods to serve model artifacts and context. The `ModelContextProtocolServer` wraps this provider, exposing a FastAPI application. The server is then run using `uvicorn`, typically accessible via `http://localhost:8000` (or the configured port). Remember to install `uvicorn` separately.

import uvicorn
from mcp_server.server import ModelContextProtocolServer
from mcp_server.provider import ModelProvider

class MyModelProvider(ModelProvider):
    def __init__(self):
        super().__init__('my-model-provider-id')

    async def get_model_artifact_uri(self, model_id: str) -> str:
        # In a real scenario, this would return an S3 URI or similar
        print(f"Request for model_id: {model_id}")
        return f"s3://my-bucket/models/{model_id}/artifact.tar.gz"

    async def get_model_context(self, model_id: str) -> dict:
        # Return context specific to the model, e.g., framework, version
        return {"framework": "pytorch", "version": "1.13.1", "device": "cuda"}

# Instantiate your model provider
provider = MyModelProvider()

# Create the MCP server instance
app = ModelContextProtocolServer(provider=provider, port=8000)

# Run the FastAPI app using Uvicorn
# In a real deployment, you'd use a proper process manager (e.g., systemd, Kubernetes deployment)
# For local testing, you can run this file directly and access http://localhost:8000/docs

# Example of running the app via uvicorn programmatically
if __name__ == "__main__":
    print("Starting MCP server on http://localhost:8000")
    # Use reload=True for development, remove in production
    uvicorn.run(app.get_app(), host="0.0.0.0", port=8000)

view raw JSON →