konokenj.cdk-api-mcp-server 0.0.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.
- konokenj_cdk_api_mcp_server-0.0.1/.gitignore +264 -0
- konokenj_cdk_api_mcp_server-0.0.1/LICENSE.txt +9 -0
- konokenj_cdk_api_mcp_server-0.0.1/PKG-INFO +45 -0
- konokenj_cdk_api_mcp_server-0.0.1/README.md +21 -0
- konokenj_cdk_api_mcp_server-0.0.1/cdk_api_mcp_server/__about__.py +4 -0
- konokenj_cdk_api_mcp_server-0.0.1/cdk_api_mcp_server/__init__.py +7 -0
- konokenj_cdk_api_mcp_server-0.0.1/cdk_api_mcp_server/core/__init__.py +1 -0
- konokenj_cdk_api_mcp_server-0.0.1/cdk_api_mcp_server/core/resources.py +121 -0
- konokenj_cdk_api_mcp_server-0.0.1/cdk_api_mcp_server/core/server.py +255 -0
- konokenj_cdk_api_mcp_server-0.0.1/cdk_api_mcp_server/resources/.gitkeep +0 -0
- konokenj_cdk_api_mcp_server-0.0.1/cdk_api_mcp_server/server.py +8 -0
- konokenj_cdk_api_mcp_server-0.0.1/pyproject.toml +109 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# Abstra
|
|
171
|
+
# Abstra is an AI-powered process automation framework.
|
|
172
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
173
|
+
# Learn more at https://abstra.io/docs
|
|
174
|
+
.abstra/
|
|
175
|
+
|
|
176
|
+
# Visual Studio Code
|
|
177
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
178
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
179
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
180
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
181
|
+
# .vscode/
|
|
182
|
+
|
|
183
|
+
# Ruff stuff:
|
|
184
|
+
.ruff_cache/
|
|
185
|
+
|
|
186
|
+
# PyPI configuration file
|
|
187
|
+
.pypirc
|
|
188
|
+
|
|
189
|
+
# Cursor
|
|
190
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
191
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
192
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
193
|
+
.cursorignore
|
|
194
|
+
.cursorindexingignore
|
|
195
|
+
.vscode/*
|
|
196
|
+
!.vscode/settings.json
|
|
197
|
+
!.vscode/tasks.json
|
|
198
|
+
!.vscode/launch.json
|
|
199
|
+
!.vscode/extensions.json
|
|
200
|
+
!.vscode/*.code-snippets
|
|
201
|
+
|
|
202
|
+
# Local History for Visual Studio Code
|
|
203
|
+
.history/
|
|
204
|
+
|
|
205
|
+
# Built Visual Studio Code Extensions
|
|
206
|
+
*.vsix
|
|
207
|
+
|
|
208
|
+
# General
|
|
209
|
+
.DS_Store
|
|
210
|
+
.AppleDouble
|
|
211
|
+
.LSOverride
|
|
212
|
+
Icon[
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
# Thumbnails
|
|
216
|
+
._*
|
|
217
|
+
|
|
218
|
+
# Files that might appear in the root of a volume
|
|
219
|
+
.DocumentRevisions-V100
|
|
220
|
+
.fseventsd
|
|
221
|
+
.Spotlight-V100
|
|
222
|
+
.TemporaryItems
|
|
223
|
+
.Trashes
|
|
224
|
+
.VolumeIcon.icns
|
|
225
|
+
.com.apple.timemachine.donotpresent
|
|
226
|
+
|
|
227
|
+
# Directories potentially created on remote AFP share
|
|
228
|
+
.AppleDB
|
|
229
|
+
.AppleDesktop
|
|
230
|
+
Network Trash Folder
|
|
231
|
+
Temporary Items
|
|
232
|
+
.apdisk
|
|
233
|
+
|
|
234
|
+
# Windows thumbnail cache files
|
|
235
|
+
Thumbs.db
|
|
236
|
+
Thumbs.db:encryptable
|
|
237
|
+
ehthumbs.db
|
|
238
|
+
ehthumbs_vista.db
|
|
239
|
+
|
|
240
|
+
# Dump file
|
|
241
|
+
*.stackdump
|
|
242
|
+
|
|
243
|
+
# Folder config file
|
|
244
|
+
[Dd]esktop.ini
|
|
245
|
+
|
|
246
|
+
# Recycle Bin used on file shares
|
|
247
|
+
$RECYCLE.BIN/
|
|
248
|
+
|
|
249
|
+
# Windows Installer files
|
|
250
|
+
*.cab
|
|
251
|
+
*.msi
|
|
252
|
+
*.msix
|
|
253
|
+
*.msm
|
|
254
|
+
*.msp
|
|
255
|
+
|
|
256
|
+
# Windows shortcuts
|
|
257
|
+
*.lnk
|
|
258
|
+
|
|
259
|
+
.work/
|
|
260
|
+
.ai-work/
|
|
261
|
+
|
|
262
|
+
# Generated resources
|
|
263
|
+
cdk_api_mcp_server/resources/*
|
|
264
|
+
!cdk_api_mcp_server/resources/.gitkeep
|
|
@@ -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.
|
|
@@ -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
|
+
[](https://pypi.org/project/cdk-api-mcp-server)
|
|
28
|
+
[](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,21 @@
|
|
|
1
|
+
# cdk-api-mcp-server
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/cdk-api-mcp-server)
|
|
4
|
+
[](https://pypi.org/project/cdk-api-mcp-server)
|
|
5
|
+
|
|
6
|
+
-----
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [License](#license)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```console
|
|
16
|
+
pip install cdk-api-mcp-server
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
`cdk-api-mcp-server` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
|
@@ -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,109 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "konokenj.cdk-api-mcp-server"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = 'An MCP server provides AWS CDK API Reference'
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
keywords = []
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Kenji Kono", email = "konoken@amazon.co.jp" },
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3.8",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
25
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"fastmcp>=2.0.0",
|
|
29
|
+
"pydantic>=2.10.6",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Documentation = "https://github.com/konokenj/cdk-api-mcp-server#readme"
|
|
34
|
+
Issues = "https://github.com/konokenj/cdk-api-mcp-server/issues"
|
|
35
|
+
Source = "https://github.com/konokenj/cdk-api-mcp-server"
|
|
36
|
+
|
|
37
|
+
[project.scripts]
|
|
38
|
+
"konokenj.cdk-api-mcp-server" = "cdk_api_mcp_server.server:main"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.version]
|
|
41
|
+
path = "cdk_api_mcp_server/__about__.py"
|
|
42
|
+
|
|
43
|
+
[tool.hatch.envs.default.scripts]
|
|
44
|
+
server = 'python cdk_api_mcp_server/server.py'
|
|
45
|
+
dev = 'npx @modelcontextprotocol/inspector hatch run python cdk_api_mcp_server/server.py'
|
|
46
|
+
|
|
47
|
+
[tool.hatch.envs.dev]
|
|
48
|
+
extra-dependencies = [
|
|
49
|
+
"mypy>=1.0.0",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[tool.hatch.envs.dev.scripts]
|
|
53
|
+
check = "mypy --install-types --non-interactive {args:cdk_api_mcp_server tests}"
|
|
54
|
+
|
|
55
|
+
[tool.hatch.envs.downloader]
|
|
56
|
+
dependencies = ["PyGithub", "semantic-version"]
|
|
57
|
+
|
|
58
|
+
[tool.hatch.envs.downloader.scripts]
|
|
59
|
+
download = "python cdk_api_downloader/main.py"
|
|
60
|
+
download-force = "python cdk_api_downloader/main.py --force"
|
|
61
|
+
|
|
62
|
+
[tool.hatch.envs.test]
|
|
63
|
+
dependencies = [
|
|
64
|
+
"fastmcp>=2.0.0",
|
|
65
|
+
"pydantic>=2.10.6",
|
|
66
|
+
"pytest",
|
|
67
|
+
"pytest-cov",
|
|
68
|
+
"pytest-mock",
|
|
69
|
+
"pytest-asyncio",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[tool.hatch.envs.test.scripts]
|
|
73
|
+
test = "pytest {args:tests}"
|
|
74
|
+
test-cov = "pytest --cov {args:tests}"
|
|
75
|
+
|
|
76
|
+
[tool.hatch.build.targets.sdist]
|
|
77
|
+
include = [
|
|
78
|
+
"cdk_api_mcp_server/**/*.py",
|
|
79
|
+
"cdk_api_mcp_server/resources/**/*"
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
[tool.hatch.build.targets.wheel]
|
|
83
|
+
packages = ["cdk_api_mcp_server"]
|
|
84
|
+
|
|
85
|
+
[tool.coverage.run]
|
|
86
|
+
source_pkgs = ["cdk_api_mcp_server", "cdk_api_downloader", "tests"]
|
|
87
|
+
branch = true
|
|
88
|
+
parallel = true
|
|
89
|
+
omit = [
|
|
90
|
+
"cdk_api_mcp_server/__about__.py",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
[tool.coverage.paths]
|
|
94
|
+
cdk_api_mcp_server = ["cdk_api_mcp_server", "*/cdk-api-mcp-server/cdk_api_mcp_server"]
|
|
95
|
+
cdk_api_downloader = ["cdk_api_downloader", "*/cdk-api-mcp-server/cdk_api_downloader"]
|
|
96
|
+
tests = ["tests", "*/cdk-api-mcp-server/tests"]
|
|
97
|
+
|
|
98
|
+
[tool.coverage.report]
|
|
99
|
+
exclude_lines = [
|
|
100
|
+
"no cov",
|
|
101
|
+
"if __name__ == .__main__.:",
|
|
102
|
+
"if TYPE_CHECKING:",
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
[tool.pytest.ini_options]
|
|
106
|
+
asyncio_mode = "auto"
|
|
107
|
+
markers = [
|
|
108
|
+
"asyncio: mark test as an asyncio coroutine",
|
|
109
|
+
]
|