awslabs.openapi-mcp-server 0.1.1__tar.gz → 0.2.0__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.
Files changed (127) hide show
  1. awslabs_openapi_mcp_server-0.2.0/AUTHENTICATION.md +320 -0
  2. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/CHANGELOG.md +17 -18
  3. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/DEPLOYMENT.md +1 -1
  4. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/Dockerfile +36 -24
  5. awslabs_openapi_mcp_server-0.2.0/Dockerlite +73 -0
  6. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/PKG-INFO +36 -36
  7. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/README.md +9 -9
  8. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/__init__.py +1 -1
  9. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/api/config.py +22 -6
  10. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/cognito_auth.py +168 -24
  11. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/server.py +11 -1
  12. awslabs_openapi_mcp_server-0.2.0/docker-healthcheck.sh +25 -0
  13. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/pyproject.toml +27 -27
  14. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/api/test_config.py +3 -15
  15. awslabs_openapi_mcp_server-0.2.0/tests/auth/test_auth_protocol_boost.py +64 -0
  16. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_cognito_auth.py +43 -3
  17. awslabs_openapi_mcp_server-0.2.0/tests/auth/test_cognito_auth_additional_coverage.py +320 -0
  18. awslabs_openapi_mcp_server-0.2.0/tests/auth/test_cognito_auth_boost_coverage.py +259 -0
  19. awslabs_openapi_mcp_server-0.2.0/tests/auth/test_cognito_auth_client_credentials.py +321 -0
  20. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_cognito_auth_coverage_boost.py +7 -6
  21. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_cognito_auth_exceptions.py +6 -0
  22. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_main.py +0 -1
  23. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_main_extended.py +1 -2
  24. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_server.py +1 -1
  25. awslabs_openapi_mcp_server-0.2.0/tests/test_server_coverage_boost_2.py +69 -0
  26. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_server_extended.py +1 -1
  27. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_server_httpx_version.py +1 -1
  28. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_server_part1.py +1 -1
  29. awslabs_openapi_mcp_server-0.2.0/tests/utils/test_error_handler_boost.py +76 -0
  30. awslabs_openapi_mcp_server-0.2.0/uv-requirements.txt +26 -0
  31. awslabs_openapi_mcp_server-0.1.1/.pre-commit-config.yaml +0 -60
  32. awslabs_openapi_mcp_server-0.1.1/AUTHENTICATION.md +0 -204
  33. awslabs_openapi_mcp_server-0.1.1/docker-healthcheck.sh +0 -31
  34. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/.coveragerc +0 -0
  35. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/.dockerignore +0 -0
  36. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/.gitignore +0 -0
  37. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/.python-version +0 -0
  38. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/AWS_BEST_PRACTICES.md +0 -0
  39. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/LICENSE +0 -0
  40. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/NOTICE +0 -0
  41. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/OBSERVABILITY.md +0 -0
  42. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/__init__.py +0 -0
  43. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/api/__init__.py +0 -0
  44. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/__init__.py +0 -0
  45. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/api_key_auth.py +0 -0
  46. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/auth_cache.py +0 -0
  47. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/auth_errors.py +0 -0
  48. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/auth_factory.py +0 -0
  49. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/auth_protocol.py +0 -0
  50. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/auth_provider.py +0 -0
  51. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/base_auth.py +0 -0
  52. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/basic_auth.py +0 -0
  53. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/bearer_auth.py +0 -0
  54. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/auth/register.py +0 -0
  55. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/patch/__init__.py +0 -0
  56. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/prompts/__init__.py +0 -0
  57. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/prompts/generators/__init__.py +0 -0
  58. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/prompts/generators/operation_prompts.py +0 -0
  59. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/prompts/generators/workflow_prompts.py +0 -0
  60. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/prompts/models.py +0 -0
  61. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/prompts/prompt_manager.py +0 -0
  62. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/utils/__init__.py +0 -0
  63. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/utils/cache_provider.py +0 -0
  64. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/utils/config.py +0 -0
  65. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/utils/error_handler.py +0 -0
  66. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/utils/http_client.py +0 -0
  67. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/utils/metrics_provider.py +0 -0
  68. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/utils/openapi.py +0 -0
  69. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/awslabs/openapi_mcp_server/utils/openapi_validator.py +0 -0
  70. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/pyrightconfig.json +0 -0
  71. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/README.md +0 -0
  72. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_api_key_auth.py +0 -0
  73. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_cache.py +0 -0
  74. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_errors.py +0 -0
  75. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_factory.py +0 -0
  76. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_factory_caching.py +0 -0
  77. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_factory_coverage.py +0 -0
  78. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_protocol.py +0 -0
  79. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_protocol_additional.py +0 -0
  80. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_protocol_coverage.py +0 -0
  81. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_protocol_extended.py +0 -0
  82. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_protocol_improved.py +0 -0
  83. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_auth_provider_additional.py +0 -0
  84. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_base_auth.py +0 -0
  85. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_base_auth_coverage.py +0 -0
  86. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_basic_auth.py +0 -0
  87. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_bearer_auth.py +0 -0
  88. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_register.py +0 -0
  89. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/auth/test_register_coverage.py +0 -0
  90. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/standalone/test_operation_prompt.py +0 -0
  91. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/standalone/test_prompt_arguments.py +0 -0
  92. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/standalone/test_secure_operation_prompt.py +0 -0
  93. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/test_mcp_prompt_manager.py +0 -0
  94. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/test_mcp_prompt_manager_integration.py +0 -0
  95. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/test_models_dict_method.py +0 -0
  96. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/test_operation_prompts_extended.py +0 -0
  97. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/test_prompt_manager_additional.py +0 -0
  98. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/test_prompt_manager_comprehensive.py +0 -0
  99. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/test_prompt_manager_coverage.py +0 -0
  100. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/prompts/test_prompt_registration.py +0 -0
  101. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_api_name.py +0 -0
  102. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_cache_coverage_89.py +0 -0
  103. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_client.py +0 -0
  104. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_coverage_boost.py +0 -0
  105. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_init.py +0 -0
  106. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_openapi_coverage_89.py +0 -0
  107. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_server_auth_errors.py +0 -0
  108. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_server_coverage_boost.py +0 -0
  109. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_server_exception_handling.py +0 -0
  110. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_server_route_logging.py +0 -0
  111. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/test_server_signal_handlers.py +0 -0
  112. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_cache_provider.py +0 -0
  113. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_error_handler.py +0 -0
  114. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_error_handler_extended.py +0 -0
  115. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_error_handler_fix.py +0 -0
  116. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_http_client.py +0 -0
  117. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_http_client_comprehensive.py +0 -0
  118. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_http_client_extended.py +0 -0
  119. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_http_client_extended2.py +0 -0
  120. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_http_client_import_error.py +0 -0
  121. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_metrics_provider.py +0 -0
  122. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_metrics_provider_decorators.py +0 -0
  123. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_metrics_provider_extended2.py +0 -0
  124. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_metrics_provider_prometheus.py +0 -0
  125. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_openapi.py +0 -0
  126. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/tests/utils/test_openapi_validator.py +0 -0
  127. {awslabs_openapi_mcp_server-0.1.1 → awslabs_openapi_mcp_server-0.2.0}/uv.lock +0 -0
