modmex-lambda 0.6.3__tar.gz → 0.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/PKG-INFO +109 -2
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/README.md +107 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/api_gateway.py +15 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/__init__.py +37 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/middleware.py +70 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/prompt.py +51 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/protocol.py +64 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/registry.py +90 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/resource.py +83 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/schema.py +97 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/server.py +420 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/tool.py +170 -0
- modmex_lambda-0.7.1/modmex_lambda/mcp/transport.py +202 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/poetry.lock +9 -8
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/pyproject.toml +1 -1
- modmex_lambda-0.7.1/tests/mcp/helpers.py +17 -0
- modmex_lambda-0.7.1/tests/mcp/test_http.py +108 -0
- modmex_lambda-0.7.1/tests/mcp/test_middleware.py +90 -0
- modmex_lambda-0.7.1/tests/mcp/test_resources_prompts.py +75 -0
- modmex_lambda-0.7.1/tests/mcp/test_server.py +51 -0
- modmex_lambda-0.7.1/tests/mcp/test_tools.py +118 -0
- modmex_lambda-0.7.1/tests/mcp/test_transport.py +36 -0
- modmex_lambda-0.7.1/tests/stream/utils/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/.github/workflows/ci.yml +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/.github/workflows/release.yml +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/.gitignore +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/LICENSE +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/cloudwatch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/dynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/eventbridge.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/eventbridge_scheduler.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/icloudwatch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/idynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/ieventbridge.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/ieventbridge_scheduler.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/ilambda.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/is3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/isns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/isqs.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/lambda_.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/module.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/connectors/sqs.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/data_classes/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/data_classes/api_gateway_authorizer_event.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/data_classes/api_gateway_proxy_event.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/data_classes/api_gateway_websocket_event.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/data_classes/cognito_user_pool_event.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/data_classes/common.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/dependencies.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/constants.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/content_types.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/cors.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/dependencies/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/dependencies/compat.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/dependencies/dependant.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/dependencies/dependency_middleware.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/dependencies/depends.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/dependencies/params.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/dependencies/types.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/exception_handler.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/exceptions.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/gateway_response.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/middlewares.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/params.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/request.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/response.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/routing.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/routing_fallbacks.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_handler/types.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/event_sources.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/exceptions.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/logging.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/params.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/parser.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/persistence/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/persistence/dynamodb/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/persistence/dynamodb/expressions.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/persistence/dynamodb/keys.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/persistence/dynamodb/materialized_views.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/persistence/dynamodb/stream_fields.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/py.typed +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/request.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/resolver.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/response.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/routing.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/shared/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/shared/cookies.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/shared/headers_serializer.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/shared/json_encoder.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/shared/types.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/events/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/events/dynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/events/kinesis.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/events/s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/events/sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/events/sqs.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/filters/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/filters/content.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/filters/event_type.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/filters/latch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/filters/skip.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/base_flavor.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/cdc.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/collect.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/correlate.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/evaluate.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/expired.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/iflavor.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/job.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/materialize.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/schedule.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/task.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/flavors/update.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/irules_registry.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/cloudwatch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/dynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/ioperator.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/lambda_.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/publisher.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/scheduler.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/operators/sqs.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/rules_registry.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/runner.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/schedulers.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/sources/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/sources/base.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/sources/dynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/sources/kinesis.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/sources/s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/sources/sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/sources/sqs.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/apigateway.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/aws.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/batch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/cloudwatch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/concurrency.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/contracts.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/data_classes/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/data_classes/dynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/decorators.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/dynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/eventbridge.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/faults.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/filters.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/json_encoder.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/lambda_.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/operators.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/pluralize.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/print.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/retry.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/split.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/sqs.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/tags.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/time.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/stream/utils/uow.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/tracing.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/modmex_lambda/validation.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/conftest.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/connectors/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/connectors/conftest.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/connectors/test_cloudwatch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/connectors/test_dynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/connectors/test_lazy_clients.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/connectors/test_s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/connectors/test_simple_connectors.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/connectors/test_sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/connectors/test_sqs.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/data_classes/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/data_classes/test_api_gateway_proxy_event.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/data_classes/test_cognito_user_pool_event.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/data_classes/test_common.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/event_handler/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/event_handler/test_api_gateway.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/event_handler/test_cors.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/event_handler/test_dependencies.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/event_handler/test_exception_handler.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/event_handler/test_gateway_response.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/event_handler/test_request.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/event_handler/test_response.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/event_handler/test_routing.py +0 -0
- {modmex_lambda-0.6.3/tests/shared → modmex_lambda-0.7.1/tests/mcp}/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/persistence/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/persistence/test_dynamodb_expressions.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/persistence/test_dynamodb_keys.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/persistence/test_dynamodb_materialized_views.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/persistence/test_dynamodb_stream_fields.py +0 -0
- {modmex_lambda-0.6.3/tests/stream → modmex_lambda-0.7.1/tests/shared}/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/shared/test_cookies_headers.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/shared/test_json_encoder.py +0 -0
- {modmex_lambda-0.6.3/tests/stream/events → modmex_lambda-0.7.1/tests/stream}/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/conftest.py +0 -0
- {modmex_lambda-0.6.3/tests/stream/filters → modmex_lambda-0.7.1/tests/stream/events}/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/events/test_dynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/events/test_kinesis.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/events/test_s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/events/test_sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/events/test_sqs.py +0 -0
- {modmex_lambda-0.6.3/tests/stream/flavors → modmex_lambda-0.7.1/tests/stream/filters}/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/filters/test_content.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/filters/test_event_type.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/filters/test_latch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/filters/test_skip.py +0 -0
- {modmex_lambda-0.6.3/tests/stream/utils → modmex_lambda-0.7.1/tests/stream/flavors}/__init__.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/source_events.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_base_flavor.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_cdc.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_collect.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_correlate.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_evaluate.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_expired.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_job.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_materialize.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_schedule.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_task.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/flavors/test_update.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/operators/test_scheduler.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/test_dependency_resolver.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/test_faults.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/test_rules_registry.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/test_runner.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/test_runner_pipeline.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/test_sources.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/faults.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_apigateway.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_aws.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_batch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_cloudwatch.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_concurrency.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_decorators.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_dynamodb.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_eventbridge.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_filters.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_json_encoder.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_lambda.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_operators.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_pluralize.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_print.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_retry.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_s3.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_sns.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_split.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_sqs.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_tags.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_time.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/stream/utils/test_uow.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/test_lazy_imports.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/test_logging.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/test_parser_event_sources.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/test_reexports.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/test_tracing.py +0 -0
- {modmex_lambda-0.6.3 → modmex_lambda-0.7.1}/tests/test_validation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: modmex-lambda
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.1
|
|
4
4
|
Summary: Ultra-lightweight AWS Lambda utilities for API Gateway routing and event handling.
|
|
5
5
|
Author: Modmex
|
|
6
6
|
License: MIT
|
|
@@ -1266,3 +1266,110 @@ handler = KinesisSource(registry, concurrency=False).handle
|
|
|
1266
1266
|
|
|
1267
1267
|
- OpenAPI/Swagger generation is not implemented.
|
|
1268
1268
|
- Async API Gateway resolver pipelines are not implemented yet.
|
|
1269
|
+
|
|
1270
|
+
## Model Context Protocol (MCP) Server
|
|
1271
|
+
|
|
1272
|
+
`modmex-lambda` exposes MCP `2026-07-28` through the existing
|
|
1273
|
+
`APIGatewayHttpResolver`. MCP is an optional adapter; it does not introduce a
|
|
1274
|
+
second HTTP resolver, DI system, or application lifecycle.
|
|
1275
|
+
|
|
1276
|
+
### Basic server
|
|
1277
|
+
|
|
1278
|
+
Tools reuse the existing dependency injection and `modmex` model schemas:
|
|
1279
|
+
|
|
1280
|
+
```python
|
|
1281
|
+
from typing import Annotated
|
|
1282
|
+
|
|
1283
|
+
from modmex import BaseModel
|
|
1284
|
+
from modmex_lambda import APIGatewayHttpResolver, Depends
|
|
1285
|
+
from modmex_lambda.mcp import MCPServer
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
class Order(BaseModel):
|
|
1289
|
+
customer: str
|
|
1290
|
+
item: str
|
|
1291
|
+
|
|
1292
|
+
|
|
1293
|
+
app = APIGatewayHttpResolver()
|
|
1294
|
+
mcp = MCPServer(name="orders", version="1.0.0")
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
@mcp.tool()
|
|
1298
|
+
def create_order(order: Order):
|
|
1299
|
+
return {"status": "received", "order": order.model_dump()}
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
app.include_mcp(mcp, path="/mcp")
|
|
1303
|
+
handler = app.handler
|
|
1304
|
+
```
|
|
1305
|
+
|
|
1306
|
+
### Capabilities
|
|
1307
|
+
|
|
1308
|
+
The server supports:
|
|
1309
|
+
|
|
1310
|
+
- `server/discover`;
|
|
1311
|
+
- `tools/list` and `tools/call`;
|
|
1312
|
+
- `resources/list`, `resources/templates/list` and `resources/read`;
|
|
1313
|
+
- `prompts/list` and `prompts/get`;
|
|
1314
|
+
- pagination through the opaque `nextCursor` field;
|
|
1315
|
+
- `structuredContent` in tool results;
|
|
1316
|
+
- `resultType`, `ttlMs` and `cacheScope` metadata;
|
|
1317
|
+
- JSON responses and buffered `text/event-stream` responses.
|
|
1318
|
+
|
|
1319
|
+
Resources and prompts are registered explicitly:
|
|
1320
|
+
|
|
1321
|
+
```python
|
|
1322
|
+
@mcp.resource("orders://{order_id}", name="order")
|
|
1323
|
+
def order_resource(order_id: str):
|
|
1324
|
+
return {"order_id": order_id}
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
@mcp.prompt(name="order_assistant")
|
|
1328
|
+
def order_assistant_prompt():
|
|
1329
|
+
return [{
|
|
1330
|
+
"role": "system",
|
|
1331
|
+
"content": {"type": "text", "text": "Help manage orders."},
|
|
1332
|
+
}]
|
|
1333
|
+
```
|
|
1334
|
+
|
|
1335
|
+
Tools are actions that an MCP client can invoke. Resources and prompts are
|
|
1336
|
+
read explicitly by the client application; they are not automatically
|
|
1337
|
+
converted into tools.
|
|
1338
|
+
|
|
1339
|
+
### Stateless HTTP contract
|
|
1340
|
+
|
|
1341
|
+
Every request uses protocol metadata in `_meta` and the modern HTTP headers:
|
|
1342
|
+
|
|
1343
|
+
```text
|
|
1344
|
+
MCP-Protocol-Version: 2026-07-28
|
|
1345
|
+
Mcp-Method: tools/call
|
|
1346
|
+
Mcp-Name: create_order
|
|
1347
|
+
```
|
|
1348
|
+
|
|
1349
|
+
The server does not use `initialize`, `ping` or `Mcp-Session-Id`. Requests are
|
|
1350
|
+
independent and may be routed to any Lambda instance. If the application needs
|
|
1351
|
+
state, it must pass an explicit handle in tool arguments or persist that state
|
|
1352
|
+
in its own services.
|
|
1353
|
+
|
|
1354
|
+
### Middleware and authorization
|
|
1355
|
+
|
|
1356
|
+
MCP uses the existing resolver and middleware pipeline. Authentication should
|
|
1357
|
+
be configured with an API Gateway authorizer or application middleware. Tool
|
|
1358
|
+
permissions can be implemented as capability middleware:
|
|
1359
|
+
|
|
1360
|
+
```python
|
|
1361
|
+
@mcp.tool(middlewares=[PermissionMiddleware(["orders:create"])])
|
|
1362
|
+
def create_order(order: Order):
|
|
1363
|
+
...
|
|
1364
|
+
```
|
|
1365
|
+
|
|
1366
|
+
`MCPHttpTransport` accepts `allowed_origins=[...]` when the transport should
|
|
1367
|
+
enforce an Origin allowlist itself. Leaving it as `None` explicitly delegates
|
|
1368
|
+
Origin validation to API Gateway, WAF, or application middleware.
|
|
1369
|
+
|
|
1370
|
+
### Transport boundary
|
|
1371
|
+
|
|
1372
|
+
JSON is the required response mode. Buffered SSE is available when the client
|
|
1373
|
+
requests `text/event-stream`, but this integration does not provide a
|
|
1374
|
+
long-lived bidirectional stream or incremental Lambda response streaming.
|
|
1375
|
+
Tasks, MRTR, subscriptions and real-time notifications are future extensions.
|
|
@@ -1243,3 +1243,110 @@ handler = KinesisSource(registry, concurrency=False).handle
|
|
|
1243
1243
|
|
|
1244
1244
|
- OpenAPI/Swagger generation is not implemented.
|
|
1245
1245
|
- Async API Gateway resolver pipelines are not implemented yet.
|
|
1246
|
+
|
|
1247
|
+
## Model Context Protocol (MCP) Server
|
|
1248
|
+
|
|
1249
|
+
`modmex-lambda` exposes MCP `2026-07-28` through the existing
|
|
1250
|
+
`APIGatewayHttpResolver`. MCP is an optional adapter; it does not introduce a
|
|
1251
|
+
second HTTP resolver, DI system, or application lifecycle.
|
|
1252
|
+
|
|
1253
|
+
### Basic server
|
|
1254
|
+
|
|
1255
|
+
Tools reuse the existing dependency injection and `modmex` model schemas:
|
|
1256
|
+
|
|
1257
|
+
```python
|
|
1258
|
+
from typing import Annotated
|
|
1259
|
+
|
|
1260
|
+
from modmex import BaseModel
|
|
1261
|
+
from modmex_lambda import APIGatewayHttpResolver, Depends
|
|
1262
|
+
from modmex_lambda.mcp import MCPServer
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
class Order(BaseModel):
|
|
1266
|
+
customer: str
|
|
1267
|
+
item: str
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
app = APIGatewayHttpResolver()
|
|
1271
|
+
mcp = MCPServer(name="orders", version="1.0.0")
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
@mcp.tool()
|
|
1275
|
+
def create_order(order: Order):
|
|
1276
|
+
return {"status": "received", "order": order.model_dump()}
|
|
1277
|
+
|
|
1278
|
+
|
|
1279
|
+
app.include_mcp(mcp, path="/mcp")
|
|
1280
|
+
handler = app.handler
|
|
1281
|
+
```
|
|
1282
|
+
|
|
1283
|
+
### Capabilities
|
|
1284
|
+
|
|
1285
|
+
The server supports:
|
|
1286
|
+
|
|
1287
|
+
- `server/discover`;
|
|
1288
|
+
- `tools/list` and `tools/call`;
|
|
1289
|
+
- `resources/list`, `resources/templates/list` and `resources/read`;
|
|
1290
|
+
- `prompts/list` and `prompts/get`;
|
|
1291
|
+
- pagination through the opaque `nextCursor` field;
|
|
1292
|
+
- `structuredContent` in tool results;
|
|
1293
|
+
- `resultType`, `ttlMs` and `cacheScope` metadata;
|
|
1294
|
+
- JSON responses and buffered `text/event-stream` responses.
|
|
1295
|
+
|
|
1296
|
+
Resources and prompts are registered explicitly:
|
|
1297
|
+
|
|
1298
|
+
```python
|
|
1299
|
+
@mcp.resource("orders://{order_id}", name="order")
|
|
1300
|
+
def order_resource(order_id: str):
|
|
1301
|
+
return {"order_id": order_id}
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
@mcp.prompt(name="order_assistant")
|
|
1305
|
+
def order_assistant_prompt():
|
|
1306
|
+
return [{
|
|
1307
|
+
"role": "system",
|
|
1308
|
+
"content": {"type": "text", "text": "Help manage orders."},
|
|
1309
|
+
}]
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
Tools are actions that an MCP client can invoke. Resources and prompts are
|
|
1313
|
+
read explicitly by the client application; they are not automatically
|
|
1314
|
+
converted into tools.
|
|
1315
|
+
|
|
1316
|
+
### Stateless HTTP contract
|
|
1317
|
+
|
|
1318
|
+
Every request uses protocol metadata in `_meta` and the modern HTTP headers:
|
|
1319
|
+
|
|
1320
|
+
```text
|
|
1321
|
+
MCP-Protocol-Version: 2026-07-28
|
|
1322
|
+
Mcp-Method: tools/call
|
|
1323
|
+
Mcp-Name: create_order
|
|
1324
|
+
```
|
|
1325
|
+
|
|
1326
|
+
The server does not use `initialize`, `ping` or `Mcp-Session-Id`. Requests are
|
|
1327
|
+
independent and may be routed to any Lambda instance. If the application needs
|
|
1328
|
+
state, it must pass an explicit handle in tool arguments or persist that state
|
|
1329
|
+
in its own services.
|
|
1330
|
+
|
|
1331
|
+
### Middleware and authorization
|
|
1332
|
+
|
|
1333
|
+
MCP uses the existing resolver and middleware pipeline. Authentication should
|
|
1334
|
+
be configured with an API Gateway authorizer or application middleware. Tool
|
|
1335
|
+
permissions can be implemented as capability middleware:
|
|
1336
|
+
|
|
1337
|
+
```python
|
|
1338
|
+
@mcp.tool(middlewares=[PermissionMiddleware(["orders:create"])])
|
|
1339
|
+
def create_order(order: Order):
|
|
1340
|
+
...
|
|
1341
|
+
```
|
|
1342
|
+
|
|
1343
|
+
`MCPHttpTransport` accepts `allowed_origins=[...]` when the transport should
|
|
1344
|
+
enforce an Origin allowlist itself. Leaving it as `None` explicitly delegates
|
|
1345
|
+
Origin validation to API Gateway, WAF, or application middleware.
|
|
1346
|
+
|
|
1347
|
+
### Transport boundary
|
|
1348
|
+
|
|
1349
|
+
JSON is the required response mode. Buffered SSE is available when the client
|
|
1350
|
+
requests `text/event-stream`, but this integration does not provide a
|
|
1351
|
+
long-lived bidirectional stream or incremental Lambda response streaming.
|
|
1352
|
+
Tasks, MRTR, subscriptions and real-time notifications are future extensions.
|
|
@@ -171,6 +171,21 @@ class ApiGatewayResolver(BaseRouter, IApiGatewayResolver):
|
|
|
171
171
|
def include_router(self, router: Router, prefix: str = "") -> None:
|
|
172
172
|
self._router.include_router(router, prefix=prefix)
|
|
173
173
|
|
|
174
|
+
def include_mcp(self, server: Any, *, path: str = "/mcp") -> None:
|
|
175
|
+
"""Mount a transport-neutral MCP server as a normal HTTP route."""
|
|
176
|
+
from modmex_lambda.mcp import MCPServer
|
|
177
|
+
from modmex_lambda.mcp.transport import MCPHttpTransport
|
|
178
|
+
|
|
179
|
+
if not isinstance(server, MCPServer):
|
|
180
|
+
raise TypeError("include_mcp expects an MCPServer")
|
|
181
|
+
|
|
182
|
+
transport = MCPHttpTransport(server)
|
|
183
|
+
|
|
184
|
+
@self.route(path, method="POST", status_code=200)
|
|
185
|
+
def mcp_handler(request: Request) -> Response:
|
|
186
|
+
return transport.handle(request)
|
|
187
|
+
|
|
188
|
+
|
|
174
189
|
def resolve(self, event: dict[str, Any], context: object) -> dict[str, Any]:
|
|
175
190
|
self.current_event = self._to_proxy_event(event)
|
|
176
191
|
self.current_context = context
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""MCP server, protocol, and HTTP transport primitives."""
|
|
2
|
+
|
|
3
|
+
from modmex_lambda.mcp.protocol import (
|
|
4
|
+
MCP_PROTOCOL_VERSION,
|
|
5
|
+
JSONRPCError,
|
|
6
|
+
JSONRPCErrorCode,
|
|
7
|
+
JSONRPCRequest,
|
|
8
|
+
JSONRPCResponse,
|
|
9
|
+
)
|
|
10
|
+
from modmex_lambda.mcp.server import MCPError, MCPServer
|
|
11
|
+
from modmex_lambda.mcp.tool import MCPTool
|
|
12
|
+
from modmex_lambda.mcp.resource import MCPResource
|
|
13
|
+
from modmex_lambda.mcp.prompt import MCPPrompt
|
|
14
|
+
from modmex_lambda.mcp.transport import MCPHttpTransport, SSEEvent, encode_sse, encode_sse_stream, MCP_JSON_CONTENT_TYPE, MCP_SSE_CONTENT_TYPE
|
|
15
|
+
from modmex_lambda.mcp.middleware import MCPContext, MCPMiddleware, MCPNextMiddleware
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"JSONRPCError",
|
|
19
|
+
"JSONRPCErrorCode",
|
|
20
|
+
"MCP_PROTOCOL_VERSION",
|
|
21
|
+
"JSONRPCRequest",
|
|
22
|
+
"JSONRPCResponse",
|
|
23
|
+
"MCPServer",
|
|
24
|
+
"MCPError",
|
|
25
|
+
"MCPHttpTransport",
|
|
26
|
+
"MCPTool",
|
|
27
|
+
"MCPResource",
|
|
28
|
+
"MCPPrompt",
|
|
29
|
+
"SSEEvent",
|
|
30
|
+
"encode_sse",
|
|
31
|
+
"encode_sse_stream",
|
|
32
|
+
"MCP_JSON_CONTENT_TYPE",
|
|
33
|
+
"MCP_SSE_CONTENT_TYPE",
|
|
34
|
+
"MCPContext",
|
|
35
|
+
"MCPMiddleware",
|
|
36
|
+
"MCPNextMiddleware",
|
|
37
|
+
]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Composable middleware for MCP capabilities."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import inspect
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from typing import TYPE_CHECKING, Callable, Protocol, TypeAlias, Union, Any
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from modmex_lambda.event_handler.request import Request
|
|
11
|
+
from modmex_lambda.mcp.server import MCPServer
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
JSONValue: TypeAlias = Union[
|
|
15
|
+
None,
|
|
16
|
+
bool,
|
|
17
|
+
int,
|
|
18
|
+
float,
|
|
19
|
+
str,
|
|
20
|
+
list["JSONValue"],
|
|
21
|
+
dict[str, "JSONValue"],
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class MCPContext:
|
|
27
|
+
request: "Request | None"
|
|
28
|
+
server: "MCPServer | None"
|
|
29
|
+
capability: str
|
|
30
|
+
name: str
|
|
31
|
+
arguments: dict[str, JSONValue]
|
|
32
|
+
state: dict[str, object] = field(default_factory=dict)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class MCPNextMiddleware(Protocol):
|
|
36
|
+
def __call__(self, context: MCPContext) -> object: ...
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class MCPMiddleware(Protocol):
|
|
40
|
+
def __call__(self, context: MCPContext, next_middleware: MCPNextMiddleware) -> object: ...
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def run_middleware(
|
|
44
|
+
middlewares: list[MCPMiddleware],
|
|
45
|
+
context: MCPContext,
|
|
46
|
+
endpoint: Callable[[MCPContext], Any],
|
|
47
|
+
) -> Any:
|
|
48
|
+
next_middleware: MCPNextMiddleware = endpoint
|
|
49
|
+
for middleware in reversed(middlewares):
|
|
50
|
+
current = next_middleware
|
|
51
|
+
next_middleware = lambda ctx, middleware=middleware, current=current: middleware(ctx, current)
|
|
52
|
+
result = next_middleware(context)
|
|
53
|
+
if inspect.isawaitable(result):
|
|
54
|
+
raise RuntimeError("MCP middleware is async; use run_middleware_async")
|
|
55
|
+
return result
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async def run_middleware_async(
|
|
59
|
+
middlewares: list[MCPMiddleware],
|
|
60
|
+
context: MCPContext,
|
|
61
|
+
endpoint: Callable[[MCPContext], Any],
|
|
62
|
+
) -> Any:
|
|
63
|
+
async def invoke(index: int, ctx: MCPContext) -> Any:
|
|
64
|
+
if index == len(middlewares):
|
|
65
|
+
result = endpoint(ctx)
|
|
66
|
+
else:
|
|
67
|
+
middleware = middlewares[index]
|
|
68
|
+
result = middleware(ctx, lambda next_ctx: invoke(index + 1, next_ctx))
|
|
69
|
+
return await result if inspect.isawaitable(result) else result
|
|
70
|
+
return await invoke(0, context)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""MCP prompt registration and invocation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import inspect
|
|
6
|
+
from typing import Any, Callable, get_type_hints
|
|
7
|
+
|
|
8
|
+
from modmex_lambda.mcp.schema import input_schema
|
|
9
|
+
from modmex_lambda.mcp.tool import MCPTool
|
|
10
|
+
from modmex_lambda.mcp.middleware import MCPContext, MCPMiddleware
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MCPPrompt:
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
handler: Callable[..., Any],
|
|
17
|
+
*,
|
|
18
|
+
name: str | None = None,
|
|
19
|
+
description: str | None = None,
|
|
20
|
+
middlewares: list[Any] | None = None,
|
|
21
|
+
) -> None:
|
|
22
|
+
self.name = name or handler.__name__
|
|
23
|
+
self.description = description or inspect.getdoc(handler) or ""
|
|
24
|
+
self.operation = MCPTool(handler, middlewares=middlewares)
|
|
25
|
+
|
|
26
|
+
def definition(self) -> dict[str, Any]:
|
|
27
|
+
schema = input_schema(self.operation.handler)
|
|
28
|
+
required = set(schema.get("required", []))
|
|
29
|
+
properties = schema.get("properties", {})
|
|
30
|
+
return {
|
|
31
|
+
"name": self.name,
|
|
32
|
+
"description": self.description,
|
|
33
|
+
"arguments": [
|
|
34
|
+
{"name": name, "description": str(properties[name].get("description", "")), "required": name in required}
|
|
35
|
+
for name in properties
|
|
36
|
+
],
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def get(self, arguments: dict[str, Any] | None = None, *, context: Any = None, server: Any = None, middlewares: list[MCPMiddleware] | None = None) -> dict[str, Any]:
|
|
40
|
+
values = arguments or {}
|
|
41
|
+
output = self.operation.invoke(values, request=context, middlewares=middlewares, middleware_context=MCPContext(request=context, server=server, capability="prompts", name=self.name, arguments=values))
|
|
42
|
+
if not isinstance(output, list):
|
|
43
|
+
output = [{"role": "user", "content": {"type": "text", "text": str(output)}}]
|
|
44
|
+
return {"messages": output}
|
|
45
|
+
|
|
46
|
+
async def aget(self, arguments: dict[str, Any] | None = None, *, context: Any = None, server: Any = None, middlewares: list[MCPMiddleware] | None = None) -> dict[str, Any]:
|
|
47
|
+
values = arguments or {}
|
|
48
|
+
output = await self.operation.ainvoke(values, request=context, middlewares=middlewares, middleware_context=MCPContext(request=context, server=server, capability="prompts", name=self.name, arguments=values))
|
|
49
|
+
if not isinstance(output, list):
|
|
50
|
+
output = [{"role": "user", "content": {"type": "text", "text": str(output)}}]
|
|
51
|
+
return {"messages": output}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Small, transport-neutral JSON-RPC models used by the MCP server."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from enum import IntEnum
|
|
6
|
+
from typing import Any, Dict, Literal, Optional, Union
|
|
7
|
+
|
|
8
|
+
from modmex import BaseModel
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
JSONRPCVersion = Literal["2.0"]
|
|
12
|
+
JSONRPCId = Optional[Union[str, int]]
|
|
13
|
+
MCP_PROTOCOL_VERSION = "2026-07-28"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class JSONRPCErrorCode(IntEnum):
|
|
17
|
+
PARSE_ERROR = -32700
|
|
18
|
+
INVALID_REQUEST = -32600
|
|
19
|
+
METHOD_NOT_FOUND = -32601
|
|
20
|
+
INVALID_PARAMS = -32602
|
|
21
|
+
INTERNAL_ERROR = -32603
|
|
22
|
+
HEADER_MISMATCH = -32020
|
|
23
|
+
UNSUPPORTED_PROTOCOL_VERSION = -32022
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class JSONRPCRequest(BaseModel):
|
|
27
|
+
jsonrpc: JSONRPCVersion = "2.0"
|
|
28
|
+
id: JSONRPCId = None
|
|
29
|
+
method: str
|
|
30
|
+
params: Optional[Dict[str, Any]] = None
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def metadata(self) -> dict[str, Any]:
|
|
34
|
+
return (self.params or {}).get("_meta", {})
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class JSONRPCError(BaseModel):
|
|
38
|
+
code: int
|
|
39
|
+
message: str
|
|
40
|
+
data: Any = None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class JSONRPCResponse(BaseModel):
|
|
44
|
+
jsonrpc: JSONRPCVersion = "2.0"
|
|
45
|
+
id: JSONRPCId = None
|
|
46
|
+
result: Any = None
|
|
47
|
+
error: Optional[JSONRPCError] = None
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def success(cls, request_id: JSONRPCId, result: Any = None) -> "JSONRPCResponse":
|
|
51
|
+
return cls(id=request_id, result=result)
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def failure(
|
|
55
|
+
cls,
|
|
56
|
+
request_id: JSONRPCId,
|
|
57
|
+
code: int | JSONRPCErrorCode,
|
|
58
|
+
message: str,
|
|
59
|
+
data: Any = None,
|
|
60
|
+
) -> "JSONRPCResponse":
|
|
61
|
+
return cls(
|
|
62
|
+
id=request_id,
|
|
63
|
+
error=JSONRPCError(code=int(code), message=message, data=data),
|
|
64
|
+
)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""Capability registries used by the MCP server."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from modmex_lambda.mcp.tool import MCPTool
|
|
8
|
+
from modmex_lambda.mcp.prompt import MCPPrompt
|
|
9
|
+
from modmex_lambda.mcp.resource import MCPResource
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MCPToolRegistry:
|
|
13
|
+
def __init__(self) -> None:
|
|
14
|
+
self._tools: dict[str, MCPTool] = {}
|
|
15
|
+
|
|
16
|
+
def add(self, tool: MCPTool) -> MCPTool:
|
|
17
|
+
if tool.name in self._tools:
|
|
18
|
+
raise ValueError(f"Duplicate MCP tool: {tool.name}")
|
|
19
|
+
self._tools[tool.name] = tool
|
|
20
|
+
return tool
|
|
21
|
+
|
|
22
|
+
def get(self, name: str) -> MCPTool | None:
|
|
23
|
+
return self._tools.get(name)
|
|
24
|
+
|
|
25
|
+
def definitions(self) -> list[dict[str, Any]]:
|
|
26
|
+
return [tool.definition() for tool in self._tools.values()]
|
|
27
|
+
|
|
28
|
+
def page(self, cursor: str | None = None, *, limit: int = 50) -> tuple[list[dict[str, Any]], str | None]:
|
|
29
|
+
return _page(self.definitions(), cursor, limit)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MCPResourceRegistry:
|
|
33
|
+
def __init__(self) -> None:
|
|
34
|
+
self._resources: list[MCPResource] = []
|
|
35
|
+
|
|
36
|
+
def add(self, resource: MCPResource) -> MCPResource:
|
|
37
|
+
if any(item.uri_template == resource.uri_template for item in self._resources):
|
|
38
|
+
raise ValueError(f"Duplicate MCP resource: {resource.uri_template}")
|
|
39
|
+
self._resources.append(resource)
|
|
40
|
+
return resource
|
|
41
|
+
|
|
42
|
+
def match(self, uri: str) -> tuple[MCPResource, dict[str, str]] | None:
|
|
43
|
+
for resource in self._resources:
|
|
44
|
+
arguments = resource.match(uri)
|
|
45
|
+
if arguments is not None:
|
|
46
|
+
return resource, arguments
|
|
47
|
+
return None
|
|
48
|
+
|
|
49
|
+
def definitions(self) -> list[dict[str, Any]]:
|
|
50
|
+
return [resource.definition() for resource in self._resources if "{" not in resource.uri_template]
|
|
51
|
+
|
|
52
|
+
def templates(self) -> list[dict[str, Any]]:
|
|
53
|
+
return [resource.template_definition() for resource in self._resources if "{" in resource.uri_template]
|
|
54
|
+
|
|
55
|
+
def page(self, cursor: str | None = None, *, templates: bool = False, limit: int = 50) -> tuple[list[dict[str, Any]], str | None]:
|
|
56
|
+
values = self.templates() if templates else self.definitions()
|
|
57
|
+
return _page(values, cursor, limit)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class MCPPromptRegistry:
|
|
61
|
+
def __init__(self) -> None:
|
|
62
|
+
self._prompts: dict[str, MCPPrompt] = {}
|
|
63
|
+
|
|
64
|
+
def add(self, prompt: MCPPrompt) -> MCPPrompt:
|
|
65
|
+
if prompt.name in self._prompts:
|
|
66
|
+
raise ValueError(f"Duplicate MCP prompt: {prompt.name}")
|
|
67
|
+
self._prompts[prompt.name] = prompt
|
|
68
|
+
return prompt
|
|
69
|
+
|
|
70
|
+
def get(self, name: str) -> MCPPrompt | None:
|
|
71
|
+
return self._prompts.get(name)
|
|
72
|
+
|
|
73
|
+
def definitions(self) -> list[dict[str, Any]]:
|
|
74
|
+
return [prompt.definition() for prompt in self._prompts.values()]
|
|
75
|
+
|
|
76
|
+
def page(self, cursor: str | None = None, *, limit: int = 50) -> tuple[list[dict[str, Any]], str | None]:
|
|
77
|
+
return _page(self.definitions(), cursor, limit)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _page(values: list[dict[str, Any]], cursor: str | None, limit: int) -> tuple[list[dict[str, Any]], str | None]:
|
|
81
|
+
if limit <= 0:
|
|
82
|
+
raise ValueError("page size must be positive")
|
|
83
|
+
try:
|
|
84
|
+
start = int(cursor) if cursor is not None else 0
|
|
85
|
+
except (TypeError, ValueError) as exc:
|
|
86
|
+
raise ValueError("invalid pagination cursor") from exc
|
|
87
|
+
if start < 0 or start > len(values):
|
|
88
|
+
raise ValueError("invalid pagination cursor")
|
|
89
|
+
end = min(start + min(limit, 100), len(values))
|
|
90
|
+
return values[start:end], str(end) if end < len(values) else None
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""MCP resource URI templates and invocation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from typing import Any, Callable
|
|
7
|
+
|
|
8
|
+
from modmex_lambda.mcp.tool import MCPTool
|
|
9
|
+
from modmex_lambda.mcp.middleware import MCPContext, MCPMiddleware
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MCPResource:
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
uri_template: str,
|
|
16
|
+
handler: Callable[..., Any],
|
|
17
|
+
*,
|
|
18
|
+
name: str | None = None,
|
|
19
|
+
description: str | None = None,
|
|
20
|
+
mime_type: str = "application/json",
|
|
21
|
+
middlewares: list[Any] | None = None,
|
|
22
|
+
) -> None:
|
|
23
|
+
if not uri_template:
|
|
24
|
+
raise ValueError("MCP resource URI template cannot be empty")
|
|
25
|
+
self.uri_template = uri_template
|
|
26
|
+
self.name = name or uri_template
|
|
27
|
+
self.description = description or ""
|
|
28
|
+
self.mime_type = mime_type
|
|
29
|
+
self.operation = MCPTool(handler, middlewares=middlewares)
|
|
30
|
+
self._names = tuple(re.findall(r"\{([A-Za-z_][A-Za-z0-9_]*)\}", uri_template))
|
|
31
|
+
pattern = re.escape(uri_template)
|
|
32
|
+
for parameter in self._names:
|
|
33
|
+
pattern = pattern.replace("\\{" + parameter + "\\}", rf"(?P<{parameter}>[^/]+)")
|
|
34
|
+
self._pattern = re.compile(rf"^{pattern}$")
|
|
35
|
+
|
|
36
|
+
def match(self, uri: str) -> dict[str, str] | None:
|
|
37
|
+
matched = self._pattern.match(uri)
|
|
38
|
+
return matched.groupdict() if matched else None
|
|
39
|
+
|
|
40
|
+
def definition(self) -> dict[str, Any]:
|
|
41
|
+
return {
|
|
42
|
+
"uri": self.uri_template,
|
|
43
|
+
"name": self.name,
|
|
44
|
+
"description": self.description,
|
|
45
|
+
"mimeType": self.mime_type,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
def template_definition(self) -> dict[str, Any]:
|
|
49
|
+
definition = self.definition()
|
|
50
|
+
definition.pop("uri", None)
|
|
51
|
+
definition["uriTemplate"] = self.uri_template
|
|
52
|
+
return definition
|
|
53
|
+
|
|
54
|
+
def read(self, uri: str, *, context: Any = None, server: Any = None, middlewares: list[MCPMiddleware] | None = None) -> dict[str, Any]:
|
|
55
|
+
arguments = self.match(uri)
|
|
56
|
+
if arguments is None:
|
|
57
|
+
raise ValueError(f"Resource URI does not match: {uri}")
|
|
58
|
+
output = self.operation.invoke(arguments, request=context, middlewares=middlewares, middleware_context=MCPContext(request=context, server=server, capability="resources", name=self.name, arguments=arguments))
|
|
59
|
+
if isinstance(output, bytes):
|
|
60
|
+
import base64
|
|
61
|
+
return {"uri": uri, "mimeType": self.mime_type, "blob": base64.b64encode(output).decode()}
|
|
62
|
+
if isinstance(output, str):
|
|
63
|
+
return {"uri": uri, "mimeType": self.mime_type, "text": output}
|
|
64
|
+
return {"uri": uri, "mimeType": self.mime_type, "text": _json_text(output)}
|
|
65
|
+
|
|
66
|
+
async def aread(self, uri: str, *, context: Any = None, server: Any = None, middlewares: list[MCPMiddleware] | None = None) -> dict[str, Any]:
|
|
67
|
+
arguments = self.match(uri)
|
|
68
|
+
if arguments is None:
|
|
69
|
+
raise ValueError(f"Resource URI does not match: {uri}")
|
|
70
|
+
output = await self.operation.ainvoke(arguments, request=context, middlewares=middlewares, middleware_context=MCPContext(request=context, server=server, capability="resources", name=self.name, arguments=arguments))
|
|
71
|
+
if isinstance(output, bytes):
|
|
72
|
+
import base64
|
|
73
|
+
return {"uri": uri, "mimeType": self.mime_type, "blob": base64.b64encode(output).decode()}
|
|
74
|
+
if isinstance(output, str):
|
|
75
|
+
return {"uri": uri, "mimeType": self.mime_type, "text": output}
|
|
76
|
+
return {"uri": uri, "mimeType": self.mime_type, "text": _json_text(output)}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _json_text(value: Any) -> str:
|
|
80
|
+
import json
|
|
81
|
+
if hasattr(value, "model_dump"):
|
|
82
|
+
value = value.model_dump()
|
|
83
|
+
return json.dumps(value, default=str, separators=(",", ":"))
|