awslabs.dynamodb-mcp-server 0.1.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 awslabs.dynamodb-mcp-server might be problematic. Click here for more details.

awslabs/__init__.py ADDED
@@ -0,0 +1,13 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
+ # with the License. A copy of the License is located at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
+ # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
+ # and limitations under the License.
11
+
12
+ # This file is part of the awslabs namespace.
13
+ # It is intentionally minimal to support PEP 420 namespace packages.
@@ -0,0 +1,14 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
+ # with the License. A copy of the License is located at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
+ # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
+ # and limitations under the License.
11
+
12
+ """awslabs.dynamodb-mcp-server"""
13
+
14
+ __version__ = '0.0.0'
@@ -0,0 +1,306 @@
1
+ from functools import wraps
2
+ from typing import Any, Callable, Dict, List, Literal, Optional
3
+ from typing_extensions import TypedDict
4
+
5
+
6
+ def handle_exceptions(func: Callable) -> Callable:
7
+ """Decorator to handle exceptions in DynamoDB operations.
8
+
9
+ Wraps the function in a try-catch block and returns any exceptions
10
+ in a standardized error format.
11
+
12
+ Args:
13
+ func: The function to wrap
14
+
15
+ Returns:
16
+ The wrapped function that handles exceptions
17
+ """
18
+
19
+ @wraps(func)
20
+ async def wrapper(*args, **kwargs):
21
+ try:
22
+ return await func(*args, **kwargs)
23
+ except Exception as e:
24
+ return {'error': str(e)}
25
+
26
+ return wrapper
27
+
28
+
29
+ # Type definitions
30
+ AttributeValue = Dict[Literal['S', 'N', 'B', 'BOOL', 'NULL', 'L', 'M', 'SS', 'NS', 'BS'], Any]
31
+ KeyAttributeValue = Dict[Literal['S', 'N', 'B'], Any]
32
+
33
+ # Return value enums
34
+ ReturnValue = Literal['NONE', 'ALL_OLD', 'UPDATED_OLD', 'ALL_NEW', 'UPDATED_NEW']
35
+ ReturnConsumedCapacity = Literal['INDEXES', 'TOTAL', 'NONE']
36
+ ReturnItemCollectionMetrics = Literal['SIZE', 'NONE']
37
+ Select = Literal['ALL_ATTRIBUTES', 'ALL_PROJECTED_ATTRIBUTES', 'SPECIFIC_ATTRIBUTES', 'COUNT']
38
+
39
+
40
+ class ScanInput(TypedDict, total=False):
41
+ """Parameters for Scan operation."""
42
+
43
+ TableName: str # required
44
+ IndexName: Optional[str]
45
+ AttributesToGet: Optional[List[str]] # Legacy parameter
46
+ Limit: Optional[int]
47
+ Select: Optional[Select]
48
+ ScanFilter: Optional[
49
+ Dict[str, AttributeValue]
50
+ ] # Legacy parameter (must use AttributeValue format e.g. {'S': 'value'})
51
+ ConditionalOperator: Optional[Literal['AND', 'OR']] # Legacy parameter
52
+ ExclusiveStartKey: Optional[
53
+ Dict[str, KeyAttributeValue]
54
+ ] # Primary key attributes in AttributeValue format e.g. {'S': 'value'}
55
+ ReturnConsumedCapacity: Optional[ReturnConsumedCapacity]
56
+ TotalSegments: Optional[int]
57
+ Segment: Optional[int]
58
+ ProjectionExpression: Optional[str]
59
+ FilterExpression: Optional[str]
60
+ ExpressionAttributeNames: Optional[Dict[str, str]]
61
+ ExpressionAttributeValues: Optional[
62
+ Dict[str, AttributeValue]
63
+ ] # values must use AttributeValue format e.g. {'S': 'value'}
64
+ ConsistentRead: Optional[bool]
65
+
66
+
67
+ class QueryInput(TypedDict, total=False):
68
+ """Parameters for Query operation."""
69
+
70
+ TableName: str # required
71
+ IndexName: Optional[str]
72
+ Select: Optional[Select]
73
+ AttributesToGet: Optional[List[str]] # Legacy parameter
74
+ Limit: Optional[int]
75
+ ConsistentRead: Optional[bool]
76
+ KeyConditionExpression: Optional[str]
77
+ FilterExpression: Optional[str]
78
+ ProjectionExpression: Optional[str]
79
+ ExpressionAttributeNames: Optional[Dict[str, str]]
80
+ ExpressionAttributeValues: Optional[
81
+ Dict[str, AttributeValue]
82
+ ] # values must use AttributeValue format e.g. {'S': 'value'}
83
+ ScanIndexForward: Optional[bool]
84
+ ExclusiveStartKey: Optional[
85
+ Dict[str, KeyAttributeValue]
86
+ ] # Primary key attributes in AttributeValue format e.g. {'S': 'value'}
87
+ ReturnConsumedCapacity: Optional[ReturnConsumedCapacity]
88
+
89
+
90
+ class DeleteItemInput(TypedDict, total=False):
91
+ """Parameters for DeleteItem operation."""
92
+
93
+ TableName: str # required
94
+ Key: Dict[
95
+ str, KeyAttributeValue
96
+ ] # required - primary key attributes in AttributeValue format e.g. {'S': 'value'}
97
+ ConditionExpression: Optional[str]
98
+ ExpressionAttributeNames: Optional[Dict[str, str]]
99
+ ExpressionAttributeValues: Optional[
100
+ Dict[str, AttributeValue]
101
+ ] # values must use AttributeValue format e.g. {'S': 'value'}
102
+ ReturnConsumedCapacity: Optional[ReturnConsumedCapacity]
103
+ ReturnItemCollectionMetrics: Optional[ReturnItemCollectionMetrics]
104
+ ReturnValues: Optional[ReturnValue]
105
+ ReturnValuesOnConditionCheckFailure: Optional[Literal['ALL_OLD', 'NONE']]
106
+
107
+
108
+ class UpdateItemInput(TypedDict, total=False):
109
+ """Parameters for UpdateItem operation."""
110
+
111
+ TableName: str # required
112
+ Key: Dict[
113
+ str, KeyAttributeValue
114
+ ] # required - primary key attributes in AttributeValue format e.g. {'S': 'value'}
115
+ UpdateExpression: Optional[str]
116
+ ConditionExpression: Optional[str]
117
+ ExpressionAttributeNames: Optional[Dict[str, str]]
118
+ ExpressionAttributeValues: Optional[
119
+ Dict[str, AttributeValue]
120
+ ] # values must use AttributeValue format e.g. {'S': 'value'}
121
+ ReturnConsumedCapacity: Optional[ReturnConsumedCapacity]
122
+ ReturnItemCollectionMetrics: Optional[ReturnItemCollectionMetrics]
123
+ ReturnValues: Optional[ReturnValue]
124
+ ReturnValuesOnConditionCheckFailure: Optional[Literal['ALL_OLD', 'NONE']]
125
+
126
+
127
+ class GetItemInput(TypedDict, total=False):
128
+ """Parameters for GetItem operation."""
129
+
130
+ TableName: str # required
131
+ Key: Dict[
132
+ str, KeyAttributeValue
133
+ ] # required - primary key attributes in AttributeValue format e.g. {'S': 'value'}
134
+ AttributesToGet: Optional[List[str]]
135
+ ConsistentRead: Optional[bool]
136
+ ExpressionAttributeNames: Optional[Dict[str, str]]
137
+ ProjectionExpression: Optional[str]
138
+ ReturnConsumedCapacity: Optional[ReturnConsumedCapacity]
139
+
140
+
141
+ class PutItemInput(TypedDict, total=False):
142
+ """Parameters for PutItem operation."""
143
+
144
+ TableName: str # required
145
+ Item: Dict[
146
+ str, AttributeValue
147
+ ] # required - maps attribute name to AttributeValue (must use AttributeValue format e.g. {'S': 'value'})
148
+ ConditionExpression: Optional[str]
149
+ ExpressionAttributeNames: Optional[Dict[str, str]]
150
+ ExpressionAttributeValues: Optional[
151
+ Dict[str, AttributeValue]
152
+ ] # values must use AttributeValue format e.g. {'S': 'value'}
153
+ ReturnConsumedCapacity: Optional[ReturnConsumedCapacity]
154
+ ReturnItemCollectionMetrics: Optional[ReturnItemCollectionMetrics]
155
+ ReturnValues: Optional[ReturnValue]
156
+ ReturnValuesOnConditionCheckFailure: Optional[Literal['ALL_OLD', 'NONE']]
157
+
158
+
159
+ class AttributeDefinition(TypedDict):
160
+ AttributeName: str
161
+ AttributeType: Literal['S', 'N', 'B']
162
+
163
+
164
+ class KeySchemaElement(TypedDict):
165
+ AttributeName: str
166
+ KeyType: Literal['HASH', 'RANGE']
167
+
168
+
169
+ class ProvisionedThroughput(TypedDict):
170
+ ReadCapacityUnits: int
171
+ WriteCapacityUnits: int
172
+
173
+
174
+ class Projection(TypedDict, total=False):
175
+ ProjectionType: Literal['KEYS_ONLY', 'INCLUDE', 'ALL']
176
+ NonKeyAttributes: List[str]
177
+
178
+
179
+ class OnDemandThroughput(TypedDict, total=False):
180
+ MaxReadRequestUnits: int
181
+ MaxWriteRequestUnits: int
182
+
183
+
184
+ class WarmThroughput(TypedDict, total=False):
185
+ ReadUnitsPerSecond: int
186
+ WriteUnitsPerSecond: int
187
+
188
+
189
+ class GlobalSecondaryIndex(TypedDict, total=False):
190
+ IndexName: str # required
191
+ KeySchema: List[KeySchemaElement] # required
192
+ Projection: Projection # required
193
+ ProvisionedThroughput: ProvisionedThroughput
194
+ OnDemandThroughput: OnDemandThroughput
195
+
196
+
197
+ class GlobalSecondaryIndexUpdateAction(TypedDict, total=False):
198
+ IndexName: str
199
+ ProvisionedThroughput: ProvisionedThroughput
200
+ OnDemandThroughput: OnDemandThroughput
201
+ WarmThroughput: WarmThroughput
202
+
203
+
204
+ class GlobalSecondaryIndexDeleteAction(TypedDict):
205
+ IndexName: str
206
+
207
+
208
+ class GlobalSecondaryIndexUpdate(TypedDict, total=False):
209
+ Create: GlobalSecondaryIndex
210
+ Delete: GlobalSecondaryIndexDeleteAction
211
+ Update: GlobalSecondaryIndexUpdateAction
212
+
213
+
214
+ class StreamSpecification(TypedDict, total=False):
215
+ StreamEnabled: bool
216
+ StreamViewType: Literal['KEYS_ONLY', 'NEW_IMAGE', 'OLD_IMAGE', 'NEW_AND_OLD_IMAGES']
217
+
218
+
219
+ class Tag(TypedDict):
220
+ Key: str
221
+ Value: str
222
+
223
+
224
+ class SSESpecification(TypedDict, total=False):
225
+ """Set Enabled to true for AWS managed key (KMS charges apply). set it to false for AWS owned key."""
226
+
227
+ Enabled: bool
228
+ SSEType: Literal['KMS']
229
+ KMSMasterKeyId: str
230
+
231
+
232
+ class TimeToLiveSpecification(TypedDict):
233
+ AttributeName: str # The name of the TTL attribute used to store the expiration time for items
234
+ Enabled: bool # Indicates whether TTL is enabled (true) or disabled (false) on the table
235
+
236
+
237
+ class GetResourcePolicyInput(TypedDict):
238
+ ResourceArn: str # The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy is attached
239
+
240
+
241
+ class PutResourcePolicyInput(TypedDict, total=False):
242
+ Policy: str # An AWS resource-based policy document in JSON format
243
+ ResourceArn: str # The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached
244
+ ConfirmRemoveSelfResourceAccess: (
245
+ bool # Set to true to confirm removing your permissions to change the policy in the future
246
+ )
247
+ ExpectedRevisionId: str # A string value for conditional updates of your policy
248
+
249
+
250
+ class OnDemandThroughputOverride(TypedDict):
251
+ MaxReadRequestUnits: int
252
+
253
+
254
+ class ProvisionedThroughputOverride(TypedDict):
255
+ ReadCapacityUnits: int
256
+
257
+
258
+ class ReplicaCreate(TypedDict, total=False):
259
+ RegionName: str
260
+ KMSMasterKeyId: str
261
+
262
+
263
+ class ReplicaDelete(TypedDict):
264
+ RegionName: str
265
+
266
+
267
+ class ReplicaUpdate(TypedDict, total=False):
268
+ KMSMasterKeyId: str
269
+ OnDemandThroughputOverride: OnDemandThroughputOverride
270
+ ProvisionedThroughputOverride: ProvisionedThroughputOverride
271
+ RegionName: str
272
+ TableClassOverride: Literal['STANDARD', 'STANDARD_INFREQUENT_ACCESS']
273
+
274
+
275
+ class ReplicationGroupUpdate(TypedDict, total=False):
276
+ Create: ReplicaCreate
277
+ Update: ReplicaUpdate
278
+ Delete: ReplicaDelete
279
+
280
+
281
+ class CreateTableInput(TypedDict, total=False):
282
+ """Parameters for CreateTable operation."""
283
+
284
+ TableName: str # required
285
+ AttributeDefinitions: List[AttributeDefinition] # required
286
+ KeySchema: List[KeySchemaElement] # required
287
+ BillingMode: Literal['PROVISIONED', 'PAY_PER_REQUEST']
288
+ GlobalSecondaryIndexes: List[GlobalSecondaryIndex]
289
+ ProvisionedThroughput: ProvisionedThroughput
290
+
291
+
292
+ class UpdateTableInput(TypedDict, total=False):
293
+ """Parameters for UpdateTable operation."""
294
+
295
+ TableName: str # required
296
+ AttributeDefinitions: List[AttributeDefinition]
297
+ BillingMode: Literal['PROVISIONED', 'PAY_PER_REQUEST']
298
+ DeletionProtectionEnabled: bool
299
+ GlobalSecondaryIndexUpdates: List[GlobalSecondaryIndexUpdate]
300
+ OnDemandThroughput: OnDemandThroughput
301
+ ProvisionedThroughput: ProvisionedThroughput
302
+ ReplicaUpdates: List[ReplicationGroupUpdate]
303
+ SSESpecification: SSESpecification
304
+ StreamSpecification: StreamSpecification
305
+ TableClass: Literal['STANDARD', 'STANDARD_INFREQUENT_ACCESS']
306
+ WarmThroughput: WarmThroughput