mcp-hydrolix 0.1.6__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.
mcp_hydrolix/utils.py ADDED
@@ -0,0 +1,70 @@
1
+ import inspect
2
+ import ipaddress
3
+ import json
4
+ from datetime import datetime, time
5
+ from decimal import Decimal
6
+ from functools import wraps
7
+
8
+ import fastmcp.utilities.types
9
+ from fastmcp.tools.tool import ToolResult
10
+
11
+
12
+ class ExtendedEncoder(json.JSONEncoder):
13
+ """Extends JSONEncoder to apply custom serialization of CH data types."""
14
+
15
+ def default(self, obj):
16
+ if isinstance(obj, ipaddress.IPv4Address):
17
+ return str(obj)
18
+ if isinstance(obj, datetime):
19
+ return obj.time()
20
+ if isinstance(obj, time):
21
+ return obj.hour * 3600 + obj.minute * 60 + obj.second + obj.microsecond / 1_000_000
22
+ if isinstance(obj, bytes):
23
+ return obj.decode()
24
+ if isinstance(obj, Decimal):
25
+ return str(obj)
26
+ return super().default(obj)
27
+
28
+
29
+ def with_serializer(fn):
30
+ """
31
+ Decorator to apply custom serialization to CH query tool result.
32
+ Should be applied as a first decorator of the tool function.
33
+
34
+ :returns: sync/async wrapper of mcp tool function
35
+ """
36
+
37
+ @wraps(fn)
38
+ def wrapper(*args, **kwargs):
39
+ """
40
+ Sync wrapper of mcpt tool `fn` function.
41
+ Function should return a dict or None.
42
+
43
+ :returns: ToolResult object with text-serialized and structured content.
44
+ """
45
+ result = fn(*args, **kwargs)
46
+ if not isinstance(result, dict):
47
+ result = {"result": result}
48
+ enc = json.dumps(result, cls=ExtendedEncoder)
49
+ return ToolResult(content=enc, structured_content=json.loads(enc))
50
+
51
+ @wraps(fn)
52
+ async def async_wrapper(*args, **kwargs):
53
+ """
54
+ Async wrapper of mcp tool `fn` function.
55
+ Function should return a dict or None.
56
+
57
+ :returns: ToolResult object with text-serialized and structured content.
58
+ """
59
+ result = await fn(*args, **kwargs)
60
+ if not isinstance(result, dict):
61
+ result = {"result": result}
62
+ enc = json.dumps(result, cls=ExtendedEncoder)
63
+ return ToolResult(content=enc, structured_content=json.loads(enc))
64
+
65
+ # TODO: remove next signature fix code when a new fastmcp released (https://github.com/jlowin/fastmcp/issues/2524)
66
+ new_fn = fastmcp.utilities.types.create_function_without_params(fn, ["ctx"])
67
+ sig = inspect.signature(new_fn)
68
+ async_wrapper.__signature__ = sig
69
+ wrapper.__signature__ = sig
70
+ return async_wrapper if inspect.iscoroutinefunction(fn) else wrapper
@@ -0,0 +1,314 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-hydrolix
3
+ Version: 0.1.6
4
+ Summary: An MCP server for Hydrolix.
5
+ Project-URL: Home, https://github.com/hydrolix/mcp-hydrolix
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.13
9
+ Requires-Dist: clickhouse-connect<0.11,>=0.10
10
+ Requires-Dist: fastmcp<2.15,>=2.14
11
+ Requires-Dist: gunicorn<24.0,>=23.0
12
+ Requires-Dist: pip-system-certs<5.0,>=4.0
13
+ Requires-Dist: pyjwt<2.11,>=2.10
14
+ Requires-Dist: python-dotenv<1.2,>=1.1
15
+ Provides-Extra: dev
16
+ Requires-Dist: fastapi>=0.124; extra == 'dev'
17
+ Requires-Dist: mcp-clickhouse==0.1.13; extra == 'dev'
18
+ Requires-Dist: pre-commit; extra == 'dev'
19
+ Requires-Dist: pytest; extra == 'dev'
20
+ Requires-Dist: pytest-asyncio; extra == 'dev'
21
+ Requires-Dist: pytest-repeat; extra == 'dev'
22
+ Requires-Dist: pytest-xdist; extra == 'dev'
23
+ Requires-Dist: ruff; extra == 'dev'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # Hydrolix MCP Server
27
+
28
+ [![PyPI - Version](https://img.shields.io/pypi/v/mcp-hydrolix)](https://pypi.org/project/mcp-hydrolix)
29
+
30
+ An MCP server for Hydrolix.
31
+
32
+ ## Tools
33
+
34
+ * `run_select_query`
35
+ * Execute SQL queries on your Hydrolix cluster.
36
+ * Input: `sql` (string): The SQL query to execute.
37
+ * All Hydrolix queries are run with `readonly = 1` to ensure they are safe.
38
+
39
+ * `list_databases`
40
+ * List all databases on your Hydrolix cluster.
41
+
42
+ * `list_tables`
43
+ * List all tables in a database.
44
+ * Input: `database` (string): The name of the database.
45
+
46
+ ## Effective Usage
47
+
48
+ Due to the wide variety in LLM architectures, not all models will proactively use the tools above, and few will use them effectively without guidance, even with the carefully-constructed tool descriptions provided to the model. To get the best results out of your model while using the Hydrolix MCP server, we recommend the following:
49
+
50
+ * Refer to your Hydrolix database by name and request tool usage in your prompts (e.g., "Using MCP tools to access my Hydrolix database, please ...")
51
+ - This encourages the model to use the MCP tools available and minimizes hallucinations.
52
+ * Include time ranges in your prompts (e.g., "Between December 5 2023 and January 18 2024, ...") and specifically request that the output be ordered by timestamp.
53
+ - This prompts the model to write more efficient queries that take advantage of [primary key optimizations](https://hydrolix.io/blog/optimizing-latest-n-row-queries/)
54
+
55
+ ### Health Check Endpoint
56
+
57
+ When running with HTTP or SSE transport, a health check endpoint is available at `/health`. This endpoint:
58
+ - Returns `200 OK` with the Hydrolix query-head's Clickhouse version if the server is healthy and can connect to Hydrolix
59
+ - Returns `503 Service Unavailable` if the server cannot connect to the Hydrolix query-head
60
+
61
+ Example:
62
+ ```bash
63
+ curl http://localhost:8000/health
64
+ # Response: OK - Connected to Hydrolix compatible with ClickHouse 24.3.1
65
+ ```
66
+
67
+ ## Configuration
68
+
69
+ The Hydrolix MCP server is configured using a standard MCP server entry. Consult your client's documentation for specific instructions on where to find or declare MCP servers. An example setup using Claude Desktop is documented below.
70
+
71
+ The recommended way to launch the Hydrolix MCP server is via the [`uv` project manager](https://github.com/astral-sh/uv), which will manage installing all other dependencies in an isolated environment.
72
+
73
+ ### Authentication
74
+
75
+ The server supports multiple authentication methods with the following precedence (highest to lowest):
76
+
77
+ 1. **Per-request Bearer token**: Service account token provided via `Authorization: Bearer <token>` header
78
+ 2. **Per-request GET parameter**: Service account token provided via `?token=<token>` query parameter
79
+ 3. **Environment-based credentials**: Credentials configured via environment variables
80
+ - Service account token (`HYDROLIX_TOKEN`), or
81
+ - Username and password (`HYDROLIX_USER` and `HYDROLIX_PASSWORD`)
82
+
83
+ When multiple authentication methods are configured, the server will use the first available method in the precedence order above. Per-request authentication is only available when using HTTP or SSE transport modes.
84
+
85
+ MCP Server definition using username and password (JSON):
86
+
87
+ ```json
88
+ {
89
+ "command": "uv",
90
+ "args": [
91
+ "run",
92
+ "--with",
93
+ "mcp-hydrolix",
94
+ "--python",
95
+ "3.13",
96
+ "mcp-hydrolix"
97
+ ],
98
+ "env": {
99
+ "HYDROLIX_HOST": "<hydrolix-host>",
100
+ "HYDROLIX_USER": "<hydrolix-user>",
101
+ "HYDROLIX_PASSWORD": "<hydrolix-password>"
102
+ }
103
+ }
104
+ ```
105
+
106
+ MCP Server definition using service account token (JSON):
107
+
108
+ ```json
109
+ {
110
+ "command": "uv",
111
+ "args": [
112
+ "run",
113
+ "--with",
114
+ "mcp-hydrolix",
115
+ "--python",
116
+ "3.13",
117
+ "mcp-hydrolix"
118
+ ],
119
+ "env": {
120
+ "HYDROLIX_HOST": "<hydrolix-host>",
121
+ "HYDROLIX_TOKEN": "<hydrolix-service-account-token>"
122
+ }
123
+ }
124
+ ```
125
+
126
+ MCP Server definition using username and password (YAML):
127
+
128
+ ```yaml
129
+ command: uv
130
+ args:
131
+ - run
132
+ - --with
133
+ - mcp-hydrolix
134
+ - --python
135
+ - "3.13"
136
+ - mcp-hydrolix
137
+ env:
138
+ HYDROLIX_HOST: <hydrolix-host>
139
+ HYDROLIX_USER: <hydrolix-user>
140
+ HYDROLIX_PASSWORD: <hydrolix-password>
141
+ ```
142
+
143
+ MCP Server definition using service account token (YAML):
144
+
145
+ ```yaml
146
+ command: uv
147
+ args:
148
+ - run
149
+ - --with
150
+ - mcp-hydrolix
151
+ - --python
152
+ - "3.13"
153
+ - mcp-hydrolix
154
+ env:
155
+ HYDROLIX_HOST: <hydrolix-host>
156
+ HYDROLIX_TOKEN: <hydrolix-service-account-token>
157
+ ```
158
+
159
+ ### Configuration Example (Claude Desktop)
160
+
161
+ 1. Open the Claude Desktop configuration file located at:
162
+ - On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
163
+ - On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
164
+
165
+ 2. Add a `mcp-hydrolix` server entry to the `mcpServers` config block to use username and password:
166
+
167
+ ```json
168
+ {
169
+ "mcpServers": {
170
+ "mcp-hydrolix": {
171
+ "command": "uv",
172
+ "args": [
173
+ "run",
174
+ "--with",
175
+ "mcp-hydrolix",
176
+ "--python",
177
+ "3.13",
178
+ "mcp-hydrolix"
179
+ ],
180
+ "env": {
181
+ "HYDROLIX_HOST": "<hydrolix-host>",
182
+ "HYDROLIX_USER": "<hydrolix-user>",
183
+ "HYDROLIX_PASSWORD": "<hydrolix-password>"
184
+ }
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ To leverage service account use the following config block:
191
+
192
+ ```json
193
+ {
194
+ "mcpServers": {
195
+ "mcp-hydrolix": {
196
+ "command": "uv",
197
+ "args": [
198
+ "run",
199
+ "--with",
200
+ "mcp-hydrolix",
201
+ "--python",
202
+ "3.13",
203
+ "mcp-hydrolix"
204
+ ],
205
+ "env": {
206
+ "HYDROLIX_HOST": "<hydrolix-host>",
207
+ "HYDROLIX_TOKEN": "<hydrolix-service-account-token>"
208
+ }
209
+ }
210
+ }
211
+ }
212
+ ```
213
+
214
+ 3. Update the environment variable definitions to point to your Hydrolix cluster.
215
+
216
+ 4. (Recommended) Locate the command entry for `uv` and replace it with the absolute path to the `uv` executable. This ensures that the correct version of `uv` is used when starting the server. You can find this path using `which uv` or `where.exe uv`.
217
+
218
+ 5. Restart Claude Desktop to apply the changes. If you are using Windows, ensure Claude is stopped completely by closing the client using the system tray icon.
219
+
220
+ ### Configuration Example (Claude Code)
221
+
222
+ To configure the Hydrolix MCP server for Claude Code, run the following command:
223
+
224
+ ```bash
225
+ claude mcp add --transport stdio hydrolix \
226
+ --env HYDROLIX_USER=<hydrolix-user> \
227
+ --env HYDROLIX_PASSWORD=<hydrolix-password> \
228
+ --env HYDROLIX_HOST=<hydrolix-host> \
229
+ --env HYDROLIX_MCP_SERVER_TRANSPORT=stdio \
230
+ -- uv run --with mcp-hydrolix --python 3.13 mcp-hydrolix
231
+ ```
232
+
233
+ ### Environment Variables
234
+
235
+ The following variables are used to configure the Hydrolix connection. These variables may be provided via the MCP config block (as shown above), a `.env` file, or traditional environment variables.
236
+
237
+ #### Required Variables
238
+ * `HYDROLIX_HOST`: The hostname of your Hydrolix server
239
+
240
+ #### Authentication Variables
241
+ At least one authentication method must be configured when using the stdio transport:
242
+
243
+ * `HYDROLIX_TOKEN`: Service account token for environment-based authentication
244
+ * `HYDROLIX_USER` and `HYDROLIX_PASSWORD`: Username and password for environment-based authentication (both must be provided together)
245
+
246
+ In summary:
247
+ - For stdio, you MUST use HYDROLIX_TOKEN or HYDROLIX_USER+HYDROLIX_PASS (environmental credentials)
248
+ - For http/sse, you MAY use HYDROLIX_TOKEN or HYDROLIX_USER+HYDROLIX_PASS (environmental credentials), but you may instead use per-request credentials.
249
+
250
+ If no credentials are provided via the environment or the request, the request will fail.
251
+
252
+ #### Optional Variables
253
+ * `HYDROLIX_PORT`: The port number of your Hydrolix server
254
+ * Default: `8088`
255
+ * Usually doesn't need to be set unless using a non-standard port
256
+ * `HYDROLIX_VERIFY`: Enable/disable SSL certificate verification
257
+ * Default: `"true"`
258
+ * Set to `"false"` to disable certificate verification (not recommended for production)
259
+ * `HYDROLIX_DATABASE`: Default database to use
260
+ *Default: None (uses server default)
261
+ * Set this to automatically connect to a specific database
262
+ * `HYDROLIX_MCP_SERVER_TRANSPORT`: Sets the transport method for the MCP server.
263
+ * Default: `"stdio"`
264
+ * Valid options: `"stdio"`, `"http"`, `"sse"`. This is useful for local development with tools like MCP Inspector.
265
+ * `HYDROLIX_MCP_BIND_HOST`: Host to bind the MCP server to when using HTTP or SSE transport
266
+ * Default: `"127.0.0.1"`
267
+ * Set to `"0.0.0.0"` to bind to all network interfaces (useful for Docker or remote access)
268
+ * Only used when transport is `"http"` or `"sse"`
269
+ * `HYDROLIX_MCP_BIND_PORT`: Port to bind the MCP server to when using HTTP or SSE transport
270
+ * Default: `"8000"`
271
+ * Only used when transport is `"http"` or `"sse"`
272
+
273
+
274
+ For MCP Inspector or remote access with HTTP transport:
275
+
276
+ ```env
277
+ HYDROLIX_HOST=localhost
278
+ HYDROLIX_USER=default
279
+ HYDROLIX_PASSWORD=myPassword
280
+ HYDROLIX_MCP_SERVER_TRANSPORT=http
281
+ HYDROLIX_MCP_BIND_HOST=0.0.0.0 # Bind to all interfaces
282
+ HYDROLIX_MCP_BIND_PORT=4200 # Custom port (default: 8000)
283
+ ```
284
+
285
+ When using HTTP transport, the server will run on the configured port (default 8000). For example, with the above configuration:
286
+ - MCP endpoint: `http://localhost:4200/mcp`
287
+ - Health check: `http://localhost:4200/health`
288
+
289
+ #### Using Per-Request Authentication with HTTP Transport
290
+
291
+ When using HTTP or SSE transport, you can omit environment-based credentials and instead provide authentication per-request. This is useful for multi-user scenarios or with clients that don't support running MCP servers locally.
292
+
293
+ Example `mcpServers` configuration connecting to a remote HTTP server with per-request authentication:
294
+
295
+ ```json
296
+ {
297
+ "mcpServers": {
298
+ "mcp-hydrolix-remote": {
299
+ "url": "http://my-hydrolix-mcp.example.com:8000/mcp?token=<service-account-token>"
300
+ }
301
+ }
302
+ }
303
+ ```
304
+
305
+ Example minimal `.env` configuration for running your own HTTP server without environment credentials:
306
+
307
+ ```env
308
+ HYDROLIX_HOST=my-cluster.hydrolix.net
309
+ HYDROLIX_MCP_SERVER_TRANSPORT=http
310
+ ```
311
+
312
+ Though not part of the MCP specification, many MCP clients allow adding headers to MCP-issued requests. When this is possible, we recommend configuring the MCP client to pass a service account token via the `Authorization: Bearer <sa-token-here>` header instead of as a query parameter for greater security.
313
+
314
+ Note: The bind host and port settings are only used when transport is set to "http" or "sse".
@@ -0,0 +1,17 @@
1
+ mcp_hydrolix/__init__.py,sha256=DnAQkvoFf_QhrDNFLOmn-nHlldPUgtdN33k3xJWthgc,225
2
+ mcp_hydrolix/main.py,sha256=Q58yz9ykx0bilptGALXW_Lli0pR7wDNOPib34l1z8Sg,2760
3
+ mcp_hydrolix/mcp_env.py,sha256=For5l-G67ihJJbW4d4qpZNZvhxsIfT0AXGQsg8-3BMk,11533
4
+ mcp_hydrolix/mcp_server.py,sha256=TSTKEaXoonNXvk65CD99eCFdIDY0pppO2Qr66SbCvUc,12402
5
+ mcp_hydrolix/utils.py,sha256=fMGCsRa2DqlS2PMfIpD5VaHTbaxUkW7mvgArgVViXbs,2433
6
+ mcp_hydrolix/auth/__init__.py,sha256=Ui9pLq3Z5tH8X56T_SqACRLEU9zl1gmcONWif-GV1Ko,656
7
+ mcp_hydrolix/auth/credentials.py,sha256=IK8w6TjNxS1K0LCKBt3xXOOI-0ogWCVAkiJuOzEJuJY,1915
8
+ mcp_hydrolix/auth/mcp_providers.py,sha256=4lexSj6tqCgPb5GGbuG5_wIocvSvQbqx8CHNl9D6OCA,5194
9
+ mcp_hydrolix/log/__init__.py,sha256=1K-ycdGrawELMLSBeiqE8bV3-SFJYOE0dD_U3PAP2QM,119
10
+ mcp_hydrolix/log/log.py,sha256=6KX0oSz-BbCWUoPxbJED4sZBmbgCHa3KDrc5nYtdks4,1838
11
+ mcp_hydrolix/log/log.yaml,sha256=ldw66lGkQjqyJ92gJqOtdP63T_3MSD_ndKU1p8Xegvs,978
12
+ mcp_hydrolix/log/utils.py,sha256=gOnlo25-sGZydGJmr6T94Pb805RZ9LcZlLCRaVEuUv4,2099
13
+ mcp_hydrolix-0.1.6.dist-info/METADATA,sha256=FDfNexRS-g7bFLcjaGv-H5PlJ6erx7_4V-KTvnedxUA,11096
14
+ mcp_hydrolix-0.1.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
15
+ mcp_hydrolix-0.1.6.dist-info/entry_points.txt,sha256=vHa7F2rOCVu8lpsqR8BYbE1w8ugJSOYwX95w802Y5qE,56
16
+ mcp_hydrolix-0.1.6.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ mcp_hydrolix-0.1.6.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mcp-hydrolix = mcp_hydrolix.main:main
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.