awslabs.openapi-mcp-server 0.1.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.
Files changed (117) hide show
  1. awslabs_openapi_mcp_server-0.1.1/.coveragerc +51 -0
  2. awslabs_openapi_mcp_server-0.1.1/.dockerignore +49 -0
  3. awslabs_openapi_mcp_server-0.1.1/.gitignore +80 -0
  4. awslabs_openapi_mcp_server-0.1.1/.pre-commit-config.yaml +60 -0
  5. awslabs_openapi_mcp_server-0.1.1/.python-version +1 -0
  6. awslabs_openapi_mcp_server-0.1.1/AUTHENTICATION.md +204 -0
  7. awslabs_openapi_mcp_server-0.1.1/AWS_BEST_PRACTICES.md +258 -0
  8. awslabs_openapi_mcp_server-0.1.1/CHANGELOG.md +43 -0
  9. awslabs_openapi_mcp_server-0.1.1/DEPLOYMENT.md +405 -0
  10. awslabs_openapi_mcp_server-0.1.1/Dockerfile +77 -0
  11. awslabs_openapi_mcp_server-0.1.1/LICENSE +175 -0
  12. awslabs_openapi_mcp_server-0.1.1/NOTICE +2 -0
  13. awslabs_openapi_mcp_server-0.1.1/OBSERVABILITY.md +194 -0
  14. awslabs_openapi_mcp_server-0.1.1/PKG-INFO +418 -0
  15. awslabs_openapi_mcp_server-0.1.1/README.md +359 -0
  16. awslabs_openapi_mcp_server-0.1.1/awslabs/__init__.py +16 -0
  17. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/__init__.py +69 -0
  18. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/api/__init__.py +18 -0
  19. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/api/config.py +200 -0
  20. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/__init__.py +27 -0
  21. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/api_key_auth.py +185 -0
  22. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/auth_cache.py +190 -0
  23. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/auth_errors.py +206 -0
  24. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/auth_factory.py +146 -0
  25. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/auth_protocol.py +63 -0
  26. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/auth_provider.py +160 -0
  27. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/base_auth.py +218 -0
  28. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/basic_auth.py +171 -0
  29. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/bearer_auth.py +108 -0
  30. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/cognito_auth.py +538 -0
  31. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/auth/register.py +100 -0
  32. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/patch/__init__.py +17 -0
  33. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/prompts/__init__.py +18 -0
  34. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/prompts/generators/__init__.py +22 -0
  35. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/prompts/generators/operation_prompts.py +642 -0
  36. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/prompts/generators/workflow_prompts.py +257 -0
  37. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/prompts/models.py +70 -0
  38. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/prompts/prompt_manager.py +150 -0
  39. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/server.py +511 -0
  40. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/utils/__init__.py +18 -0
  41. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/utils/cache_provider.py +249 -0
  42. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/utils/config.py +35 -0
  43. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/utils/error_handler.py +349 -0
  44. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/utils/http_client.py +263 -0
  45. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/utils/metrics_provider.py +503 -0
  46. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/utils/openapi.py +217 -0
  47. awslabs_openapi_mcp_server-0.1.1/awslabs/openapi_mcp_server/utils/openapi_validator.py +253 -0
  48. awslabs_openapi_mcp_server-0.1.1/docker-healthcheck.sh +31 -0
  49. awslabs_openapi_mcp_server-0.1.1/pyproject.toml +159 -0
  50. awslabs_openapi_mcp_server-0.1.1/pyrightconfig.json +72 -0
  51. awslabs_openapi_mcp_server-0.1.1/tests/README.md +102 -0
  52. awslabs_openapi_mcp_server-0.1.1/tests/api/test_config.py +235 -0
  53. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_api_key_auth.py +221 -0
  54. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_cache.py +219 -0
  55. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_errors.py +111 -0
  56. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_factory.py +141 -0
  57. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_factory_caching.py +112 -0
  58. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_factory_coverage.py +88 -0
  59. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_protocol.py +91 -0
  60. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_protocol_additional.py +45 -0
  61. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_protocol_coverage.py +80 -0
  62. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_protocol_extended.py +164 -0
  63. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_protocol_improved.py +27 -0
  64. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_auth_provider_additional.py +26 -0
  65. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_base_auth.py +132 -0
  66. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_base_auth_coverage.py +110 -0
  67. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_basic_auth.py +187 -0
  68. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_bearer_auth.py +172 -0
  69. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_cognito_auth.py +590 -0
  70. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_cognito_auth_coverage_boost.py +194 -0
  71. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_cognito_auth_exceptions.py +303 -0
  72. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_register.py +146 -0
  73. awslabs_openapi_mcp_server-0.1.1/tests/auth/test_register_coverage.py +61 -0
  74. awslabs_openapi_mcp_server-0.1.1/tests/prompts/standalone/test_operation_prompt.py +178 -0
  75. awslabs_openapi_mcp_server-0.1.1/tests/prompts/standalone/test_prompt_arguments.py +210 -0
  76. awslabs_openapi_mcp_server-0.1.1/tests/prompts/standalone/test_secure_operation_prompt.py +340 -0
  77. awslabs_openapi_mcp_server-0.1.1/tests/prompts/test_mcp_prompt_manager.py +511 -0
  78. awslabs_openapi_mcp_server-0.1.1/tests/prompts/test_mcp_prompt_manager_integration.py +252 -0
  79. awslabs_openapi_mcp_server-0.1.1/tests/prompts/test_models_dict_method.py +68 -0
  80. awslabs_openapi_mcp_server-0.1.1/tests/prompts/test_operation_prompts_extended.py +277 -0
  81. awslabs_openapi_mcp_server-0.1.1/tests/prompts/test_prompt_manager_additional.py +92 -0
  82. awslabs_openapi_mcp_server-0.1.1/tests/prompts/test_prompt_manager_comprehensive.py +217 -0
  83. awslabs_openapi_mcp_server-0.1.1/tests/prompts/test_prompt_manager_coverage.py +160 -0
  84. awslabs_openapi_mcp_server-0.1.1/tests/prompts/test_prompt_registration.py +166 -0
  85. awslabs_openapi_mcp_server-0.1.1/tests/test_api_name.py +171 -0
  86. awslabs_openapi_mcp_server-0.1.1/tests/test_cache_coverage_89.py +139 -0
  87. awslabs_openapi_mcp_server-0.1.1/tests/test_client.py +115 -0
  88. awslabs_openapi_mcp_server-0.1.1/tests/test_coverage_boost.py +193 -0
  89. awslabs_openapi_mcp_server-0.1.1/tests/test_init.py +127 -0
  90. awslabs_openapi_mcp_server-0.1.1/tests/test_main.py +48 -0
  91. awslabs_openapi_mcp_server-0.1.1/tests/test_main_extended.py +208 -0
  92. awslabs_openapi_mcp_server-0.1.1/tests/test_openapi_coverage_89.py +149 -0
  93. awslabs_openapi_mcp_server-0.1.1/tests/test_server.py +179 -0
  94. awslabs_openapi_mcp_server-0.1.1/tests/test_server_auth_errors.py +136 -0
  95. awslabs_openapi_mcp_server-0.1.1/tests/test_server_coverage_boost.py +56 -0
  96. awslabs_openapi_mcp_server-0.1.1/tests/test_server_exception_handling.py +112 -0
  97. awslabs_openapi_mcp_server-0.1.1/tests/test_server_extended.py +195 -0
  98. awslabs_openapi_mcp_server-0.1.1/tests/test_server_httpx_version.py +85 -0
  99. awslabs_openapi_mcp_server-0.1.1/tests/test_server_part1.py +179 -0
  100. awslabs_openapi_mcp_server-0.1.1/tests/test_server_route_logging.py +166 -0
  101. awslabs_openapi_mcp_server-0.1.1/tests/test_server_signal_handlers.py +171 -0
  102. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_cache_provider.py +160 -0
  103. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_error_handler.py +171 -0
  104. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_error_handler_extended.py +300 -0
  105. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_error_handler_fix.py +153 -0
  106. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_http_client.py +166 -0
  107. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_http_client_comprehensive.py +176 -0
  108. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_http_client_extended.py +243 -0
  109. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_http_client_extended2.py +76 -0
  110. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_http_client_import_error.py +117 -0
  111. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_metrics_provider.py +308 -0
  112. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_metrics_provider_decorators.py +134 -0
  113. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_metrics_provider_extended2.py +244 -0
  114. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_metrics_provider_prometheus.py +180 -0
  115. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_openapi.py +142 -0
  116. awslabs_openapi_mcp_server-0.1.1/tests/utils/test_openapi_validator.py +627 -0
  117. awslabs_openapi_mcp_server-0.1.1/uv.lock +1753 -0
