konokenj.cdk-api-mcp-server 0.0.1__py3-none-any.whl

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.

Potentially problematic release.


This version of konokenj.cdk-api-mcp-server might be problematic. Click here for more details.

@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2025-present Kenji Kono <konoken@amazon.co.jp>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ __version__ = "0.0.1"
@@ -0,0 +1,7 @@
1
+ # SPDX-FileCopyrightText: 2025-present Kenji Kono <konoken@amazon.co.jp>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ from .__about__ import __version__
6
+
7
+ __all__ = ["__version__"]
@@ -0,0 +1 @@
1
+ """Core module for CDK API MCP server."""
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env python3
2
+ """AWS CDK API MCP resource handlers."""
3
+
4
+ import logging
5
+ import os
6
+ from pathlib import Path
7
+ from typing import Optional
8
+
9
+
10
+ # Set up logging
11
+ logger = logging.getLogger(__name__)
12
+
13
+
14
+ # Define resource directories
15
+ DOCS_DIR = Path(__file__).parent.parent / "resources" / "aws-cdk" / "docs"
16
+ INTEG_TESTS_DIR = Path(__file__).parent.parent / "resources" / "aws-cdk" / "integ-tests"
17
+
18
+
19
+ async def get_cdk_api_docs(category: str, package_name: str, module_name: str, file_path: str) -> str:
20
+ """Get AWS CDK API documentation from the resources directory.
21
+
22
+ This resource handler serves documentation files from the resources/aws-cdk/docs directory.
23
+ The files are organized by category, package and module.
24
+
25
+ Example URIs:
26
+ - cdk-api-docs://packages/@aws-cdk/aws-s3/README.md
27
+ - cdk-api-docs://packages/aws-cdk-lib/aws-lambda/README.md
28
+ - cdk-api-docs://root/DEPRECATED_APIs.md
29
+
30
+ Args:
31
+ category: The category (e.g., 'packages', 'root')
32
+ package_name: The package name (e.g., '@aws-cdk', 'aws-cdk-lib')
33
+ module_name: The module name (e.g., 'aws-s3', 'aws-lambda')
34
+ file_path: The file path within the module (e.g., 'README.md')
35
+
36
+ Returns:
37
+ String containing the requested documentation
38
+ """
39
+ # Handle special case for root files like DEPRECATED_APIs.md
40
+ if category == "root":
41
+ file_path = os.path.join(DOCS_DIR, package_name)
42
+ if os.path.exists(file_path):
43
+ with open(file_path, 'r', encoding='utf-8') as f:
44
+ return f.read()
45
+ else:
46
+ return f"Error: File '{package_name}' not found"
47
+
48
+ # For packages category, construct the file path
49
+ if category == "packages":
50
+ if file_path:
51
+ file_path = os.path.join(DOCS_DIR, category, package_name, module_name, file_path)
52
+ else:
53
+ file_path = os.path.join(DOCS_DIR, category, package_name, module_name)
54
+ else:
55
+ # For other categories, construct the path accordingly
56
+ if file_path:
57
+ file_path = os.path.join(DOCS_DIR, category, package_name, module_name, file_path)
58
+ else:
59
+ file_path = os.path.join(DOCS_DIR, category, package_name, module_name)
60
+
61
+ # Check if the file exists
62
+ if os.path.exists(file_path):
63
+ # If it's a directory, list the contents
64
+ if os.path.isdir(file_path):
65
+ files = os.listdir(file_path)
66
+ result = f"# Contents of {package_name}/{module_name}\n\n"
67
+ for f in sorted(files):
68
+ if os.path.isdir(os.path.join(file_path, f)):
69
+ result += f"- [{f}/](cdk-api-docs://{category}/{package_name}/{module_name}/{f})\n"
70
+ else:
71
+ result += f"- [{f}](cdk-api-docs://{category}/{package_name}/{module_name}/{f})\n"
72
+ return result
73
+ # If it's a file, return the contents
74
+ else:
75
+ with open(file_path, 'r', encoding='utf-8') as f:
76
+ return f.read()
77
+ else:
78
+ return f"Error: File '{file_path}' not found"
79
+
80
+
81
+ async def get_cdk_api_integ_tests(module_name: str, file_path: Optional[str] = None) -> str:
82
+ """Get AWS CDK integration test examples from the resources directory.
83
+
84
+ This resource handler serves integration test files from the resources/aws-cdk/integ-tests directory.
85
+ The files are organized by module.
86
+
87
+ Example URIs:
88
+ - cdk-api-integ-tests://aws-s3/aws-s3.test1.md
89
+ - cdk-api-integ-tests://aws-lambda/aws-lambda.handler.md
90
+
91
+ Args:
92
+ module_name: The module name (e.g., 'aws-s3', 'aws-lambda')
93
+ file_path: The file path within the module (e.g., 'aws-s3.test1.md')
94
+
95
+ Returns:
96
+ String containing the requested integration test example
97
+ """
98
+ # Construct the file path
99
+ if file_path:
100
+ file_path = os.path.join(INTEG_TESTS_DIR, module_name, file_path)
101
+ else:
102
+ file_path = os.path.join(INTEG_TESTS_DIR, module_name)
103
+
104
+ # Check if the file exists
105
+ if os.path.exists(file_path):
106
+ # If it's a directory, list the contents
107
+ if os.path.isdir(file_path):
108
+ files = os.listdir(file_path)
109
+ result = f"# Integration Tests for {module_name}\n\n"
110
+ for f in sorted(files):
111
+ if os.path.isdir(os.path.join(file_path, f)):
112
+ result += f"- [{f}/](cdk-api-integ-tests://{module_name}/{f})\n"
113
+ else:
114
+ result += f"- [{f}](cdk-api-integ-tests://{module_name}/{f})\n"
115
+ return result
116
+ # If it's a file, return the contents
117
+ else:
118
+ with open(file_path, 'r', encoding='utf-8') as f:
119
+ return f.read()
120
+ else:
121
+ return f"Error: File '{file_path}' not found"
@@ -0,0 +1,255 @@
1
+ #!/usr/bin/env python3
2
+ """AWS CDK API MCP server implementation."""
3
+
4
+ import logging
5
+ import os
6
+ import json
7
+ from pathlib import Path
8
+ from cdk_api_mcp_server.core import resources
9
+ from fastmcp import FastMCP
10
+ from fastmcp.resources import TextResource, DirectoryResource
11
+
12
+
13
+ # Set up logging
14
+ logger = logging.getLogger(__name__)
15
+
16
+
17
+ # Define resource directories
18
+ DOCS_DIR = Path(__file__).parent.parent / "resources" / "aws-cdk" / "docs"
19
+ INTEG_TESTS_DIR = Path(__file__).parent.parent / "resources" / "aws-cdk" / "integ-tests"
20
+
21
+
22
+ # Create MCP server
23
+ mcp = FastMCP(
24
+ 'AWS CDK API MCP Server',
25
+ dependencies=[],
26
+ )
27
+
28
+
29
+ # Register resource templates for hierarchical navigation
30
+ @mcp.resource('cdk-api-docs://')
31
+ async def list_root_categories():
32
+ """List all available categories in the CDK API documentation."""
33
+ if not DOCS_DIR.exists():
34
+ return {"error": "Documentation directory not found"}
35
+
36
+ categories = []
37
+ # Add root category
38
+ categories.append({
39
+ "name": "root",
40
+ "uri": "cdk-api-docs://root/",
41
+ "description": "Root level documentation files",
42
+ "is_directory": True
43
+ })
44
+
45
+ # Add packages category if it exists
46
+ packages_dir = DOCS_DIR / "packages"
47
+ if packages_dir.exists() and packages_dir.is_dir():
48
+ categories.append({
49
+ "name": "packages",
50
+ "uri": "cdk-api-docs://packages/",
51
+ "description": "AWS CDK packages documentation",
52
+ "is_directory": True
53
+ })
54
+
55
+ return json.dumps({"categories": categories})
56
+
57
+
58
+ @mcp.resource('cdk-api-docs://root/')
59
+ def list_root_files():
60
+ """List all files in the root directory of the CDK API documentation."""
61
+ if not DOCS_DIR.exists():
62
+ return {"error": "Documentation directory not found"}
63
+
64
+ files = []
65
+ for item in DOCS_DIR.iterdir():
66
+ if item.is_file():
67
+ files.append({
68
+ "name": item.name,
69
+ "uri": f"cdk-api-docs://root/{item.name}",
70
+ "is_directory": False
71
+ })
72
+ elif item.is_dir() and item.name != "packages": # Skip packages dir as it's handled separately
73
+ files.append({
74
+ "name": item.name,
75
+ "uri": f"cdk-api-docs://root/{item.name}/",
76
+ "is_directory": True
77
+ })
78
+
79
+ return json.dumps({"files": files})
80
+
81
+
82
+ @mcp.resource('cdk-api-docs://root/{file_name}')
83
+ def get_root_file(file_name: str):
84
+ """Get a file from the root directory of the CDK API documentation."""
85
+ file_path = DOCS_DIR / file_name
86
+
87
+ if not file_path.exists() or not file_path.is_file():
88
+ return f"Error: File '{file_name}' not found"
89
+
90
+ # Read the file content
91
+ with open(file_path, 'r', encoding='utf-8') as f:
92
+ content = f.read()
93
+
94
+ # Create and return a TextResource
95
+ return TextResource(
96
+ uri=f"cdk-api-docs://root/{file_name}",
97
+ name=file_name,
98
+ text=content,
99
+ description=f"Root documentation file: {file_name}",
100
+ mime_type="text/markdown" if file_name.endswith(".md") else "text/plain"
101
+ )
102
+
103
+
104
+ @mcp.resource('cdk-api-docs://packages/')
105
+ def list_packages():
106
+ """List all packages in the CDK API documentation."""
107
+ packages_dir = DOCS_DIR / "packages"
108
+
109
+ if not packages_dir.exists() or not packages_dir.is_dir():
110
+ return {"error": "Packages directory not found"}
111
+
112
+ packages = []
113
+ for item in packages_dir.iterdir():
114
+ if item.is_dir():
115
+ packages.append({
116
+ "name": item.name,
117
+ "uri": f"cdk-api-docs://packages/{item.name}/",
118
+ "is_directory": True
119
+ })
120
+
121
+ return json.dumps({"packages": packages})
122
+
123
+
124
+ @mcp.resource('cdk-api-docs://packages/{package_name}/')
125
+ def list_package_modules(package_name: str):
126
+ """List all modules in a specific package."""
127
+ package_dir = DOCS_DIR / "packages" / package_name
128
+
129
+ if not package_dir.exists() or not package_dir.is_dir():
130
+ return {"error": f"Package '{package_name}' not found"}
131
+
132
+ modules = []
133
+ for item in package_dir.iterdir():
134
+ if item.is_dir():
135
+ modules.append({
136
+ "name": item.name,
137
+ "uri": f"cdk-api-docs://packages/{package_name}/{item.name}/",
138
+ "is_directory": True
139
+ })
140
+ elif item.is_file():
141
+ modules.append({
142
+ "name": item.name,
143
+ "uri": f"cdk-api-docs://packages/{package_name}/{item.name}",
144
+ "is_directory": False
145
+ })
146
+
147
+ return json.dumps({"modules": modules})
148
+
149
+
150
+ @mcp.resource('cdk-api-docs://packages/{package_name}/{module_name}/')
151
+ def list_module_files(package_name: str, module_name: str):
152
+ """List all files in a specific module."""
153
+ module_dir = DOCS_DIR / "packages" / package_name / module_name
154
+
155
+ if not module_dir.exists() or not module_dir.is_dir():
156
+ return {"error": f"Module '{module_name}' not found in package '{package_name}'"}
157
+
158
+ # ここでのみDirectoryResourceを使用
159
+ return DirectoryResource(
160
+ uri=f"cdk-api-docs://packages/{package_name}/{module_name}/",
161
+ name=f"Files in {package_name}/{module_name}",
162
+ path=module_dir,
163
+ description=f"List of files in the {package_name}/{module_name} module",
164
+ recursive=False
165
+ )
166
+
167
+
168
+ @mcp.resource('cdk-api-docs://packages/{package_name}/{module_name}/{file_path}')
169
+ def get_module_file(package_name: str, module_name: str, file_path: str):
170
+ """Get a specific file from a module."""
171
+ file_full_path = DOCS_DIR / "packages" / package_name / module_name / file_path
172
+
173
+ if not file_full_path.exists() or not file_full_path.is_file():
174
+ return f"Error: File '{file_path}' not found in {package_name}/{module_name}"
175
+
176
+ # Read the file content
177
+ with open(file_full_path, 'r', encoding='utf-8') as f:
178
+ content = f.read()
179
+
180
+ # Create and return a TextResource
181
+ return TextResource(
182
+ uri=f"cdk-api-docs://packages/{package_name}/{module_name}/{file_path}",
183
+ name=file_path,
184
+ text=content,
185
+ description=f"Documentation file: {file_path} in {package_name}/{module_name}",
186
+ mime_type="text/markdown" if file_path.endswith(".md") else "text/plain"
187
+ )
188
+
189
+
190
+ # Register integration tests resources
191
+ @mcp.resource('cdk-api-integ-tests://')
192
+ def list_integ_test_modules():
193
+ """List all modules with integration tests."""
194
+ if not INTEG_TESTS_DIR.exists():
195
+ return {"error": "Integration tests directory not found"}
196
+
197
+ modules = []
198
+ for item in INTEG_TESTS_DIR.iterdir():
199
+ if item.is_dir():
200
+ modules.append({
201
+ "name": item.name,
202
+ "uri": f"cdk-api-integ-tests://{item.name}/",
203
+ "is_directory": True
204
+ })
205
+
206
+ return json.dumps({"modules": modules})
207
+
208
+
209
+ @mcp.resource('cdk-api-integ-tests://{module_name}/')
210
+ def list_module_tests(module_name: str):
211
+ """List all integration tests for a specific module."""
212
+ module_dir = INTEG_TESTS_DIR / module_name
213
+
214
+ if not module_dir.exists() or not module_dir.is_dir():
215
+ return {"error": f"Module '{module_name}' not found in integration tests"}
216
+
217
+ # ここでのみDirectoryResourceを使用
218
+ return DirectoryResource(
219
+ uri=f"cdk-api-integ-tests://{module_name}/",
220
+ name=f"Integration tests for {module_name}",
221
+ path=module_dir,
222
+ description=f"List of integration tests for the {module_name} module",
223
+ recursive=False
224
+ )
225
+
226
+
227
+ @mcp.resource('cdk-api-integ-tests://{module_name}/{file_path}')
228
+ def get_module_test(module_name: str, file_path: str):
229
+ """Get a specific integration test file."""
230
+ file_full_path = INTEG_TESTS_DIR / module_name / file_path
231
+
232
+ if not file_full_path.exists() or not file_full_path.is_file():
233
+ return f"Error: Integration test '{file_path}' not found for module '{module_name}'"
234
+
235
+ # Read the file content
236
+ with open(file_full_path, 'r', encoding='utf-8') as f:
237
+ content = f.read()
238
+
239
+ # Create and return a TextResource
240
+ return TextResource(
241
+ uri=f"cdk-api-integ-tests://{module_name}/{file_path}",
242
+ name=file_path,
243
+ text=content,
244
+ description=f"Integration test: {file_path} for {module_name}",
245
+ mime_type="text/markdown" if file_path.endswith(".md") else "text/plain"
246
+ )
247
+
248
+
249
+ def main():
250
+ """Run the MCP server with CLI argument support."""
251
+ mcp.run()
252
+
253
+
254
+ if __name__ == '__main__':
255
+ main()
File without changes
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python3
2
+ """AWS CDK API MCP server implementation."""
3
+
4
+ from cdk_api_mcp_server.core.server import main
5
+
6
+
7
+ if __name__ == '__main__':
8
+ main()
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: konokenj.cdk-api-mcp-server
3
+ Version: 0.0.1
4
+ Summary: An MCP server provides AWS CDK API Reference
5
+ Project-URL: Documentation, https://github.com/konokenj/cdk-api-mcp-server#readme
6
+ Project-URL: Issues, https://github.com/konokenj/cdk-api-mcp-server/issues
7
+ Project-URL: Source, https://github.com/konokenj/cdk-api-mcp-server
8
+ Author-email: Kenji Kono <konoken@amazon.co.jp>
9
+ License-Expression: MIT
10
+ License-File: LICENSE.txt
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
20
+ Requires-Python: >=3.8
21
+ Requires-Dist: fastmcp>=2.0.0
22
+ Requires-Dist: pydantic>=2.10.6
23
+ Description-Content-Type: text/markdown
24
+
25
+ # cdk-api-mcp-server
26
+
27
+ [![PyPI - Version](https://img.shields.io/pypi/v/cdk-api-mcp-server.svg)](https://pypi.org/project/cdk-api-mcp-server)
28
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cdk-api-mcp-server.svg)](https://pypi.org/project/cdk-api-mcp-server)
29
+
30
+ -----
31
+
32
+ ## Table of Contents
33
+
34
+ - [Installation](#installation)
35
+ - [License](#license)
36
+
37
+ ## Installation
38
+
39
+ ```console
40
+ pip install cdk-api-mcp-server
41
+ ```
42
+
43
+ ## License
44
+
45
+ `cdk-api-mcp-server` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,12 @@
1
+ cdk_api_mcp_server/__about__.py,sha256=YDFhVrJ6IAPLvkmnNQeYbddiqs-wE-itcAwTO84Lt2U,128
2
+ cdk_api_mcp_server/__init__.py,sha256=NEvU-xodn9HlOjf2mMHp_TfU-_2UkrV6zJRJSy5vt74,169
3
+ cdk_api_mcp_server/server.py,sha256=XAG7UI1_Uy0F5Ff9qoL2z3FhLt5C9he39oHjhEYPhc4,157
4
+ cdk_api_mcp_server/core/__init__.py,sha256=vDq0hUSCu3Tfj4EJyp5p40Ak5W68S4y_NkN5Z3pKAkA,42
5
+ cdk_api_mcp_server/core/resources.py,sha256=yG0MPNAIYmnXioV3lSI3T1QkeelX5l83MddsbzKCZvs,4723
6
+ cdk_api_mcp_server/core/server.py,sha256=KgCycgr7Yxnx4JeZHIk7oG1pz7YaXc1TOva9CclM5B4,8513
7
+ cdk_api_mcp_server/resources/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ konokenj_cdk_api_mcp_server-0.0.1.dist-info/METADATA,sha256=y6E_ViH9EUcZMI0kvT7xz7grYG78aURNGUzGX1Aefr4,1601
9
+ konokenj_cdk_api_mcp_server-0.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ konokenj_cdk_api_mcp_server-0.0.1.dist-info/entry_points.txt,sha256=bVDhMdyCC1WNMPOMbmB82jvWII2CIrwTZDygdCf0cYQ,79
11
+ konokenj_cdk_api_mcp_server-0.0.1.dist-info/licenses/LICENSE.txt,sha256=5OIAASeg1HM22mVZ1enz9bgZ7TlsGfWXnj02P9OgFyk,1098
12
+ konokenj_cdk_api_mcp_server-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ konokenj.cdk-api-mcp-server = cdk_api_mcp_server.server:main
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Kenji Kono <konoken@amazon.co.jp>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.