awslabs.amazon-keyspaces-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.
- awslabs_amazon_keyspaces_mcp_server-0.0.1/.gitignore +64 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/.python-version +1 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/CHANGELOG.md +24 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/LICENSE +175 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/NOTICE +2 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/PKG-INFO +223 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/README.md +193 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/awslabs/__init__.py +16 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/awslabs/amazon_keyspaces_mcp_server/__init__.py +17 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/awslabs/amazon_keyspaces_mcp_server/client.py +430 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/awslabs/amazon_keyspaces_mcp_server/config.py +69 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/awslabs/amazon_keyspaces_mcp_server/consts.py +52 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/awslabs/amazon_keyspaces_mcp_server/llm_context.py +270 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/awslabs/amazon_keyspaces_mcp_server/models.py +71 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/awslabs/amazon_keyspaces_mcp_server/server.py +432 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/awslabs/amazon_keyspaces_mcp_server/services.py +389 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/pyproject.toml +137 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/run_tests.sh +39 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/tests/__init__.py +13 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/tests/test_client.py +585 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/tests/test_init.py +49 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/tests/test_main.py +55 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/tests/test_query_analysis_service.py +346 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/tests/test_server.py +578 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/tests/test_services.py +177 -0
- awslabs_amazon_keyspaces_mcp_server-0.0.1/uv.lock +1087 -0
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
# Certificate files
|
|
26
|
+
awslabs/certs/
|
|
27
|
+
awslabs/certs/*
|
|
28
|
+
!awslabs/certs/.gitkeep
|
|
29
|
+
|
|
30
|
+
# Virtual environments
|
|
31
|
+
.venv
|
|
32
|
+
env/
|
|
33
|
+
venv/
|
|
34
|
+
ENV/
|
|
35
|
+
|
|
36
|
+
# IDE
|
|
37
|
+
.idea/
|
|
38
|
+
.vscode/
|
|
39
|
+
*.swp
|
|
40
|
+
*.swo
|
|
41
|
+
|
|
42
|
+
# Testing
|
|
43
|
+
.tox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
htmlcov/
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
|
|
49
|
+
# Ruff
|
|
50
|
+
.ruff_cache/
|
|
51
|
+
|
|
52
|
+
# Build
|
|
53
|
+
*.manifest
|
|
54
|
+
*.spec
|
|
55
|
+
.pybuilder/
|
|
56
|
+
target/
|
|
57
|
+
|
|
58
|
+
# Environments
|
|
59
|
+
.env
|
|
60
|
+
.env.local
|
|
61
|
+
.env.*.local
|
|
62
|
+
|
|
63
|
+
# PyPI
|
|
64
|
+
.pypirc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.10
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## Unreleased
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial project setup
|
|
13
|
+
# Changelog
|
|
14
|
+
|
|
15
|
+
All notable changes to this project will be documented in this file.
|
|
16
|
+
|
|
17
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
18
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
19
|
+
|
|
20
|
+
## Unreleased
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Initial project setup
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: awslabs.amazon-keyspaces-mcp-server
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: An Amazon Keyspaces (for Apache Cassandra) MCP server for interacting with Amazon Keyspaces and Apache Cassandra.
|
|
5
|
+
Project-URL: homepage, https://awslabs.github.io/mcp/
|
|
6
|
+
Project-URL: docs, https://awslabs.github.io/mcp/servers/amazon-keyspaces-mcp-server/
|
|
7
|
+
Project-URL: documentation, https://awslabs.github.io/mcp/servers/amazon-keyspaces-mcp-server/
|
|
8
|
+
Project-URL: repository, https://github.com/awslabs/mcp.git
|
|
9
|
+
Project-URL: changelog, https://github.com/awslabs/mcp/blob/main/src/amazon-keyspaces-mcp-server/CHANGELOG.md
|
|
10
|
+
Author: Amazon Web Services
|
|
11
|
+
Author-email: AWSLabs MCP <203918161+awslabs-mcp@users.noreply.github.com>, Joel Shepherd <shepherd@amazon.com>
|
|
12
|
+
License: Apache-2.0
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: NOTICE
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Requires-Python: <3.12,>=3.10
|
|
22
|
+
Requires-Dist: boto3>=1.37.27
|
|
23
|
+
Requires-Dist: cassandra-driver>=3.25.0
|
|
24
|
+
Requires-Dist: fastmcp>=0.1.0
|
|
25
|
+
Requires-Dist: loguru>=0.7.0
|
|
26
|
+
Requires-Dist: mcp>=0.9.1
|
|
27
|
+
Requires-Dist: pydantic>=2.10.6
|
|
28
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# AWS Labs amazon-keyspaces MCP Server
|
|
32
|
+
|
|
33
|
+
An Amazon Keyspaces (for Apache Cassandra) MCP server for interacting with Amazon Keyspaces and Apache Cassandra.
|
|
34
|
+
|
|
35
|
+
## Overview
|
|
36
|
+
|
|
37
|
+
The Amazon Keyspaces MCP server implements the Model Context Protocol (MCP) to enable AI assistants like Amazon Q to
|
|
38
|
+
interact with Amazon Keyspaces or Apache Cassandra databases through natural language. This server allows you to explore
|
|
39
|
+
database schemas, execute queries, and analyze query performance without having to write CQL code directly.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
The Amazon Keyspaces (for Apache Cassandra) MCP server provides the following capabilities:
|
|
44
|
+
1. **Schema**: Explore keyspaces and tables.
|
|
45
|
+
2. **Run Queries**: Execute CQL SELECT queries against the configured database.
|
|
46
|
+
3. **Query Analysis**: Get feedback and suggestions for improving query performance.
|
|
47
|
+
4. **Cassandra-Compatible**: Use with Amazon Keyspaces, or with Apache Cassandra.
|
|
48
|
+
|
|
49
|
+
Here are some example prompts that this MCP server can help with:
|
|
50
|
+
- "List all keyspaces in my Cassandra database"
|
|
51
|
+
- "Show me the tables in the 'sales' keyspace"
|
|
52
|
+
- "Describe the 'users' table in the 'sales' keyspace"
|
|
53
|
+
- "What's the schema of the 'products' table?"
|
|
54
|
+
- "Run a SELECT query to get all users from the 'users' table in 'sales'"
|
|
55
|
+
- "Query the first 10 records from the 'events' table"
|
|
56
|
+
- "Analyze the performance of this query: SELECT * FROM users WHERE last_name = 'Smith'"
|
|
57
|
+
- "Is this query efficient: SELECT * FROM orders WHERE order_date > '2023-01-01'?"
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
### Prerequisites
|
|
62
|
+
|
|
63
|
+
- Python 3.10 or 3.11 (Python 3.12+ is not fully supported due to asyncore module removal)
|
|
64
|
+
- Access to an Amazon Keyspaces instance or Apache Cassandra cluster that supports password authentication
|
|
65
|
+
- Appropriate Cassandra log-in credentials
|
|
66
|
+
- Starfield digital certificate (required for Amazon Keyspaces)
|
|
67
|
+
|
|
68
|
+
### Install from PyPI
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install awslabs.amazon-keyspaces-mcp-server
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Install from Source
|
|
75
|
+
|
|
76
|
+
1. Clone the repository:
|
|
77
|
+
```bash
|
|
78
|
+
git clone https://github.com/awslabs/mcp.git
|
|
79
|
+
cd mcp/src/amazon-keyspaces-mcp-server
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. Create a virtual environment:
|
|
83
|
+
```bash
|
|
84
|
+
python -m venv .venv
|
|
85
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
3. Install the package:
|
|
89
|
+
```bash
|
|
90
|
+
pip install -e .
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Configuration
|
|
94
|
+
|
|
95
|
+
Create a `.env` file in your working directory with your database connection settings:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
# Set to true for Amazon Keyspaces, false for Apache Cassandra
|
|
99
|
+
DB_USE_KEYSPACES=true
|
|
100
|
+
|
|
101
|
+
# Cassandra configuration (for native Cassandra)
|
|
102
|
+
DB_CASSANDRA_CONTACT_POINTS=127.0.0.1
|
|
103
|
+
DB_CASSANDRA_PORT=9042
|
|
104
|
+
DB_CASSANDRA_LOCAL_DATACENTER=datacenter1
|
|
105
|
+
DB_CASSANDRA_USERNAME=
|
|
106
|
+
DB_CASSANDRA_PASSWORD=
|
|
107
|
+
|
|
108
|
+
# Keyspaces configuration (for Amazon Keyspaces)
|
|
109
|
+
DB_KEYSPACES_ENDPOINT=cassandra.us-west-2.amazonaws.com
|
|
110
|
+
DB_KEYSPACES_REGION=us-west-2
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Authentication Credentials
|
|
114
|
+
|
|
115
|
+
This MCP server uses username and password authentication for both Amazon Keyspaces and Apache Cassandra:
|
|
116
|
+
|
|
117
|
+
- For **Amazon Keyspaces**: Set the `DB_CASSANDRA_USERNAME` and `DB_CASSANDRA_PASSWORD` environment variables with
|
|
118
|
+
your Keyspaces username and password. These are the same service-specific credentials you would use to access Keyspaces
|
|
119
|
+
via the Cassandra Query Language (CQL) shell.
|
|
120
|
+
|
|
121
|
+
- For **Apache Cassandra**: Set the `DB_CASSANDRA_USERNAME` and `DB_CASSANDRA_PASSWORD` environment variables with
|
|
122
|
+
your Cassandra username and password.
|
|
123
|
+
|
|
124
|
+
### Starfield Digital Certificate for Amazon Keyspaces
|
|
125
|
+
|
|
126
|
+
Before connecting to Amazon Keyspaces, you need to download and install the Starfield digital certificate that Amazon
|
|
127
|
+
Keyspaces uses for TLS connections:
|
|
128
|
+
|
|
129
|
+
1. Download the Starfield digital certificate:
|
|
130
|
+
```bash
|
|
131
|
+
curl -O https://certs.secureserver.net/repository/sf-class2-root.crt
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
2. Place the certificate in the correct location:
|
|
135
|
+
```bash
|
|
136
|
+
# If you installed the package from PyPI
|
|
137
|
+
mkdir -p ~/.keyspaces-mcp/certs
|
|
138
|
+
cp sf-class2-root.crt ~/.keyspaces-mcp/certs/
|
|
139
|
+
|
|
140
|
+
# If you installed from source
|
|
141
|
+
mkdir -p /path/to/mcp/src/amazon-keyspaces-mcp-server/awslabs/certs
|
|
142
|
+
cp sf-class2-root.crt /path/to/mcp/src/amazon-keyspaces-mcp-server/awslabs/certs/
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The MCP server looks for the certificate in the `awslabs/certs` directory relative to the installation.
|
|
146
|
+
|
|
147
|
+
## Running the MCP Server
|
|
148
|
+
|
|
149
|
+
After installation, you can run the server directly:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
awslabs.amazon-keyspaces-mcp-server
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Configuring Amazon Q to Use the MCP Server
|
|
156
|
+
|
|
157
|
+
To use the Amazon Keyspaces MCP server with Amazon Q CLI, you need to configure it in your Q configuration file.
|
|
158
|
+
|
|
159
|
+
### Configuration for Amazon Q CLI
|
|
160
|
+
|
|
161
|
+
Edit the Q configuration file at `~/.config/amazon-q/config.json`:
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"mcpServers": [
|
|
166
|
+
{
|
|
167
|
+
"name": "keyspaces-mcp",
|
|
168
|
+
"command": "awslabs.amazon-keyspaces-mcp-server",
|
|
169
|
+
"args": [],
|
|
170
|
+
"env": {}
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
If the file doesn't exist yet or doesn't have an `mcpServers` section, create it with the structure shown above.
|
|
177
|
+
|
|
178
|
+
Now when you use Q Chat by running `q chat`, it will automatically connect to your Keyspaces MCP server.
|
|
179
|
+
|
|
180
|
+
## Available Tools
|
|
181
|
+
|
|
182
|
+
The Amazon Keyspaces MCP server provides the following tools that AI assistants can use:
|
|
183
|
+
|
|
184
|
+
- `listKeyspaces`: Lists all keyspaces in the database
|
|
185
|
+
- `listTables`: Lists all tables in a specified keyspace
|
|
186
|
+
- `describeKeyspace`: Gets detailed information about a keyspace
|
|
187
|
+
- `describeTable`: Gets detailed information about a table
|
|
188
|
+
- `executeQuery`: Executes a read-only SELECT query against the database
|
|
189
|
+
- `analyzeQueryPerformance`: Analyzes the performance characteristics of a CQL query
|
|
190
|
+
|
|
191
|
+
## Security Considerations
|
|
192
|
+
|
|
193
|
+
- When using Amazon Keyspaces, ensure your IAM policies follow the principle of least privilege. While this
|
|
194
|
+
MCP server does not mutate Keyspaces data or resources, it cannot prevent agent-driven attempts to (for example)
|
|
195
|
+
invoke AWS SDK operations on your behalf, including mutating operations.
|
|
196
|
+
- This MCP server only allows read-only SELECT queries to protect your data.
|
|
197
|
+
- Queries are validated to prevent potentially harmful operations.
|
|
198
|
+
|
|
199
|
+
## Troubleshooting
|
|
200
|
+
|
|
201
|
+
### Connection Issues
|
|
202
|
+
|
|
203
|
+
- Verify your database connection settings in the `.env` file.
|
|
204
|
+
- Ensure your logged-in user has the necessary permissions for the operations performed by this server.
|
|
205
|
+
- Check that your database is accessible from your network.
|
|
206
|
+
- For Amazon Keyspaces, verify that the Starfield certificate is correctly installed in the `awslabs/certs` directory.
|
|
207
|
+
- If you get SSL/TLS errors, check that the certificate path is correct and the certificate is valid.
|
|
208
|
+
|
|
209
|
+
### Python Version Compatibility
|
|
210
|
+
|
|
211
|
+
- The MCP server works best with Python 3.10 or 3.11.
|
|
212
|
+
- Python 3.12+ may have issues due to the removal of the asyncore module which the Cassandra driver depends on.
|
|
213
|
+
|
|
214
|
+
### Cassandra Driver Issues
|
|
215
|
+
|
|
216
|
+
If you encounter issues with the Cassandra driver:
|
|
217
|
+
|
|
218
|
+
1. Ensure you have the necessary C dependencies installed for the Cassandra driver.
|
|
219
|
+
2. Try installing the driver with: `pip install cassandra-driver --no-binary :all:`
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# AWS Labs amazon-keyspaces MCP Server
|
|
2
|
+
|
|
3
|
+
An Amazon Keyspaces (for Apache Cassandra) MCP server for interacting with Amazon Keyspaces and Apache Cassandra.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Amazon Keyspaces MCP server implements the Model Context Protocol (MCP) to enable AI assistants like Amazon Q to
|
|
8
|
+
interact with Amazon Keyspaces or Apache Cassandra databases through natural language. This server allows you to explore
|
|
9
|
+
database schemas, execute queries, and analyze query performance without having to write CQL code directly.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
The Amazon Keyspaces (for Apache Cassandra) MCP server provides the following capabilities:
|
|
14
|
+
1. **Schema**: Explore keyspaces and tables.
|
|
15
|
+
2. **Run Queries**: Execute CQL SELECT queries against the configured database.
|
|
16
|
+
3. **Query Analysis**: Get feedback and suggestions for improving query performance.
|
|
17
|
+
4. **Cassandra-Compatible**: Use with Amazon Keyspaces, or with Apache Cassandra.
|
|
18
|
+
|
|
19
|
+
Here are some example prompts that this MCP server can help with:
|
|
20
|
+
- "List all keyspaces in my Cassandra database"
|
|
21
|
+
- "Show me the tables in the 'sales' keyspace"
|
|
22
|
+
- "Describe the 'users' table in the 'sales' keyspace"
|
|
23
|
+
- "What's the schema of the 'products' table?"
|
|
24
|
+
- "Run a SELECT query to get all users from the 'users' table in 'sales'"
|
|
25
|
+
- "Query the first 10 records from the 'events' table"
|
|
26
|
+
- "Analyze the performance of this query: SELECT * FROM users WHERE last_name = 'Smith'"
|
|
27
|
+
- "Is this query efficient: SELECT * FROM orders WHERE order_date > '2023-01-01'?"
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### Prerequisites
|
|
32
|
+
|
|
33
|
+
- Python 3.10 or 3.11 (Python 3.12+ is not fully supported due to asyncore module removal)
|
|
34
|
+
- Access to an Amazon Keyspaces instance or Apache Cassandra cluster that supports password authentication
|
|
35
|
+
- Appropriate Cassandra log-in credentials
|
|
36
|
+
- Starfield digital certificate (required for Amazon Keyspaces)
|
|
37
|
+
|
|
38
|
+
### Install from PyPI
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install awslabs.amazon-keyspaces-mcp-server
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Install from Source
|
|
45
|
+
|
|
46
|
+
1. Clone the repository:
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/awslabs/mcp.git
|
|
49
|
+
cd mcp/src/amazon-keyspaces-mcp-server
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. Create a virtual environment:
|
|
53
|
+
```bash
|
|
54
|
+
python -m venv .venv
|
|
55
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
3. Install the package:
|
|
59
|
+
```bash
|
|
60
|
+
pip install -e .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Configuration
|
|
64
|
+
|
|
65
|
+
Create a `.env` file in your working directory with your database connection settings:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
# Set to true for Amazon Keyspaces, false for Apache Cassandra
|
|
69
|
+
DB_USE_KEYSPACES=true
|
|
70
|
+
|
|
71
|
+
# Cassandra configuration (for native Cassandra)
|
|
72
|
+
DB_CASSANDRA_CONTACT_POINTS=127.0.0.1
|
|
73
|
+
DB_CASSANDRA_PORT=9042
|
|
74
|
+
DB_CASSANDRA_LOCAL_DATACENTER=datacenter1
|
|
75
|
+
DB_CASSANDRA_USERNAME=
|
|
76
|
+
DB_CASSANDRA_PASSWORD=
|
|
77
|
+
|
|
78
|
+
# Keyspaces configuration (for Amazon Keyspaces)
|
|
79
|
+
DB_KEYSPACES_ENDPOINT=cassandra.us-west-2.amazonaws.com
|
|
80
|
+
DB_KEYSPACES_REGION=us-west-2
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Authentication Credentials
|
|
84
|
+
|
|
85
|
+
This MCP server uses username and password authentication for both Amazon Keyspaces and Apache Cassandra:
|
|
86
|
+
|
|
87
|
+
- For **Amazon Keyspaces**: Set the `DB_CASSANDRA_USERNAME` and `DB_CASSANDRA_PASSWORD` environment variables with
|
|
88
|
+
your Keyspaces username and password. These are the same service-specific credentials you would use to access Keyspaces
|
|
89
|
+
via the Cassandra Query Language (CQL) shell.
|
|
90
|
+
|
|
91
|
+
- For **Apache Cassandra**: Set the `DB_CASSANDRA_USERNAME` and `DB_CASSANDRA_PASSWORD` environment variables with
|
|
92
|
+
your Cassandra username and password.
|
|
93
|
+
|
|
94
|
+
### Starfield Digital Certificate for Amazon Keyspaces
|
|
95
|
+
|
|
96
|
+
Before connecting to Amazon Keyspaces, you need to download and install the Starfield digital certificate that Amazon
|
|
97
|
+
Keyspaces uses for TLS connections:
|
|
98
|
+
|
|
99
|
+
1. Download the Starfield digital certificate:
|
|
100
|
+
```bash
|
|
101
|
+
curl -O https://certs.secureserver.net/repository/sf-class2-root.crt
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
2. Place the certificate in the correct location:
|
|
105
|
+
```bash
|
|
106
|
+
# If you installed the package from PyPI
|
|
107
|
+
mkdir -p ~/.keyspaces-mcp/certs
|
|
108
|
+
cp sf-class2-root.crt ~/.keyspaces-mcp/certs/
|
|
109
|
+
|
|
110
|
+
# If you installed from source
|
|
111
|
+
mkdir -p /path/to/mcp/src/amazon-keyspaces-mcp-server/awslabs/certs
|
|
112
|
+
cp sf-class2-root.crt /path/to/mcp/src/amazon-keyspaces-mcp-server/awslabs/certs/
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The MCP server looks for the certificate in the `awslabs/certs` directory relative to the installation.
|
|
116
|
+
|
|
117
|
+
## Running the MCP Server
|
|
118
|
+
|
|
119
|
+
After installation, you can run the server directly:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
awslabs.amazon-keyspaces-mcp-server
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Configuring Amazon Q to Use the MCP Server
|
|
126
|
+
|
|
127
|
+
To use the Amazon Keyspaces MCP server with Amazon Q CLI, you need to configure it in your Q configuration file.
|
|
128
|
+
|
|
129
|
+
### Configuration for Amazon Q CLI
|
|
130
|
+
|
|
131
|
+
Edit the Q configuration file at `~/.config/amazon-q/config.json`:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"mcpServers": [
|
|
136
|
+
{
|
|
137
|
+
"name": "keyspaces-mcp",
|
|
138
|
+
"command": "awslabs.amazon-keyspaces-mcp-server",
|
|
139
|
+
"args": [],
|
|
140
|
+
"env": {}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
If the file doesn't exist yet or doesn't have an `mcpServers` section, create it with the structure shown above.
|
|
147
|
+
|
|
148
|
+
Now when you use Q Chat by running `q chat`, it will automatically connect to your Keyspaces MCP server.
|
|
149
|
+
|
|
150
|
+
## Available Tools
|
|
151
|
+
|
|
152
|
+
The Amazon Keyspaces MCP server provides the following tools that AI assistants can use:
|
|
153
|
+
|
|
154
|
+
- `listKeyspaces`: Lists all keyspaces in the database
|
|
155
|
+
- `listTables`: Lists all tables in a specified keyspace
|
|
156
|
+
- `describeKeyspace`: Gets detailed information about a keyspace
|
|
157
|
+
- `describeTable`: Gets detailed information about a table
|
|
158
|
+
- `executeQuery`: Executes a read-only SELECT query against the database
|
|
159
|
+
- `analyzeQueryPerformance`: Analyzes the performance characteristics of a CQL query
|
|
160
|
+
|
|
161
|
+
## Security Considerations
|
|
162
|
+
|
|
163
|
+
- When using Amazon Keyspaces, ensure your IAM policies follow the principle of least privilege. While this
|
|
164
|
+
MCP server does not mutate Keyspaces data or resources, it cannot prevent agent-driven attempts to (for example)
|
|
165
|
+
invoke AWS SDK operations on your behalf, including mutating operations.
|
|
166
|
+
- This MCP server only allows read-only SELECT queries to protect your data.
|
|
167
|
+
- Queries are validated to prevent potentially harmful operations.
|
|
168
|
+
|
|
169
|
+
## Troubleshooting
|
|
170
|
+
|
|
171
|
+
### Connection Issues
|
|
172
|
+
|
|
173
|
+
- Verify your database connection settings in the `.env` file.
|
|
174
|
+
- Ensure your logged-in user has the necessary permissions for the operations performed by this server.
|
|
175
|
+
- Check that your database is accessible from your network.
|
|
176
|
+
- For Amazon Keyspaces, verify that the Starfield certificate is correctly installed in the `awslabs/certs` directory.
|
|
177
|
+
- If you get SSL/TLS errors, check that the certificate path is correct and the certificate is valid.
|
|
178
|
+
|
|
179
|
+
### Python Version Compatibility
|
|
180
|
+
|
|
181
|
+
- The MCP server works best with Python 3.10 or 3.11.
|
|
182
|
+
- Python 3.12+ may have issues due to the removal of the asyncore module which the Cassandra driver depends on.
|
|
183
|
+
|
|
184
|
+
### Cassandra Driver Issues
|
|
185
|
+
|
|
186
|
+
If you encounter issues with the Cassandra driver:
|
|
187
|
+
|
|
188
|
+
1. Ensure you have the necessary C dependencies installed for the Cassandra driver.
|
|
189
|
+
2. Try installing the driver with: `pip install cassandra-driver --no-binary :all:`
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
|