@@ -0,0 +1,51 @@
1
+ [run]
2
+ branch = True
3
+ parallel = True
4
+ source = awslabs
5
+ # Skip coverage for license headers to prevent line shift issues
6
+ skip_covered = False
7
+ skip_empty = True
8
+
9
+ [report]
10
+ exclude_lines =
11
+ pragma: no cover
12
+ def __repr__
13
+ raise NotImplementedError
14
+ if __name__ == .__main__.:
15
+ pass
16
+ raise ImportError
17
+ except ImportError:
18
+ # License header exclusions - comprehensive patterns to handle line shifts
19
+ ^\s*#\s*Copyright
20
+ ^\s*#\s*Licensed under
21
+ ^\s*#\s*limitations under the License
22
+ ^\s*#\s*Copyright Amazon\.com
23
+ ^\s*#\s*Licensed under the Apache License
24
+ ^\s*#\s*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
25
+ ^\s*#\s*See the License for the specific language governing permissions
26
+ ^\s*#\s*and limitations under the License
27
+ ^\s*#\s*$
28
+ ^\s*#\s*http://www\.apache\.org/licenses/LICENSE-2\.0
29
+ ^\s*#\s*Unless required by applicable law
30
+ ^\s*#\s*distributed under the License is distributed
31
+ ^\s*#\s*either express or implied
32
+ response.raise_for_status()
33
+
34
+ # Exclude test files and environments from coverage calculation
35
+ omit =
36
+ */test-env/*
37
+ */tests/*
38
+ */__pycache__/*
39
+
40
+ [paths]
41
+ source =
42
+ awslabs/
43
+ */site-packages/awslabs/
44
+
45
+ # Handle line mapping for files with license headers
46
+ [html]
47
+ skip_covered = False
48
+ skip_empty = True
49
+
50
+ [xml]
51
+ skip_empty = True
@@ -0,0 +1,49 @@
1
+ # Git
2
+ .git
3
+ .github
4
+ .gitignore
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+ *.so
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+
28
+ # Testing
29
+ .pytest_cache/
30
+ .coverage
31
+ htmlcov/
32
+ .tox/
33
+
34
+ # Environment
35
+ .env
36
+ .venv
37
+ env/
38
+ venv/
39
+ ENV/
40
+
41
+ # IDE
42
+ .idea/
43
+ .vscode/
44
+ *.swp
45
+ *.swo
46
+
47
+ # Project specific
48
+ docker-compose.yml
49
+ .ruff_cache/
@@ -0,0 +1,80 @@
1
+ Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ share/python-wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+ MANIFEST
24
+
25
+ # Virtual environments
26
+ .venv
27
+ .venv/
28
+ env/
29
+ venv/
30
+ ENV/
31
+ test-env/
32
+ .test-env/
33
+
34
+ # IDE
35
+ .idea/
36
+ .vscode/
37
+ *.swp
38
+ *.swo
39
+
40
+ # Testing
41
+ .tox/
42
+ .coverage
43
+ .coverage.*
44
+ htmlcov/
45
+ .pytest_cache/
46
+
47
+ # Ruff
48
+ .ruff_cache/
49
+
50
+ # Build
51
+ *.manifest
52
+ *.spec
53
+ .pybuilder/
54
+ target/
55
+
56
+ # Environments
57
+ .env
58
+ .env.local
59
+ .env.*.local
60
+
61
+ # PyPI
62
+ .pypirc
63
+
64
+ # Project specific files
65
+ # Functional test logs
66
+ petstore_test_*.log
67
+ server_output.tmp
68
+ server_log.txt
69
+ server_pid.txt
70
+ *.tmp
71
+ test-docker*.sh
72
+
73
+ # mkdocs
74
+ site/
75
+ .venv/
76
+
77
+ # Temp files
78
+ *.bak
79
+ *~
80
+ .DS_Store
@@ -0,0 +1,60 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: check-added-large-files
6
+ - id: check-case-conflict
7
+ - id: check-executables-have-shebangs
8
+ - id: check-illegal-windows-names
9
+ - id: check-json
10
+ - id: check-merge-conflict
11
+ - id: check-shebang-scripts-are-executable
12
+ - id: check-symlinks
13
+ - id: check-toml
14
+ - id: check-xml
15
+ # Full check against all YAML files excluding mkdocs.yml
16
+ - id: check-yaml
17
+ name: check non-mkdocs yaml
18
+ exclude: mkdocs.yml
19
+ # Unsafe check against mkdocs.yml specifically to allow the necessary
20
+ # custom tags to render Mermaid diagrams.
21
+ - id: check-yaml
22
+ name: check mkdocs yaml
23
+ files: mkdocs.yml
24
+ args:
25
+ # https://github.com/pre-commit/pre-commit-hooks/issues/701
26
+ # Necessary so that non-standard tags do not throw failures.
27
+ - '--unsafe'
28
+ - id: end-of-file-fixer
29
+ - id: debug-statements
30
+ - id: destroyed-symlinks
31
+ - id: detect-private-key
32
+ - id: detect-aws-credentials
33
+ args: [ --allow-missing-credentials ]
34
+ - id: forbid-submodules
35
+ - id: pretty-format-json
36
+ - id: trailing-whitespace
37
+
38
+ - repo: https://github.com/astral-sh/ruff-pre-commit
39
+ rev: v0.11.4
40
+ hooks:
41
+ - id: ruff
42
+ args: [ --fix ]
43
+ - id: ruff-format
44
+
45
+ - repo: https://github.com/Yelp/detect-secrets
46
+ rev: v1.5.0
47
+ hooks:
48
+ - id: detect-secrets
49
+ args: ['--baseline', '.secrets.baseline']
50
+
51
+ - repo: local
52
+ hooks:
53
+ - id: check-license-header
54
+ name: check license header
55
+ pass_filenames: false
56
+ language: system
57
+ entry: npm
58
+ args: [
59
+ 'exec', '--',
60
+ 'github:viperproject/check-license-header#v1', 'check', '--config', './.github/workflows/check-license-header.json']
@@ -0,0 +1 @@
1
+ 3.10
@@ -0,0 +1,204 @@
1
+ # Authentication for OpenAPI MCP Server
2
+
3
+ [← Back to main README](README.md)
4
+
5
+ ## Supported Authentication Methods
6
+
7
+ The OpenAPI MCP Server supports five authentication methods:
8
+
9
+ | Method | Description | Required Parameters |
10
+ |--------|-------------|---------------------|
11
+ | **None** | No authentication (default) | None |
12
+ | **Bearer** | Token-based authentication | `--auth-token` |
13
+ | **Basic** | Username/password authentication | `--auth-username`, `--auth-password` |
14
+ | **API Key** | API key authentication | `--auth-api-key`, `--auth-api-key-name`, `--auth-api-key-in` |
15
+ | **Cognito** | AWS Cognito User Pool authentication | `--auth-cognito-client-id`, `--auth-cognito-username`, `--auth-cognito-password`, `--auth-cognito-user-pool-id` (optional) |
16
+
17
+ ## Quick Start Examples
18
+
19
+ ### Bearer Authentication
20
+
21
+ ```bash
22
+ # Command line
23
+ python -m awslabs.openapi_mcp_server.server --auth-type bearer --auth-token "YOUR_TOKEN" --api-url "https://api.example.com"
24
+
25
+ # Environment variables
26
+ export AUTH_TYPE=bearer
27
+ export AUTH_TOKEN="YOUR_TOKEN"
28
+ python -m awslabs.openapi_mcp_server.server
29
+ ```
30
+
31
+ ### Basic Authentication
32
+
33
+ ```bash
34
+ # Command line
35
+ python -m awslabs.openapi_mcp_server.server --auth-type basic --auth-username "user" --auth-password "pass" --api-url "https://api.example.com"
36
+
37
+ # Environment variables
38
+ export AUTH_TYPE=basic
39
+ export AUTH_USERNAME="user"
40
+ export AUTH_PASSWORD="pass"
41
+ python -m awslabs.openapi_mcp_server.server
42
+ ```
43
+
44
+ ### API Key Authentication
45
+
46
+ ```bash
47
+ # Command line
48
+ 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"
49
+
50
+ # Environment variables
51
+ export AUTH_TYPE=api_key
52
+ export AUTH_API_KEY="your-key"
53
+ export AUTH_API_KEY_NAME="X-API-Key"
54
+ export AUTH_API_KEY_IN="header" # Options: header, query, cookie
55
+ ```
56
+
57
+ ### Cognito Authentication
58
+
59
+ ```bash
60
+ # Command line
61
+ python -m awslabs.openapi_mcp_server.server --auth-type cognito \
62
+ --auth-cognito-client-id "YOUR_CLIENT_ID" \
63
+ --auth-cognito-username "username" \
64
+ --auth-cognito-password "password" \
65
+ --auth-cognito-user-pool-id "OPTIONAL_POOL_ID" \
66
+ --auth-cognito-region "us-east-1" \
67
+ --api-url "https://api.example.com"
68
+
69
+ # Environment variables
70
+ export AUTH_TYPE=cognito
71
+ export AUTH_COGNITO_CLIENT_ID="YOUR_CLIENT_ID"
72
+ export AUTH_COGNITO_USERNAME="username"
73
+ export AUTH_COGNITO_PASSWORD="password" # Can also be set in system environment
74
+ export AUTH_COGNITO_USER_POOL_ID="OPTIONAL_POOL_ID"
75
+ export AUTH_COGNITO_REGION="us-east-1"
76
+ python -m awslabs.openapi_mcp_server.server
77
+ ```
78
+
79
+ ## Important Notes
80
+
81
+ - **Bearer Authentication**: Requires a valid token. The server will exit gracefully with an error message if no token is provided.
82
+ - **Basic Authentication**: Requires both username and password. The server will exit gracefully with an error message if either is missing.
83
+ - **API Key Authentication**: Can be placed in a header (default), query parameter, or cookie.
84
+ - **Cognito Authentication**: 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.
85
+ - **ID Token Usage**: The Cognito authentication provider uses the **ID Token** for authentication. This is consistent with the AWS CLI approach:
86
+ ```bash
87
+ # Get ID Token from Cognito and use it for authentication
88
+ export AUTH_TOKEN=$(aws cognito-idp initiate-auth \
89
+ --auth-flow USER_PASSWORD_AUTH \
90
+ --client-id $AUTH_COGNITO_CLIENT_ID \
91
+ --auth-parameters USERNAME=$AUTH_COGNITO_USERNAME,PASSWORD=$AUTH_COGNITO_PASSWORD \
92
+ --query 'AuthenticationResult.IdToken' \
93
+ --output text)
94
+ ```
95
+ Support for using the Access Token will be added in a future release.
96
+ - **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`.
97
+ - **Authentication Flows**: The provider automatically tries different authentication flows (USER_PASSWORD_AUTH and ADMIN_USER_PASSWORD_AUTH) based on your Cognito configuration.
98
+
99
+ ## Error Handling
100
+
101
+ The server implements graceful shutdown with detailed error messages for authentication failures:
102
+
103
+ 1. **Configuration Errors**: If required authentication parameters are missing, the server will exit with a clear error message indicating what's missing.
104
+ 2. **Authentication Failures**: If authentication fails (e.g., invalid credentials), the server will exit with a detailed error message.
105
+ 3. **Token Refresh**: If token refresh fails, the server will attempt to re-authenticate with the provided credentials.
106
+ 4. **Resource Registration**: If there are issues registering tools or resources, the server will exit with an error message.
107
+
108
+ ## Advanced Configuration
109
+
110
+ ### Authentication Caching
111
+
112
+ The authentication system implements caching to improve performance:
113
+
114
+ - **Provider Caching**: Authentication provider instances are cached based on their configuration
115
+ - **Token Caching**: Authentication tokens and headers are cached with configurable TTL
116
+ - **Cache Control**: Cache can be cleared programmatically when needed
117
+
118
+ ### Custom TTL Configuration
119
+
120
+ You can configure the TTL (Time-To-Live) for authentication tokens:
121
+
122
+ ```bash
123
+ # Set token TTL to 1 hour (3600 seconds)
124
+ python -m awslabs.openapi_mcp_server.server --auth-type bearer --auth-token "YOUR_TOKEN" --auth-token-ttl 3600
125
+ ```
126
+
127
+ ## System Architecture
128
+
129
+ The authentication system follows these design principles:
130
+
131
+ 1. **Template Method Pattern**: Standardized validation and initialization flow
132
+ 2. **Decorator Pattern**: Conditional execution based on configuration validity
133
+ 3. **Factory Pattern**: Dynamic provider creation and caching
134
+ 4. **Error Handling**: Structured error types with detailed information
135
+
136
+ ## Performance Optimizations
137
+
138
+ The authentication system includes several optimizations:
139
+
140
+ - **Selective Provider Registration**: Only registers the authentication provider that will be used
141
+ - **Provider Instance Reuse**: Reduces memory usage and initialization overhead
142
+ - **Authentication Data Caching**: Improves response times for repeated requests
143
+ - **Secure Credential Handling**: Hashes sensitive data for cache keys
144
+ - **Configurable TTL**: Allows fine-tuning cache duration based on security requirements
145
+
146
+ ## Testing
147
+
148
+ Test scripts are provided for authentication providers:
149
+
150
+ ```bash
151
+ # Test Bearer authentication
152
+ python test_bearer_auth.py
153
+
154
+ # Test Basic authentication
155
+ python test_basic_auth.py
156
+
157
+ # Test API Key authentication
158
+ python test_api_key_auth.py
159
+
160
+ # Test Cognito authentication
161
+ python test_cognito_auth.py --client-id "YOUR_CLIENT_ID" --username "username" --password "password" --user-pool-id "OPTIONAL_POOL_ID" --region "us-east-1"
162
+
163
+ # Run all authentication tests
164
+ python -m pytest tests/auth/
165
+ ```
166
+
167
+ ## Troubleshooting
168
+
169
+ If you encounter authentication issues:
170
+
171
+ 1. Verify credentials are correct and not expired
172
+ 2. Enable DEBUG logging: `--log-level DEBUG`
173
+ 3. Check server logs for authentication-related error messages
174
+ 4. Ensure the API requires the authentication method you're using
175
+ 5. Check for detailed error information in the logs, including error type and details
176
+
177
+ ### Cognito Authentication Debugging
178
+
179
+ The Cognito authentication provider includes detailed debug logging to help troubleshoot authentication issues:
180
+
181
+ ```
182
+ DEBUG | awslabs.openapi_mcp_server.auth.cognito_auth:__init__:50 - Cognito auth configuration: Username=username, ClientID=client-id, Password=SET, UserPoolID=NOT SET
183
+ ```
184
+
185
+ This log message appears at the DEBUG level during initialization and shows:
186
+
187
+ - **Username**: The Cognito username being used
188
+ - **ClientID**: The Cognito client ID being used
189
+ - **Password**: Whether a password is set (shows "SET" or "NOT SET", never the actual password)
190
+ - **UserPoolID**: Whether a user pool ID is set (shows the ID or "NOT SET")
191
+
192
+ To enable these debug logs, run the server with `--log-level DEBUG`:
193
+
194
+ ```bash
195
+ python -m awslabs.openapi_mcp_server.server --auth-type cognito --log-level DEBUG [other options]
196
+ ```
197
+
198
+ Common Cognito authentication issues:
199
+
200
+ 1. **Missing credentials**: Check that all required parameters are set (client ID, username, password)
201
+ 2. **Invalid credentials**: Verify the credentials are correct in the AWS Cognito console
202
+ 3. **Expired token**: The server will automatically attempt to refresh expired tokens
203
+ 4. **User not confirmed**: Confirm the user in the AWS Cognito console
204
+ 5. **Missing User Pool ID**: Some Cognito configurations require a User Pool ID