awslabs.memcached-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.
- awslabs/__init__.py +13 -0
- awslabs/memcached_mcp_server/__init__.py +14 -0
- awslabs/memcached_mcp_server/common/config.py +7 -0
- awslabs/memcached_mcp_server/common/connection.py +81 -0
- awslabs/memcached_mcp_server/common/server.py +14 -0
- awslabs/memcached_mcp_server/main.py +67 -0
- awslabs/memcached_mcp_server/tools/cache.py +426 -0
- awslabs_memcached_mcp_server-0.1.1.dist-info/METADATA +148 -0
- awslabs_memcached_mcp_server-0.1.1.dist-info/RECORD +13 -0
- awslabs_memcached_mcp_server-0.1.1.dist-info/WHEEL +4 -0
- awslabs_memcached_mcp_server-0.1.1.dist-info/entry_points.txt +2 -0
- awslabs_memcached_mcp_server-0.1.1.dist-info/licenses/LICENSE +175 -0
- awslabs_memcached_mcp_server-0.1.1.dist-info/licenses/NOTICE +2 -0
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.memcached-mcp-server"""
|
|
13
|
+
|
|
14
|
+
__version__ = '0.1.0'
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Connection management for Memcached MCP Server."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import ssl
|
|
5
|
+
from pymemcache.client.base import Client
|
|
6
|
+
from pymemcache.client.retrying import RetryingClient
|
|
7
|
+
from pymemcache.exceptions import MemcacheError
|
|
8
|
+
from typing import Any, Dict, Optional
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MemcachedConnectionManager:
|
|
12
|
+
"""Manages connection to Memcached."""
|
|
13
|
+
|
|
14
|
+
_client: Optional[RetryingClient] = None
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def get_connection(cls) -> RetryingClient:
|
|
18
|
+
"""Get or create a Memcached client connection.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
RetryingClient: A Memcached client with retry capabilities
|
|
22
|
+
"""
|
|
23
|
+
if cls._client is None:
|
|
24
|
+
# Get configuration from environment
|
|
25
|
+
host = os.getenv('MEMCACHED_HOST', '127.0.0.1')
|
|
26
|
+
port = int(os.getenv('MEMCACHED_PORT', '11211'))
|
|
27
|
+
timeout = float(os.getenv('MEMCACHED_TIMEOUT', '1'))
|
|
28
|
+
connect_timeout = float(os.getenv('MEMCACHED_CONNECT_TIMEOUT', '5'))
|
|
29
|
+
retry_timeout = float(os.getenv('MEMCACHED_RETRY_TIMEOUT', '1'))
|
|
30
|
+
max_retries = int(os.getenv('MEMCACHED_MAX_RETRIES', '3'))
|
|
31
|
+
|
|
32
|
+
# SSL/TLS configuration
|
|
33
|
+
use_tls = os.getenv('MEMCACHED_USE_TLS', 'false').lower() == 'true'
|
|
34
|
+
tls_cert_path = os.getenv('MEMCACHED_TLS_CERT_PATH')
|
|
35
|
+
tls_key_path = os.getenv('MEMCACHED_TLS_KEY_PATH')
|
|
36
|
+
tls_ca_cert_path = os.getenv('MEMCACHED_TLS_CA_CERT_PATH')
|
|
37
|
+
tls_verify = os.getenv('MEMCACHED_TLS_VERIFY', 'true').lower() == 'true'
|
|
38
|
+
|
|
39
|
+
# Configure TLS context if enabled
|
|
40
|
+
tls_context = None
|
|
41
|
+
if use_tls:
|
|
42
|
+
tls_context = ssl.create_default_context(
|
|
43
|
+
cafile=tls_ca_cert_path if tls_ca_cert_path else None
|
|
44
|
+
)
|
|
45
|
+
if tls_verify:
|
|
46
|
+
tls_context.check_hostname = True
|
|
47
|
+
tls_context.verify_mode = ssl.CERT_REQUIRED
|
|
48
|
+
else:
|
|
49
|
+
tls_context.check_hostname = False
|
|
50
|
+
tls_context.verify_mode = ssl.CERT_NONE
|
|
51
|
+
if tls_cert_path and tls_key_path:
|
|
52
|
+
tls_context.load_cert_chain(tls_cert_path, tls_key_path)
|
|
53
|
+
|
|
54
|
+
# Create base client
|
|
55
|
+
client_kwargs: Dict[str, Any] = {
|
|
56
|
+
'server': (host, port),
|
|
57
|
+
'timeout': timeout,
|
|
58
|
+
'connect_timeout': connect_timeout,
|
|
59
|
+
'no_delay': True, # Disable Nagle's algorithm
|
|
60
|
+
}
|
|
61
|
+
if tls_context:
|
|
62
|
+
client_kwargs['tls_context'] = tls_context
|
|
63
|
+
|
|
64
|
+
base_client = Client(**client_kwargs)
|
|
65
|
+
|
|
66
|
+
# Wrap with retry capabilities
|
|
67
|
+
cls._client = RetryingClient(
|
|
68
|
+
base_client,
|
|
69
|
+
attempts=max_retries,
|
|
70
|
+
retry_delay=int(retry_timeout),
|
|
71
|
+
retry_for=[MemcacheError],
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
return cls._client
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def close_connection(cls) -> None:
|
|
78
|
+
"""Close the Memcached client connection."""
|
|
79
|
+
if cls._client is not None:
|
|
80
|
+
cls._client.close()
|
|
81
|
+
cls._client = None
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Server initialization for Memcached MCP Server."""
|
|
2
|
+
|
|
3
|
+
from mcp.server.fastmcp import FastMCP
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# Create MCP server instance
|
|
7
|
+
mcp = FastMCP(
|
|
8
|
+
'awslabs.memcached-mcp-server',
|
|
9
|
+
instructions='Instructions for using this memcached MCP server. This can be used by clients to improve the LLM'
|
|
10
|
+
's understanding of available tools, resources, etc. It can be thought of like a '
|
|
11
|
+
'hint'
|
|
12
|
+
' to the model. For example, this information MAY be added to the system prompt. Important to be clear, direct, and detailed.',
|
|
13
|
+
dependencies=['pydantic', 'loguru', 'pymemcache', 'dotenv'],
|
|
14
|
+
)
|
|
@@ -0,0 +1,67 @@
|
|
|
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 memcached MCP Server implementation."""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
from awslabs.memcached_mcp_server.common.server import mcp
|
|
16
|
+
from awslabs.memcached_mcp_server.tools import cache # noqa: F401
|
|
17
|
+
from loguru import logger
|
|
18
|
+
from starlette.requests import Request # noqa: F401
|
|
19
|
+
from starlette.responses import Response
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# Add a health check route directly to the MCP server
|
|
23
|
+
@mcp.custom_route('/health', methods=['GET'])
|
|
24
|
+
async def health_check(request):
|
|
25
|
+
"""Simple health check endpoint for ALB Target Group.
|
|
26
|
+
|
|
27
|
+
Always returns 200 OK to indicate the service is running.
|
|
28
|
+
"""
|
|
29
|
+
return Response(content='healthy', status_code=200, media_type='text/plain')
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class MemcachedMCPServer:
|
|
33
|
+
"""Memcached MCP Server wrapper."""
|
|
34
|
+
|
|
35
|
+
def __init__(self, sse=False, port=None):
|
|
36
|
+
"""Initialize MCP Server wrapper."""
|
|
37
|
+
self.sse = sse
|
|
38
|
+
self.port = port
|
|
39
|
+
|
|
40
|
+
def run(self):
|
|
41
|
+
"""Run server with appropriate transport."""
|
|
42
|
+
if self.sse:
|
|
43
|
+
mcp.settings.port = int(self.port) if self.port is not None else 8888
|
|
44
|
+
mcp.run(transport='sse')
|
|
45
|
+
else:
|
|
46
|
+
mcp.run()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def main():
|
|
50
|
+
"""Run the MCP server with CLI argument support."""
|
|
51
|
+
parser = argparse.ArgumentParser(
|
|
52
|
+
description='An AWS Labs Model Context Protocol (MCP) server for Amazon ElastiCache Memcached'
|
|
53
|
+
)
|
|
54
|
+
parser.add_argument('--sse', action='store_true', help='Use SSE transport')
|
|
55
|
+
parser.add_argument('--port', type=int, default=8888, help='Port to run the server on')
|
|
56
|
+
|
|
57
|
+
args = parser.parse_args()
|
|
58
|
+
|
|
59
|
+
logger.info('Amazon ElastiCache Memcached MCP Server Started...')
|
|
60
|
+
|
|
61
|
+
# Run server with appropriate transport
|
|
62
|
+
server = MemcachedMCPServer(args.sse, args.port)
|
|
63
|
+
server.run()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
if __name__ == '__main__':
|
|
67
|
+
main()
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
"""Cache operations for Memcached MCP Server."""
|
|
2
|
+
|
|
3
|
+
from awslabs.memcached_mcp_server.common.connection import MemcachedConnectionManager
|
|
4
|
+
from awslabs.memcached_mcp_server.common.server import mcp
|
|
5
|
+
from pymemcache.exceptions import MemcacheError
|
|
6
|
+
from typing import Any, Dict, List, Optional
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@mcp.tool()
|
|
10
|
+
async def cache_get(key: str) -> str:
|
|
11
|
+
"""Get a value from the cache.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
key: The key to retrieve
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
Value or error message
|
|
18
|
+
"""
|
|
19
|
+
try:
|
|
20
|
+
client = MemcachedConnectionManager.get_connection()
|
|
21
|
+
result = client.get(key)
|
|
22
|
+
if result is None:
|
|
23
|
+
return f"Key '{key}' not found"
|
|
24
|
+
return str(result)
|
|
25
|
+
except MemcacheError as e:
|
|
26
|
+
return f"Error getting key '{key}': {str(e)}"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@mcp.tool()
|
|
30
|
+
async def cache_gets(key: str) -> str:
|
|
31
|
+
"""Get a value and its CAS token from the cache.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
key: The key to retrieve
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
Value and CAS token or error message
|
|
38
|
+
"""
|
|
39
|
+
try:
|
|
40
|
+
client = MemcachedConnectionManager.get_connection()
|
|
41
|
+
result = client.gets(key)
|
|
42
|
+
if result is None:
|
|
43
|
+
return f"Key '{key}' not found"
|
|
44
|
+
value, cas = result
|
|
45
|
+
return f'Value: {value}, CAS: {cas}'
|
|
46
|
+
except MemcacheError as e:
|
|
47
|
+
return f"Error getting key '{key}' with CAS: {str(e)}"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@mcp.tool()
|
|
51
|
+
async def cache_get_many(keys: List[str]) -> str:
|
|
52
|
+
"""Get multiple values from the cache.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
keys: List of keys to retrieve
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
Dictionary of key-value pairs or error message
|
|
59
|
+
"""
|
|
60
|
+
try:
|
|
61
|
+
client = MemcachedConnectionManager.get_connection()
|
|
62
|
+
result = client.get_many(keys)
|
|
63
|
+
if not result:
|
|
64
|
+
return 'No keys found'
|
|
65
|
+
return str(result)
|
|
66
|
+
except MemcacheError as e:
|
|
67
|
+
return f'Error getting multiple keys: {str(e)}'
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@mcp.tool()
|
|
71
|
+
async def cache_get_multi(keys: List[str]) -> str:
|
|
72
|
+
"""Get multiple values from the cache (alias for get_many).
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
keys: List of keys to retrieve
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
Dictionary of key-value pairs or error message
|
|
79
|
+
"""
|
|
80
|
+
return await cache_get_many(keys)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@mcp.tool()
|
|
84
|
+
async def cache_set(key: str, value: Any, expire: Optional[int] = None) -> str:
|
|
85
|
+
"""Set a value in the cache.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
key: The key to set
|
|
89
|
+
value: The value to store
|
|
90
|
+
expire: Optional expiration time in seconds
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
Success message or error message
|
|
94
|
+
"""
|
|
95
|
+
try:
|
|
96
|
+
client = MemcachedConnectionManager.get_connection()
|
|
97
|
+
client.set(key, value, expire=expire)
|
|
98
|
+
expiry_msg = f' with {expire}s expiry' if expire else ''
|
|
99
|
+
return f"Successfully set key '{key}'{expiry_msg}"
|
|
100
|
+
except MemcacheError as e:
|
|
101
|
+
return f"Error setting key '{key}': {str(e)}"
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@mcp.tool()
|
|
105
|
+
async def cache_cas(key: str, value: Any, cas: int, expire: Optional[int] = None) -> str:
|
|
106
|
+
"""Set a value using CAS (Check And Set).
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
key: The key to set
|
|
110
|
+
value: The value to store
|
|
111
|
+
cas: CAS token from gets()
|
|
112
|
+
expire: Optional expiration time in seconds
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
Success message or error message
|
|
116
|
+
"""
|
|
117
|
+
try:
|
|
118
|
+
client = MemcachedConnectionManager.get_connection()
|
|
119
|
+
if client.cas(key, value, cas, expire=expire):
|
|
120
|
+
expiry_msg = f' with {expire}s expiry' if expire else ''
|
|
121
|
+
return f"Successfully set key '{key}' using CAS{expiry_msg}"
|
|
122
|
+
return f"CAS operation failed for key '{key}' (value changed)"
|
|
123
|
+
except MemcacheError as e:
|
|
124
|
+
return f"Error setting key '{key}' with CAS: {str(e)}"
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@mcp.tool()
|
|
128
|
+
async def cache_set_many(mapping: Dict[str, Any], expire: Optional[int] = None) -> str:
|
|
129
|
+
"""Set multiple values in the cache.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
mapping: Dictionary of key-value pairs
|
|
133
|
+
expire: Optional expiration time in seconds
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
Success message or error message
|
|
137
|
+
"""
|
|
138
|
+
try:
|
|
139
|
+
client = MemcachedConnectionManager.get_connection()
|
|
140
|
+
failed = client.set_many(mapping, expire=expire)
|
|
141
|
+
if not failed:
|
|
142
|
+
expiry_msg = f' with {expire}s expiry' if expire else ''
|
|
143
|
+
return f'Successfully set {len(mapping)} keys{expiry_msg}'
|
|
144
|
+
return f'Failed to set keys: {failed}'
|
|
145
|
+
except MemcacheError as e:
|
|
146
|
+
return f'Error setting multiple keys: {str(e)}'
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@mcp.tool()
|
|
150
|
+
async def cache_set_multi(mapping: Dict[str, Any], expire: Optional[int] = None) -> str:
|
|
151
|
+
"""Set multiple values in the cache (alias for set_many).
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
mapping: Dictionary of key-value pairs
|
|
155
|
+
expire: Optional expiration time in seconds
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
Success message or error message
|
|
159
|
+
"""
|
|
160
|
+
return await cache_set_many(mapping, expire)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@mcp.tool()
|
|
164
|
+
async def cache_add(key: str, value: Any, expire: Optional[int] = None) -> str:
|
|
165
|
+
"""Add a value to the cache only if the key doesn't exist.
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
key: The key to add
|
|
169
|
+
value: The value to store
|
|
170
|
+
expire: Optional expiration time in seconds
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
Success message or error message
|
|
174
|
+
"""
|
|
175
|
+
try:
|
|
176
|
+
client = MemcachedConnectionManager.get_connection()
|
|
177
|
+
if client.add(key, value, expire=expire):
|
|
178
|
+
expiry_msg = f' with {expire}s expiry' if expire else ''
|
|
179
|
+
return f"Successfully added key '{key}'{expiry_msg}"
|
|
180
|
+
return f"Key '{key}' already exists"
|
|
181
|
+
except MemcacheError as e:
|
|
182
|
+
return f"Error adding key '{key}': {str(e)}"
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@mcp.tool()
|
|
186
|
+
async def cache_replace(key: str, value: Any, expire: Optional[int] = None) -> str:
|
|
187
|
+
"""Replace a value in the cache only if the key exists.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
key: The key to replace
|
|
191
|
+
value: The new value
|
|
192
|
+
expire: Optional expiration time in seconds
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
Success message or error message
|
|
196
|
+
"""
|
|
197
|
+
try:
|
|
198
|
+
client = MemcachedConnectionManager.get_connection()
|
|
199
|
+
if client.replace(key, value, expire=expire):
|
|
200
|
+
expiry_msg = f' with {expire}s expiry' if expire else ''
|
|
201
|
+
return f"Successfully replaced key '{key}'{expiry_msg}"
|
|
202
|
+
return f"Key '{key}' not found"
|
|
203
|
+
except MemcacheError as e:
|
|
204
|
+
return f"Error replacing key '{key}': {str(e)}"
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
@mcp.tool()
|
|
208
|
+
async def cache_append(key: str, value: str) -> str:
|
|
209
|
+
"""Append a string to an existing value.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
key: The key to append to
|
|
213
|
+
value: String to append
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
Success message or error message
|
|
217
|
+
"""
|
|
218
|
+
try:
|
|
219
|
+
client = MemcachedConnectionManager.get_connection()
|
|
220
|
+
if client.append(key, value):
|
|
221
|
+
return f"Successfully appended to key '{key}'"
|
|
222
|
+
return f"Key '{key}' not found or not a string"
|
|
223
|
+
except MemcacheError as e:
|
|
224
|
+
return f"Error appending to key '{key}': {str(e)}"
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@mcp.tool()
|
|
228
|
+
async def cache_prepend(key: str, value: str) -> str:
|
|
229
|
+
"""Prepend a string to an existing value.
|
|
230
|
+
|
|
231
|
+
Args:
|
|
232
|
+
key: The key to prepend to
|
|
233
|
+
value: String to prepend
|
|
234
|
+
|
|
235
|
+
Returns:
|
|
236
|
+
Success message or error message
|
|
237
|
+
"""
|
|
238
|
+
try:
|
|
239
|
+
client = MemcachedConnectionManager.get_connection()
|
|
240
|
+
if client.prepend(key, value):
|
|
241
|
+
return f"Successfully prepended to key '{key}'"
|
|
242
|
+
return f"Key '{key}' not found or not a string"
|
|
243
|
+
except MemcacheError as e:
|
|
244
|
+
return f"Error prepending to key '{key}': {str(e)}"
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
@mcp.tool()
|
|
248
|
+
async def cache_delete(key: str) -> str:
|
|
249
|
+
"""Delete a value from the cache.
|
|
250
|
+
|
|
251
|
+
Args:
|
|
252
|
+
key: The key to delete
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
Success message or error message
|
|
256
|
+
"""
|
|
257
|
+
try:
|
|
258
|
+
client = MemcachedConnectionManager.get_connection()
|
|
259
|
+
if client.delete(key):
|
|
260
|
+
return f"Successfully deleted key '{key}'"
|
|
261
|
+
return f"Key '{key}' not found"
|
|
262
|
+
except MemcacheError as e:
|
|
263
|
+
return f"Error deleting key '{key}': {str(e)}"
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
@mcp.tool()
|
|
267
|
+
async def cache_delete_many(keys: List[str]) -> str:
|
|
268
|
+
"""Delete multiple values from the cache.
|
|
269
|
+
|
|
270
|
+
Args:
|
|
271
|
+
keys: List of keys to delete
|
|
272
|
+
|
|
273
|
+
Returns:
|
|
274
|
+
Success message or error message
|
|
275
|
+
"""
|
|
276
|
+
try:
|
|
277
|
+
client = MemcachedConnectionManager.get_connection()
|
|
278
|
+
failed = client.delete_many(keys)
|
|
279
|
+
if not failed:
|
|
280
|
+
return f'Successfully deleted {len(keys)} keys'
|
|
281
|
+
return f'Failed to delete keys: {failed}'
|
|
282
|
+
except MemcacheError as e:
|
|
283
|
+
return f'Error deleting multiple keys: {str(e)}'
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@mcp.tool()
|
|
287
|
+
async def cache_delete_multi(keys: List[str]) -> str:
|
|
288
|
+
"""Delete multiple values from the cache (alias for delete_many).
|
|
289
|
+
|
|
290
|
+
Args:
|
|
291
|
+
keys: List of keys to delete
|
|
292
|
+
|
|
293
|
+
Returns:
|
|
294
|
+
Success message or error message
|
|
295
|
+
"""
|
|
296
|
+
return await cache_delete_many(keys)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
@mcp.tool()
|
|
300
|
+
async def cache_incr(key: str, value: int = 1) -> str:
|
|
301
|
+
"""Increment a counter in the cache.
|
|
302
|
+
|
|
303
|
+
Args:
|
|
304
|
+
key: The key to increment
|
|
305
|
+
value: Amount to increment by (default 1)
|
|
306
|
+
|
|
307
|
+
Returns:
|
|
308
|
+
New value or error message
|
|
309
|
+
"""
|
|
310
|
+
try:
|
|
311
|
+
client = MemcachedConnectionManager.get_connection()
|
|
312
|
+
result = client.incr(key, value)
|
|
313
|
+
if result is None:
|
|
314
|
+
return f"Key '{key}' not found or not a counter"
|
|
315
|
+
return str(result)
|
|
316
|
+
except MemcacheError as e:
|
|
317
|
+
return f"Error incrementing key '{key}': {str(e)}"
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
@mcp.tool()
|
|
321
|
+
async def cache_decr(key: str, value: int = 1) -> str:
|
|
322
|
+
"""Decrement a counter in the cache.
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
key: The key to decrement
|
|
326
|
+
value: Amount to decrement by (default 1)
|
|
327
|
+
|
|
328
|
+
Returns:
|
|
329
|
+
New value or error message
|
|
330
|
+
"""
|
|
331
|
+
try:
|
|
332
|
+
client = MemcachedConnectionManager.get_connection()
|
|
333
|
+
result = client.decr(key, value)
|
|
334
|
+
if result is None:
|
|
335
|
+
return f"Key '{key}' not found or not a counter"
|
|
336
|
+
return str(result)
|
|
337
|
+
except MemcacheError as e:
|
|
338
|
+
return f"Error decrementing key '{key}': {str(e)}"
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
@mcp.tool()
|
|
342
|
+
async def cache_touch(key: str, expire: int) -> str:
|
|
343
|
+
"""Update the expiration time for a key.
|
|
344
|
+
|
|
345
|
+
Args:
|
|
346
|
+
key: The key to update
|
|
347
|
+
expire: New expiration time in seconds
|
|
348
|
+
|
|
349
|
+
Returns:
|
|
350
|
+
Success message or error message
|
|
351
|
+
"""
|
|
352
|
+
try:
|
|
353
|
+
client = MemcachedConnectionManager.get_connection()
|
|
354
|
+
if client.touch(key, expire):
|
|
355
|
+
return f"Successfully updated expiry for key '{key}' to {expire}s"
|
|
356
|
+
return f"Key '{key}' not found"
|
|
357
|
+
except MemcacheError as e:
|
|
358
|
+
return f"Error touching key '{key}': {str(e)}"
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
@mcp.tool()
|
|
362
|
+
async def cache_stats(args: Optional[List[str]] = None) -> str:
|
|
363
|
+
"""Get cache statistics.
|
|
364
|
+
|
|
365
|
+
Args:
|
|
366
|
+
args: Optional list of stats to retrieve
|
|
367
|
+
|
|
368
|
+
Returns:
|
|
369
|
+
Statistics or error message
|
|
370
|
+
"""
|
|
371
|
+
try:
|
|
372
|
+
client = MemcachedConnectionManager.get_connection()
|
|
373
|
+
result = client.stats(*args if args else [])
|
|
374
|
+
return str(result)
|
|
375
|
+
except MemcacheError as e:
|
|
376
|
+
return f'Error getting stats: {str(e)}'
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
@mcp.tool()
|
|
380
|
+
async def cache_flush_all(delay: int = 0) -> str:
|
|
381
|
+
"""Flush all cache entries.
|
|
382
|
+
|
|
383
|
+
Args:
|
|
384
|
+
delay: Optional delay in seconds before flushing
|
|
385
|
+
|
|
386
|
+
Returns:
|
|
387
|
+
Success message or error message
|
|
388
|
+
"""
|
|
389
|
+
try:
|
|
390
|
+
client = MemcachedConnectionManager.get_connection()
|
|
391
|
+
client.flush_all(delay=delay)
|
|
392
|
+
delay_msg = f' with {delay}s delay' if delay else ''
|
|
393
|
+
return f'Successfully flushed all cache entries{delay_msg}'
|
|
394
|
+
except MemcacheError as e:
|
|
395
|
+
return f'Error flushing cache: {str(e)}'
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
@mcp.tool()
|
|
399
|
+
async def cache_quit() -> str:
|
|
400
|
+
"""Close the connection to the cache server.
|
|
401
|
+
|
|
402
|
+
Returns:
|
|
403
|
+
Success message or error message
|
|
404
|
+
"""
|
|
405
|
+
try:
|
|
406
|
+
client = MemcachedConnectionManager.get_connection()
|
|
407
|
+
client.quit()
|
|
408
|
+
MemcachedConnectionManager.close_connection()
|
|
409
|
+
return 'Successfully closed connection'
|
|
410
|
+
except MemcacheError as e:
|
|
411
|
+
return f'Error closing connection: {str(e)}'
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
@mcp.tool()
|
|
415
|
+
async def cache_version() -> str:
|
|
416
|
+
"""Get the version of the cache server.
|
|
417
|
+
|
|
418
|
+
Returns:
|
|
419
|
+
Version string or error message
|
|
420
|
+
"""
|
|
421
|
+
try:
|
|
422
|
+
client = MemcachedConnectionManager.get_connection()
|
|
423
|
+
result = client.version()
|
|
424
|
+
return str(result)
|
|
425
|
+
except MemcacheError as e:
|
|
426
|
+
return f'Error getting version: {str(e)}'
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: awslabs.memcached-mcp-server
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: An AWS Labs Model Context Protocol (MCP) server for Amazon ElastiCache Memcached
|
|
5
|
+
Project-URL: homepage, https://awslabs.github.io/mcp/
|
|
6
|
+
Project-URL: docs, https://awslabs.github.io/mcp/servers/memcached-mcp-server/
|
|
7
|
+
Project-URL: documentation, https://awslabs.github.io/mcp/servers/memcached-mcp-server/
|
|
8
|
+
Project-URL: repository, https://github.com/awslabs/mcp.git
|
|
9
|
+
Project-URL: changelog, https://github.com/awslabs/mcp/blob/main/src/memcached-mcp-server/CHANGELOG.md
|
|
10
|
+
Author: Amazon Web Services
|
|
11
|
+
Author-email: AWSLabs MCP <203918161+awslabs-mcp@users.noreply.github.com>, seaofawareness <utkarshshah@gmail.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
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: loguru>=0.7.0
|
|
25
|
+
Requires-Dist: mcp[cli]>=1.6.0
|
|
26
|
+
Requires-Dist: pydantic>=2.10.6
|
|
27
|
+
Requires-Dist: pymemcache>=4.0.0
|
|
28
|
+
Requires-Dist: python-dotenv>=0.9.9
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# Memcached MCP Server
|
|
32
|
+
|
|
33
|
+
MCP server for interacting with Amazon ElastiCache Memcached through a secure and reliable connection
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
### Complete Memcached Protocol Support
|
|
38
|
+
|
|
39
|
+
- Full support for all standard Memcached operations
|
|
40
|
+
- Secure communication with SSL/TLS encryption
|
|
41
|
+
- Automatic connection management and pooling
|
|
42
|
+
- Built-in retry mechanism for failed operations
|
|
43
|
+
|
|
44
|
+
### Robust Connection Management
|
|
45
|
+
|
|
46
|
+
- Configurable connection settings and timeouts
|
|
47
|
+
- Automatic connection retrying with customizable parameters
|
|
48
|
+
- Connection pooling for improved performance
|
|
49
|
+
- Comprehensive error handling and recovery
|
|
50
|
+
|
|
51
|
+
### Security and Reliability
|
|
52
|
+
|
|
53
|
+
- SSL/TLS support for encrypted communication
|
|
54
|
+
- Certificate-based authentication
|
|
55
|
+
- Configurable verification settings
|
|
56
|
+
- Automatic handling of connection failures
|
|
57
|
+
|
|
58
|
+
## Prerequisites
|
|
59
|
+
|
|
60
|
+
1. Install `uv` from [Astral](https://docs.astral.sh/uv/getting-started/installation/) or the [GitHub README](https://github.com/astral-sh/uv#installation)
|
|
61
|
+
2. Install Python using `uv python install 3.10`
|
|
62
|
+
3. Access to a Memcached server (local or Amazon ElastiCache)
|
|
63
|
+
- For Amazon ElastiCache, you need appropriate AWS credentials and permissions
|
|
64
|
+
- For local development, ensure Memcached is installed and running
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
Here are some ways you can work with MCP (e.g. for Amazon Q Developer CLI MCP, `~/.aws/amazonq/mcp.json`):
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"mcpServers": {
|
|
73
|
+
"awslabs.memcached-mcp-server": {
|
|
74
|
+
"command": "uvx",
|
|
75
|
+
"args": ["awslabs.memcached-mcp-server@latest"],
|
|
76
|
+
"env": {
|
|
77
|
+
"FASTMCP_LOG_LEVEL": "ERROR",
|
|
78
|
+
"MEMCACHED_HOST": "your-memcached-host",
|
|
79
|
+
"MEMCACHED_PORT": "11211"
|
|
80
|
+
},
|
|
81
|
+
"disabled": false,
|
|
82
|
+
"autoApprove": []
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
or docker after a successful `docker build -t awslabs/memcached-mcp-server .`:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"awslabs.memcached-mcp-server": {
|
|
94
|
+
"command": "docker",
|
|
95
|
+
"args": [
|
|
96
|
+
"run",
|
|
97
|
+
"--rm",
|
|
98
|
+
"--interactive",
|
|
99
|
+
"--env",
|
|
100
|
+
"FASTMCP_LOG_LEVEL=ERROR",
|
|
101
|
+
"--env",
|
|
102
|
+
"MEMCACHED_HOST=your-memcached-host",
|
|
103
|
+
"--env",
|
|
104
|
+
"MEMCACHED_PORT=11211",
|
|
105
|
+
"awslabs/memcached-mcp-server:latest"
|
|
106
|
+
],
|
|
107
|
+
"env": {},
|
|
108
|
+
"disabled": false,
|
|
109
|
+
"autoApprove": []
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
### Basic Connection Settings
|
|
118
|
+
|
|
119
|
+
Configure the connection using these environment variables:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Basic settings
|
|
123
|
+
MEMCACHED_HOST=127.0.0.1 # Memcached server hostname
|
|
124
|
+
MEMCACHED_PORT=11211 # Memcached server port
|
|
125
|
+
MEMCACHED_TIMEOUT=1 # Operation timeout in seconds
|
|
126
|
+
MEMCACHED_CONNECT_TIMEOUT=5 # Connection timeout in seconds
|
|
127
|
+
MEMCACHED_RETRY_TIMEOUT=1 # Retry delay in seconds
|
|
128
|
+
MEMCACHED_MAX_RETRIES=3 # Maximum number of retry attempts
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### SSL/TLS Configuration
|
|
132
|
+
|
|
133
|
+
Enable and configure SSL/TLS support with these variables:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# SSL/TLS settings
|
|
137
|
+
MEMCACHED_USE_TLS=true # Enable SSL/TLS
|
|
138
|
+
MEMCACHED_TLS_CERT_PATH=/path/to/client-cert.pem # Client certificate
|
|
139
|
+
MEMCACHED_TLS_KEY_PATH=/path/to/client-key.pem # Client private key
|
|
140
|
+
MEMCACHED_TLS_CA_CERT_PATH=/path/to/ca-cert.pem # CA certificate
|
|
141
|
+
MEMCACHED_TLS_VERIFY=true # Enable cert verification
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The server automatically handles:
|
|
145
|
+
- Connection establishment and management
|
|
146
|
+
- SSL/TLS encryption when enabled
|
|
147
|
+
- Automatic retrying of failed operations
|
|
148
|
+
- Timeout enforcement and error handling
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
awslabs/__init__.py,sha256=47wJeKcStxEJwX7SVVV2pnAWYR8FxcaYoT3YTmZ5Plg,674
|
|
2
|
+
awslabs/memcached_mcp_server/__init__.py,sha256=D_E0pVUBpiPlnOQ5tR2T4vyLicn7wvNUYkTWgMxT9y4,617
|
|
3
|
+
awslabs/memcached_mcp_server/main.py,sha256=CJ_FUQ8_ej1mR-LS1GTQit1NB-CrH6nKWi8eCT3gbj4,2322
|
|
4
|
+
awslabs/memcached_mcp_server/common/config.py,sha256=8onPAqIuxVqMg-8Sq2IoKteGPFpJe5biOv_LVc-VvL8,149
|
|
5
|
+
awslabs/memcached_mcp_server/common/connection.py,sha256=rTNQTVnojDooBVs5syLMbrhxOTcDcFApEzD1tlDE77Y,3088
|
|
6
|
+
awslabs/memcached_mcp_server/common/server.py,sha256=dAUIguTwnU6puNdh2S5QEhT9XuVnB6uMfoZXJ9vrDoQ,589
|
|
7
|
+
awslabs/memcached_mcp_server/tools/cache.py,sha256=gvpRMx68czsFDAC4XcVyoZqLa3kypuF50jEBxWujMA8,12155
|
|
8
|
+
awslabs_memcached_mcp_server-0.1.1.dist-info/METADATA,sha256=IWE0CFolNGgAHm3pkIW2153IF8Fgc1Zc_bcuIBsycIY,4827
|
|
9
|
+
awslabs_memcached_mcp_server-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
+
awslabs_memcached_mcp_server-0.1.1.dist-info/entry_points.txt,sha256=x6K67VGAgFFTQYPtjI4GfE9EpeNNKP1rudtrMd4SGaQ,90
|
|
11
|
+
awslabs_memcached_mcp_server-0.1.1.dist-info/licenses/LICENSE,sha256=CeipvOyAZxBGUsFoaFqwkx54aPnIKEtm9a5u2uXxEws,10142
|
|
12
|
+
awslabs_memcached_mcp_server-0.1.1.dist-info/licenses/NOTICE,sha256=Wxt-EHT4RdVQIf79fYjNk-uwPDYiRwXxH_QNfGIG5Lg,96
|
|
13
|
+
awslabs_memcached_mcp_server-0.1.1.dist-info/RECORD,,
|
|
@@ -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.
|