@@ -0,0 +1,320 @@
1
+ # Authentication for OpenAPI MCP Server
2
+
3
+ [← Back to main README](README.md)
4
+
5
+ ## Mandatory Arguments
6
+
7
+ **IMPORTANT**: Regardless of the authentication method used, the following arguments are always required:
8
+
9
+ - `--api-url`: The base URL of the API (e.g., `https://api.example.com`)
10
+ - One of the following:
11
+ - `--spec-url`: The URL to the OpenAPI specification (e.g., `https://api.example.com/openapi.json`)
12
+ - `--spec-path`: Path to a local OpenAPI specification file (e.g., `./openapi.json`)
13
+
14
+ These arguments must be provided even when using environment variables for authentication settings.
15
+
16
+ ## Supported Authentication Methods
17
+
18
+ The OpenAPI MCP Server supports five authentication methods:
19
+
20
+ | Method | Description | Required Parameters (CLI) | Environment Variables |
21
+ |--------|-------------|---------------------|----------------------|
22
+ | **None** | No authentication (default) | None | None |
23
+ | **Bearer** | Token-based authentication | `--auth-token` | `AUTH_TOKEN` |
24
+ | **Basic** | Username/password authentication | `--auth-username`, `--auth-password` | `AUTH_USERNAME`, `AUTH_PASSWORD` |
25
+ | **API Key** | API key authentication | `--auth-api-key`, `--auth-api-key-name`, `--auth-api-key-in` | `AUTH_API_KEY`, `AUTH_API_KEY_NAME`, `AUTH_API_KEY_IN` |
26
+ | **Cognito** | AWS Cognito User Pool authentication | See below for details | See below for details |
27
+
28
+ ### Cognito Authentication Methods
29
+
30
+ Cognito authentication supports two different flows:
31
+
32
+ | Flow | Description | Required Parameters (CLI) | Environment Variables |
33
+ |------|-------------|---------------------|----------------------|
34
+ | **Password Flow** | Username/password authentication | `--auth-cognito-client-id`, `--auth-cognito-username`, `--auth-cognito-password`, `--auth-cognito-user-pool-id` (optional) | `AUTH_COGNITO_CLIENT_ID`, `AUTH_COGNITO_USERNAME`, `AUTH_COGNITO_PASSWORD`, `AUTH_COGNITO_USER_POOL_ID` (optional) |
35
+ | **Client Credentials Flow** | OAuth 2.0 client credentials flow for service-to-service authentication | `--auth-cognito-client-id`, `--auth-cognito-client-secret`, `--auth-cognito-domain`, `--auth-cognito-scopes` (optional) | `AUTH_COGNITO_CLIENT_ID`, `AUTH_COGNITO_CLIENT_SECRET`, `AUTH_COGNITO_DOMAIN`, `AUTH_COGNITO_SCOPES` (optional) |
36
+
37
+ ## Quick Start Examples
38
+
39
+ ### Bearer Authentication
40
+
41
+ ```bash
42
+ # Command line
43
+ python -m awslabs.openapi_mcp_server.server --auth-type bearer --auth-token "YOUR_TOKEN" --api-url "https://api.example.com"
44
+
45
+ # Environment variables
46
+ export AUTH_TYPE=bearer
47
+ export AUTH_TOKEN="YOUR_TOKEN"
48
+ python -m awslabs.openapi_mcp_server.server
49
+ ```
50
+
51
+ ### Basic Authentication
52
+
53
+ ```bash
54
+ # Command line
55
+ python -m awslabs.openapi_mcp_server.server --auth-type basic --auth-username "user" --auth-password "pass" --api-url "https://api.example.com"
56
+
57
+ # Environment variables
58
+ export AUTH_TYPE=basic
59
+ export AUTH_USERNAME="user"
60
+ export AUTH_PASSWORD="pass"
61
+ python -m awslabs.openapi_mcp_server.server
62
+ ```
63
+
64
+ ### API Key Authentication
65
+
66
+ ```bash
67
+ # Command line
68
+ python -m awslabs.openapi_mcp_server.server --auth-type api_key --auth-api-key "your-key" --auth-api-key-name "X-API-Key" --auth-api-key-in "header"
69
+
70
+ # Environment variables
71
+ export AUTH_TYPE=api_key
72
+ export AUTH_API_KEY="your-key"
73
+ export AUTH_API_KEY_NAME="X-API-Key"
74
+ export AUTH_API_KEY_IN="header" # Options: header, query, cookie
75
+ python -m awslabs.openapi_mcp_server.server
76
+ ```
77
+
78
+ ### Cognito Authentication - Password Flow
79
+
80
+ ```bash
81
+ # Command line
82
+ python -m awslabs.openapi_mcp_server.server --auth-type cognito \
83
+ --auth-cognito-client-id "YOUR_CLIENT_ID" \
84
+ --auth-cognito-username "username" \
85
+ --auth-cognito-password "password" \
86
+ --auth-cognito-user-pool-id "OPTIONAL_POOL_ID" \
87
+ --auth-cognito-region "us-east-1" \
88
+ --api-url "https://api.example.com"
89
+
90
+ # Environment variables
91
+ export AUTH_TYPE=cognito
92
+ export AUTH_COGNITO_CLIENT_ID="YOUR_CLIENT_ID"
93
+ export AUTH_COGNITO_USERNAME="username"
94
+ export AUTH_COGNITO_PASSWORD="password" # Can also be set in system environment
95
+ export AUTH_COGNITO_USER_POOL_ID="OPTIONAL_POOL_ID"
96
+ export AUTH_COGNITO_REGION="us-east-1"
97
+ python -m awslabs.openapi_mcp_server.server
98
+ ```
99
+
100
+ ### Cognito Authentication - OAuth 2.0 Client Credentials Flow
101
+
102
+ ```bash
103
+ # Command line
104
+ python -m awslabs.openapi_mcp_server.server --auth-type cognito \
105
+ --auth-cognito-client-id "YOUR_CLIENT_ID" \
106
+ --auth-cognito-client-secret "YOUR_CLIENT_SECRET" \
107
+ --auth-cognito-domain "your-domain-prefix" \
108
+ --auth-cognito-region "us-east-2" \
109
+ --auth-cognito-scopes "scope1 scope2" \
110
+ --api-url "https://api.example.com"
111
+
112
+ # Environment variables
113
+ export AUTH_TYPE=cognito
114
+ export AUTH_COGNITO_CLIENT_ID="YOUR_CLIENT_ID"
115
+ export AUTH_COGNITO_CLIENT_SECRET="YOUR_CLIENT_SECRET"
116
+ export AUTH_COGNITO_DOMAIN="your-domain-prefix"
117
+ export AUTH_COGNITO_REGION="us-east-2"
118
+ export AUTH_COGNITO_SCOPES="scope1 scope2" # Optional, space-separated list of scopes
119
+ python -m awslabs.openapi_mcp_server.server
120
+ ```
121
+
122
+ ## Important Notes
123
+
124
+ - **Bearer Authentication**: Requires a valid token. The server will exit gracefully with an error message if no token is provided.
125
+ - **Basic Authentication**: Requires both username and password. The server will exit gracefully with an error message if either is missing.
126
+ - **API Key Authentication**: Can be placed in a header (default), query parameter, or cookie.
127
+ - **Cognito Authentication - Password Flow**: Requires client ID, username, and password. The password can be stored in the system environment variable `AUTH_COGNITO_PASSWORD` for security. Tokens are automatically refreshed when they expire.
128
+ - **ID Token Usage**: The Cognito authentication provider uses the **ID Token** for authentication. This is consistent with the AWS CLI approach:
129
+ ```bash
130
+ # Get ID Token from Cognito and use it for authentication
131
+ export AUTH_TOKEN=$(aws cognito-idp initiate-auth \
132
+ --auth-flow USER_PASSWORD_AUTH \
133
+ --client-id $AUTH_COGNITO_CLIENT_ID \
134
+ --auth-parameters USERNAME=$AUTH_COGNITO_USERNAME,PASSWORD=$AUTH_COGNITO_PASSWORD \
135
+ --query 'AuthenticationResult.IdToken' \
136
+ --output text)
137
+ ```
138
+ Support for using the Access Token will be added in a future release.
139
+ - **User Pool ID**: Some Cognito configurations require a User Pool ID. If you encounter authentication errors, try providing the User Pool ID using `--auth-cognito-user-pool-id` or `AUTH_COGNITO_USER_POOL_ID`.
140
+ - **Authentication Flows**: The provider automatically tries different authentication flows (USER_PASSWORD_AUTH and ADMIN_USER_PASSWORD_AUTH) based on your Cognito configuration.
141
+ - **Cognito Authentication - OAuth 2.0 Client Credentials Flow**: Requires client ID, client secret, and domain. The client credentials flow is used for service-to-service authentication and does not require a user.
142
+ - **Domain**: The domain is required for client credentials flow. It's the domain prefix of your Cognito user pool (e.g., if your domain is `https://my-domain.auth.us-east-2.amazoncognito.com`, the domain prefix is `my-domain`).
143
+ - **Scopes**: Scopes are optional. If not provided, the server will use the default scopes configured for the client in Cognito. If provided, they should be a comma-separated list of scopes (e.g., `scope1,scope2`). The server will internally convert these to space-separated format as required by the OAuth 2.0 specification.
144
+ - **Token Type**: The client credentials flow uses the **Access Token** for authentication, not the ID Token.
145
+
146
+ ## OAuth 2.0 and OpenID Connect Support
147
+
148
+ The OpenAPI MCP Server supports OAuth 2.0 and OpenID Connect through the Cognito authentication provider with client credentials flow. This allows for secure service-to-service authentication without requiring a user.
149
+
150
+ ### OAuth 2.0 Client Credentials Flow
151
+
152
+ The client credentials flow is designed for service-to-service authentication where a client application needs to access resources on its own behalf, not on behalf of a user. This flow is ideal for server-side applications that need to authenticate to APIs.
153
+
154
+ #### How It Works
155
+
156
+ 1. The client application authenticates to the authorization server (Cognito) using its client ID and client secret.
157
+ 2. If the credentials are valid, the authorization server returns an access token.
158
+ 3. The client application uses the access token to authenticate to the API.
159
+ 4. The access token is automatically refreshed when it expires.
160
+
161
+ #### Configuration
162
+
163
+ To use the client credentials flow, you need to provide:
164
+
165
+ - **Client ID**: The ID of the client application registered with Cognito.
166
+ - **Client Secret**: The secret key of the client application.
167
+ - **Domain**: The domain prefix of your Cognito user pool.
168
+ - **Region**: The AWS region where your Cognito user pool is located.
169
+ - **Scopes** (optional): The scopes to request for the access token.
170
+
171
+ #### Example
172
+
173
+ ```bash
174
+ export AUTH_TYPE=cognito
175
+ export AUTH_COGNITO_CLIENT_ID="your-client-id"
176
+ export AUTH_COGNITO_CLIENT_SECRET="your-client-secret"
177
+ export AUTH_COGNITO_DOMAIN="your-domain-prefix"
178
+ export AUTH_COGNITO_REGION="us-east-2"
179
+ export AUTH_COGNITO_SCOPES="scope1 scope2" # Optional
180
+ python -m awslabs.openapi_mcp_server.server
181
+ ```
182
+
183
+ ### OpenID Connect Support
184
+
185
+ OpenID Connect is built on top of OAuth 2.0 and adds identity functionality. The client credentials flow in OpenID Connect works the same way as in OAuth 2.0, but with additional identity-related scopes and tokens.
186
+
187
+ To use OpenID Connect features, include OpenID Connect scopes in your scope list:
188
+
189
+ ```bash
190
+ export AUTH_COGNITO_SCOPES="api:read,api:write"
191
+ ```
192
+
193
+ ## Error Handling
194
+
195
+ The server implements graceful shutdown with detailed error messages for authentication failures:
196
+
197
+ 1. **Configuration Errors**: If required authentication parameters are missing, the server will exit with a clear error message indicating what's missing.
198
+ 2. **Authentication Failures**: If authentication fails (e.g., invalid credentials), the server will exit with a detailed error message.
199
+ 3. **Token Refresh**: If token refresh fails, the server will attempt to re-authenticate with the provided credentials.
200
+ 4. **Resource Registration**: If there are issues registering tools or resources, the server will exit with an error message.
201
+
202
+ ## Advanced Configuration
203
+
204
+ ### Authentication Caching
205
+
206
+ The authentication system implements caching to improve performance:
207
+
208
+ - **Provider Caching**: Authentication provider instances are cached based on their configuration
209
+ - **Token Caching**: Authentication tokens and headers are cached with configurable TTL
210
+ - **Cache Control**: Cache can be cleared programmatically when needed
211
+
212
+ ### Custom TTL Configuration
213
+
214
+ You can configure the cache TTL (Time-To-Live) for authentication data:
215
+
216
+ ```bash
217
+ # Set authentication cache TTL to 1 hour (3600 seconds)
218
+ python -m awslabs.openapi_mcp_server.server --auth-type bearer --auth-token "YOUR_TOKEN" --auth-token-ttl 3600
219
+ ```
220
+
221
+ Note: This setting controls how long the server caches authentication headers locally before regenerating them. It does not affect the actual expiration time of the token itself, which is determined by the authentication server that issued the token.
222
+
223
+ ## System Architecture
224
+
225
+ The authentication system follows these design principles:
226
+
227
+ 1. **Template Method Pattern**: Standardized validation and initialization flow
228
+ 2. **Decorator Pattern**: Conditional execution based on configuration validity
229
+ 3. **Factory Pattern**: Dynamic provider creation and caching
230
+ 4. **Error Handling**: Structured error types with detailed information
231
+
232
+ ## Performance Optimizations
233
+
234
+ The authentication system includes several optimizations:
235
+
236
+ - **Selective Provider Registration**: Only registers the authentication provider that will be used
237
+ - **Provider Instance Reuse**: Reduces memory usage and initialization overhead
238
+ - **Authentication Data Caching**: Improves response times for repeated requests
239
+ - **Secure Credential Handling**: Hashes sensitive data for cache keys
240
+ - **Configurable TTL**: Allows fine-tuning cache duration based on security requirements
241
+
242
+ ## Verifying Authentication
243
+
244
+ To verify your authentication configuration is working correctly:
245
+
246
+ 1. Start the server with debug logging enabled:
247
+ ```bash
248
+ python -m awslabs.openapi_mcp_server.server --auth-type your_auth_type [your auth options] --log-level DEBUG
249
+ ```
250
+
251
+ 2. Check the logs for successful authentication messages
252
+
253
+ 3. Make a simple request through your LLM tool to verify API connectivity:
254
+ - For Amazon Q CLI: "Can you list the available endpoints in my API?"
255
+ - For Cline: "Make a simple request to my API to verify authentication is working"
256
+
257
+ If you encounter authentication errors, see the Troubleshooting section below.
258
+
259
+ ## Troubleshooting
260
+
261
+ If you encounter authentication issues:
262
+
263
+ 1. Verify credentials are correct and not expired
264
+ 2. Enable DEBUG logging: `--log-level DEBUG`
265
+ 3. Check server logs for authentication-related error messages
266
+ 4. Ensure the API requires the authentication method you're using
267
+ 5. Check for detailed error information in the logs, including error type and details
268
+
269
+ ### Cognito Authentication Debugging
270
+
271
+ The Cognito authentication provider includes detailed debug logging to help troubleshoot authentication issues:
272
+
273
+ ```
274
+ DEBUG | awslabs.openapi_mcp_server.auth.cognito_auth:__init__:50 - Cognito auth configuration: Username=username, ClientID=client-id, Password=SET, UserPoolID=NOT SET
275
+ ```
276
+
277
+ This log message appears at the DEBUG level during initialization and shows:
278
+
279
+ - **Username**: The Cognito username being used
280
+ - **ClientID**: The Cognito client ID being used
281
+ - **Password**: Whether a password is set (shows "SET" or "NOT SET", never the actual password)
282
+ - **UserPoolID**: Whether a user pool ID is set (shows the ID or "NOT SET")
283
+
284
+ For client credentials flow:
285
+
286
+ ```
287
+ DEBUG | awslabs.openapi_mcp_server.auth.cognito_auth:__init__:50 - Cognito auth configuration: ClientID=client-id, Client Secret=SET, Domain=domain-prefix, Region=us-east-2
288
+ ```
289
+
290
+ To enable these debug logs, run the server with `--log-level DEBUG`:
291
+
292
+ ```bash
293
+ python -m awslabs.openapi_mcp_server.server --auth-type cognito --log-level DEBUG [other options]
294
+ ```
295
+
296
+ Common Cognito authentication issues:
297
+
298
+ 1. **Missing credentials**: Check that all required parameters are set (client ID, username/password or client secret)
299
+ 2. **Invalid credentials**: Verify the credentials are correct in the AWS Cognito console
300
+ 3. **Expired token**: The server will automatically attempt to refresh expired tokens
301
+ 4. **User not confirmed**: Confirm the user in the AWS Cognito console
302
+ 5. **Missing User Pool ID**: Some Cognito configurations require a User Pool ID
303
+ 6. **Invalid domain**: For client credentials flow, ensure the domain prefix is correct
304
+ 7. **Invalid scopes**: For client credentials flow, ensure the requested scopes are allowed for the client
305
+ ## AWS Documentation References
306
+
307
+ ### Bearer Token Authentication
308
+ - [Understanding JSON Web Tokens (JWTs)](https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html)
309
+ - [Using the ID token](https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html#amazon-cognito-user-pools-using-the-id-token)
310
+
311
+ ### Cognito Authentication - Password Flow
312
+ - [User Pool Authentication Flow](https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-authentication-flow.html)
313
+ - [Using the AWS CLI with Cognito User Pools](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/index.html)
314
+ - [Initiating Auth with the AWS CLI](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/initiate-auth.html)
315
+
316
+ ### Cognito Authentication - OAuth 2.0 Client Credentials Flow
317
+ - [Token Endpoint](https://docs.aws.amazon.com/cognito/latest/developerguide/token-endpoint.html)
318
+ - [Using the Client Credentials Grant](https://docs.aws.amazon.com/cognito/latest/developerguide/token-endpoint.html#client-credentials)
319
+ - [Setting up a User Pool App Client](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-client-apps.html)
320
+ - [Resource Server and Scopes](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-define-resource-servers.html)
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.0] - 2025-07-05
9
+
10
+ ### Added
11
+ - OAuth 2.0 and OpenID Connect support through Cognito authentication
12
+ - Client credentials grant flow for service-to-service authentication
13
+ - Cline Marketplace integration support
14
+
15
+ ### Changed
16
+ - Migrated from FastMCP 1.0 to 2.0
17
+ - Updated core dependencies to latest versions
18
+ - Enhanced documentation structure and authentication examples
19
+
20
+ ### Security
21
+ - Updated base image with latest security patches
22
+
8
23
  ## [0.1.0] - 2025-05-15
9
24
 
10
25
  ### Added
@@ -12,32 +27,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
27
  - Support for OpenAPI specifications in JSON and YAML formats
13
28
  - Dynamic generation of MCP tools from OpenAPI endpoints
14
29
  - Intelligent route mapping for GET operations with query parameters
15
- - Maps GET operations with query parameters to TOOLS instead of RESOURCES
16
- - Makes API operations with query parameters easier for LLMs to understand and use
17
- - Improves usability of search and filtering endpoints
18
- - Configurable via the route_patch module
19
30
  - Authentication support for Basic, Bearer Token, and API Key methods
20
31
  - Command line arguments and environment variable configuration
21
32
  - Support for SSE and stdio transports
22
33
  - Dynamic prompt generation based on API structure
23
- - Operation-specific prompts for each API endpoint
24
- - Comprehensive API documentation prompts
25
- - Prompt generation with Prompt.from_function method for FastMCP compatibility
26
34
  - Centralized configuration system for all server settings
27
35
  - Metrics collection and monitoring capabilities
28
- - In-memory metrics provider
29
- - Prometheus integration (optional)
30
- - API call tracking and performance metrics
31
36
  - Caching system with multiple backend options
32
37
  - HTTP client with resilience features and retry logic
33
38
  - Error handling and logging throughout the application
34
39
  - Graceful shutdown mechanism for clean server termination
35
- - Proper handling of SIGINT and SIGTERM signals
36
- - Metrics logging during shutdown
37
- - Integration with uvicorn's graceful shutdown process
38
40
  - Docker configuration with explicit API parameters
39
- - Comprehensive test suite with high code coverage (100% for route_patch.py)
40
- - Detailed documentation:
41
- - README with installation and usage instructions
42
- - Deployment guide with AWS service integration
43
- - AWS best practices implementation
41
+ - Comprehensive test suite with high code coverage
42
+ - Detailed documentation and deployment guides
@@ -64,7 +64,7 @@ You can customize the container behavior using environment variables:
64
64
 
65
65
  # Authentication configuration
66
66
  -e AUTH_TYPE="api_key" \
67
- -e AUTH_API_KEY="YOUR_API_KEY" \ # pragma: allowlist secret
67
+ -e AUTH_API_KEY="YOUR_API_KEY" \
68
68
  -e AUTH_API_KEY_NAME="X-API-Key" \
69
69
  -e AUTH_API_KEY_IN="header" \
70
70
 
@@ -12,7 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- FROM public.ecr.aws/sam/build-python3.10@sha256:04cdbe84bec08d17d621192bc3f0a9e4a85a83f2ac99aa9241659dfac0d845ea AS uv
15
+ # dependabot should continue to update this to the latest hash.
16
+ FROM public.ecr.aws/docker/library/python:3.13.5-alpine3.21@sha256:c9a09c45a4bcc618c7f7128585b8dd0d41d0c31a8a107db4c8255ffe0b69375d AS uv
16
17
 
17
18
  # Install the project into `/app`
18
19
  WORKDIR /app
@@ -30,48 +31,59 @@ ENV UV_PYTHON_PREFERENCE=only-system
30
31
  ENV UV_FROZEN=true
31
32
 
32
33
  # Copy the required files first
33
- COPY pyproject.toml uv.lock ./
34
+ COPY pyproject.toml uv.lock uv-requirements.txt ./
35
+
36
+ # Python optimization and uv configuration
37
+ ENV PIP_NO_CACHE_DIR=1 \
38
+ PIP_DISABLE_PIP_VERSION_CHECK=1
39
+
40
+ # Install system dependencies and Python package manager
41
+ RUN apk update && \
42
+ apk add --no-cache --virtual .build-deps \
43
+ build-base \
44
+ gcc \
45
+ musl-dev \
46
+ libffi-dev \
47
+ openssl-dev \
48
+ cargo && \
49
+ pip install --no-cache-dir uv
34
50
 
35
51
  # Install the project's dependencies using the lockfile and settings
36
52
  RUN --mount=type=cache,target=/root/.cache/uv \
37
- pip install uv && \
38
- uv sync --frozen --no-install-project --no-dev --no-editable
53
+ pip install --require-hashes --requirement uv-requirements.txt --no-cache-dir && \
54
+ uv sync --python 3.13 --frozen --no-install-project --no-dev --no-editable
39
55
 
40
56
  # Then, add the rest of the project source code and install it
41
57
  # Installing separately from its dependencies allows optimal layer caching
42
58
  COPY . /app
43
59
  RUN --mount=type=cache,target=/root/.cache/uv \
44
- uv sync --frozen --no-dev --no-editable
60
+ uv sync --python 3.13 --frozen --no-dev --no-editable
45
61
 
46
62
  # Make the directory just in case it doesn't exist
47
63
  RUN mkdir -p /root/.local
48
64
 
49
- FROM public.ecr.aws/sam/build-python3.10@sha256:04cdbe84bec08d17d621192bc3f0a9e4a85a83f2ac99aa9241659dfac0d845ea
65
+ FROM public.ecr.aws/docker/library/python:3.13.5-alpine3.21@sha256:c9a09c45a4bcc618c7f7128585b8dd0d41d0c31a8a107db4c8255ffe0b69375d
50
66
 
51
67
  # Place executables in the environment at the front of the path and include other binaries
52
- ENV PATH="/app/.venv/bin:$PATH:/usr/sbin"
53
-
54
- # Install lsof for the healthcheck
55
- # Install other tools as needed for the MCP server
56
- # Add non-root user and ability to change directory into /root
57
- RUN yum update -y && \
58
- yum install -y lsof && \
59
- yum clean all -y && \
60
- rm -rf /var/cache/yum && \
61
- groupadd --force --system app && \
62
- useradd app -g app -d /app && \
63
- chmod o+x /root
64
-
65
- # Get the project from the uv layer
66
- COPY --from=uv --chown=app:app /root/.local /root/.local
68
+ ENV PATH="/app/.venv/bin:$PATH" \
69
+ PYTHONUNBUFFERED=1
70
+
71
+ # Install runtime dependencies and create application user
72
+ RUN apk update && \
73
+ apk add --no-cache ca-certificates && \
74
+ update-ca-certificates && \
75
+ addgroup -S app && \
76
+ adduser -S app -G app -h /app
77
+
78
+ # Copy application artifacts from build stage
67
79
  COPY --from=uv --chown=app:app /app/.venv /app/.venv
68
80
 
69
81
  # Get healthcheck script
70
82
  COPY ./docker-healthcheck.sh /usr/local/bin/docker-healthcheck.sh
71
- RUN chmod +x /usr/local/bin/docker-healthcheck.sh
72
83
 
73
84
  # Run as non-root
74
85
  USER app
75
86
 
76
- HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "docker-healthcheck.sh" ]
77
- ENTRYPOINT ["python", "-m", "awslabs.openapi_mcp_server.server"]
87
+ # When running the container, add --db-path and a bind mount to the host's db file
88
+ HEALTHCHECK --interval=60s --timeout=10s --start-period=10s --retries=3 CMD ["docker-healthcheck.sh"]
89
+ ENTRYPOINT ["awslabs.openapi-mcp-server"]
@@ -0,0 +1,73 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Stage 1: Build dependencies
16
+ FROM public.ecr.aws/docker/library/python:3.13.5-alpine3.21 AS builder
17
+
18
+ ENV PYTHONDONTWRITEBYTECODE=1 \
19
+ PYTHONUNBUFFERED=1 \
20
+ PIP_NO_CACHE_DIR=1 \
21
+ PIP_DISABLE_PIP_VERSION_CHECK=1
22
+
23
+ # Install build dependencies using virtual package for easy cleanup
24
+ RUN apk update && \
25
+ apk add --no-cache --virtual .build-deps \
26
+ build-base \
27
+ gcc \
28
+ musl-dev \
29
+ libffi-dev \
30
+ openssl-dev \
31
+ cargo
32
+
33
+ WORKDIR /app
34
+
35
+ # Copy and install in single layer for better caching
36
+ COPY pyproject.toml uv.lock README.md LICENSE NOTICE ./
37
+ COPY awslabs ./awslabs
38
+ RUN pip install --no-cache-dir --target /opt/venv . && \
39
+ # Remove unnecessary files to reduce image size
40
+ find /opt/venv -name '*.pyc' -delete && \
41
+ find /opt/venv -name '__pycache__' -delete
42
+
43
+ # Stage 2: Runtime image
44
+ FROM public.ecr.aws/docker/library/python:3.13.5-alpine3.21
45
+
46
+ ENV PYTHONDONTWRITEBYTECODE=1 \
47
+ PYTHONUNBUFFERED=1 \
48
+ PYTHONPATH=/opt/venv \
49
+ PATH="/opt/venv/bin:$PATH" \
50
+ PYTHONWARNINGS="ignore"
51
+
52
+ # Install runtime dependencies and create user in single layer
53
+ RUN apk update && \
54
+ apk add --no-cache ca-certificates && \
55
+ update-ca-certificates && \
56
+ addgroup -S app && \
57
+ adduser -S app -G app -h /app
58
+
59
+ # Copy application files
60
+ COPY --from=builder --chown=app:app /opt/venv /opt/venv
61
+ COPY --from=builder --chown=app:app /app/awslabs /app/awslabs
62
+ COPY --chown=app:app ./docker-healthcheck.sh /usr/local/bin/docker-healthcheck.sh
63
+ RUN chmod +x /usr/local/bin/docker-healthcheck.sh
64
+
65
+ USER app
66
+ WORKDIR /app
67
+
68
+ # Optimize healthcheck intervals for better performance
69
+ HEALTHCHECK --interval=60s --timeout=10s --start-period=10s --retries=3 \
70
+ CMD ["docker-healthcheck.sh"]
71
+
72
+ # Use exec form for better signal handling
73
+ ENTRYPOINT ["python", "-m", "awslabs.openapi_mcp_server.server"]