Skip to main content

A Lambda-based MCP (Model Context Protocol) server implementation

Project description

ActValue Lambda MCP Server

A Python library for creating MCP (Model Context Protocol) servers that run on AWS Lambda.

Installation

pip install actvalue.lambda-mcp-server

Quick Start

from lambda_mcp import LambdaMCPServer

# Create a server instance
server = LambdaMCPServer(
    name="my-mcp-server",
    version="1.0.0",
    instructions="A sample MCP server running on Lambda"
)

# Register tools using the decorator
@server.tool()
def hello_world(name: str) -> str:
    """Say hello to someone"""
    return f"Hello, {name}!"

# Lambda handler
def lambda_handler(event, context):
    return server.handle_request(event, context)

Features

  • AWS Lambda Integration: Designed specifically for serverless deployment
  • Session Management: Built-in Redis-based session storage
  • Tool Registration: Easy decorator-based tool registration
  • MCP Protocol: Full MCP protocol compliance
  • Type Safety: Complete type annotations for better development experience

Configuration

Basic Configuration

server = LambdaMCPServer(
    name="my-server",
    version="1.0.0",
    instructions="Server description",
    cache_prefix="my_sessions",  # Redis key prefix
    redis_url="redis://localhost:6379/0"
)

Environment Variables

  • REDIS_URL: Redis connection URL
  • LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)

Session Management

Access and modify session data within your tools:

@server.tool()
def store_data(key: str, value: str) -> str:
    session = server.get_session()
    if session:
        session.data[key] = value
        return f"Stored {key} = {value}"
    return "No active session"

@server.tool()
def get_data(key: str) -> str:
    session = server.get_session()
    if session and key in session.data:
        return str(session.data[key])
    return "Key not found"

Develpment and test

Create and activate virtual environment

python -m venv .venv
source .venv/bin/activate

Install package in development mode

pip install -e .

See examples and their readme file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

actvalue_lambda_mcp_server-1.0.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

actvalue_lambda_mcp_server-1.0.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file actvalue_lambda_mcp_server-1.0.0.tar.gz.

File metadata

File hashes

Hashes for actvalue_lambda_mcp_server-1.0.0.tar.gz
Algorithm Hash digest
SHA256 17ac5c57d2c4118b05c18315a8fe7321a4449ba9450b919c352dad68b804f9b3
MD5 8a2a4c003bac95378c2b2e253e60682b
BLAKE2b-256 ea45c69ec61000b9dc06c83596921ad09d7bbd29369d9e2d9c3ddc7c6bcefd6d

See more details on using hashes here.

File details

Details for the file actvalue_lambda_mcp_server-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for actvalue_lambda_mcp_server-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb20f80287df05f7d6e7ab7eac32701df5e98018646dbc44e0fbd48a468bf56a
MD5 a03abf963206b06c379088d6ab605391
BLAKE2b-256 81b2a9fdd6643c682832d8de26ee3042111f3a334c50bca73895ce5b1e7da9e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page