@cyanheads/openfda-mcp-server 0.1.6

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.
Files changed (54) hide show
  1. package/CLAUDE.md +248 -0
  2. package/Dockerfile +99 -0
  3. package/LICENSE +190 -0
  4. package/README.md +281 -0
  5. package/dist/config/server-config.d.ts +14 -0
  6. package/dist/config/server-config.d.ts.map +1 -0
  7. package/dist/config/server-config.js +22 -0
  8. package/dist/config/server-config.js.map +1 -0
  9. package/dist/index.d.ts +7 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +15 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/mcp-server/tools/definitions/count.tool.d.ts +42 -0
  14. package/dist/mcp-server/tools/definitions/count.tool.d.ts.map +1 -0
  15. package/dist/mcp-server/tools/definitions/count.tool.js +106 -0
  16. package/dist/mcp-server/tools/definitions/count.tool.js.map +1 -0
  17. package/dist/mcp-server/tools/definitions/get-drug-label.tool.d.ts +21 -0
  18. package/dist/mcp-server/tools/definitions/get-drug-label.tool.d.ts.map +1 -0
  19. package/dist/mcp-server/tools/definitions/get-drug-label.tool.js +102 -0
  20. package/dist/mcp-server/tools/definitions/get-drug-label.tool.js.map +1 -0
  21. package/dist/mcp-server/tools/definitions/index.d.ts +68 -0
  22. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  23. package/dist/mcp-server/tools/definitions/index.js +21 -0
  24. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  25. package/dist/mcp-server/tools/definitions/lookup-ndc.tool.d.ts +21 -0
  26. package/dist/mcp-server/tools/definitions/lookup-ndc.tool.d.ts.map +1 -0
  27. package/dist/mcp-server/tools/definitions/lookup-ndc.tool.js +101 -0
  28. package/dist/mcp-server/tools/definitions/lookup-ndc.tool.js.map +1 -0
  29. package/dist/mcp-server/tools/definitions/search-adverse-events.tool.d.ts +26 -0
  30. package/dist/mcp-server/tools/definitions/search-adverse-events.tool.d.ts.map +1 -0
  31. package/dist/mcp-server/tools/definitions/search-adverse-events.tool.js +147 -0
  32. package/dist/mcp-server/tools/definitions/search-adverse-events.tool.js.map +1 -0
  33. package/dist/mcp-server/tools/definitions/search-device-clearances.tool.d.ts +25 -0
  34. package/dist/mcp-server/tools/definitions/search-device-clearances.tool.d.ts.map +1 -0
  35. package/dist/mcp-server/tools/definitions/search-device-clearances.tool.js +108 -0
  36. package/dist/mcp-server/tools/definitions/search-device-clearances.tool.js.map +1 -0
  37. package/dist/mcp-server/tools/definitions/search-drug-approvals.tool.d.ts +23 -0
  38. package/dist/mcp-server/tools/definitions/search-drug-approvals.tool.d.ts.map +1 -0
  39. package/dist/mcp-server/tools/definitions/search-drug-approvals.tool.js +136 -0
  40. package/dist/mcp-server/tools/definitions/search-drug-approvals.tool.js.map +1 -0
  41. package/dist/mcp-server/tools/definitions/search-recalls.tool.d.ts +30 -0
  42. package/dist/mcp-server/tools/definitions/search-recalls.tool.d.ts.map +1 -0
  43. package/dist/mcp-server/tools/definitions/search-recalls.tool.js +105 -0
  44. package/dist/mcp-server/tools/definitions/search-recalls.tool.js.map +1 -0
  45. package/dist/services/openfda/openfda-service.d.ts +25 -0
  46. package/dist/services/openfda/openfda-service.d.ts.map +1 -0
  47. package/dist/services/openfda/openfda-service.js +111 -0
  48. package/dist/services/openfda/openfda-service.js.map +1 -0
  49. package/dist/services/openfda/types.d.ts +30 -0
  50. package/dist/services/openfda/types.d.ts.map +1 -0
  51. package/dist/services/openfda/types.js +6 -0
  52. package/dist/services/openfda/types.js.map +1 -0
  53. package/package.json +88 -0
  54. package/server.json +98 -0
package/CLAUDE.md ADDED
@@ -0,0 +1,248 @@
1
+ # Agent Protocol
2
+
3
+ **Server:** openfda-mcp-server
4
+ **Version:** 0.1.6
5
+ **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
6
+
7
+ > **Read the framework docs first:** `node_modules/@cyanheads/mcp-ts-core/CLAUDE.md` contains the full API reference — builders, Context, error codes, exports, patterns. This file covers server-specific conventions only.
8
+
9
+ > **Design doc:** `docs/design.md` is the source of truth for the tool surface, error handling, config, and implementation notes. Read it before adding or modifying tools.
10
+
11
+ ---
12
+
13
+ ## What's Next?
14
+
15
+ When the user asks what to do next, what's left, or needs direction, suggest relevant options based on the current project state:
16
+
17
+ 1. **Re-run the `setup` skill** — ensures CLAUDE.md, skills, structure, and metadata are populated and up to date with the current codebase
18
+ 2. **Run the `design-mcp-server` skill** — if the tool/resource surface hasn't been mapped yet, work through domain design
19
+ 3. **Add tools/resources/prompts** — scaffold new definitions using the `add-tool`, `add-resource`, `add-prompt` skills
20
+ 4. **Add services** — scaffold domain service integrations using the `add-service` skill
21
+ 5. **Add tests** — scaffold tests for existing definitions using the `add-test` skill
22
+ 6. **Field-test definitions** — exercise tools/resources/prompts with real inputs using the `field-test` skill, get a report of issues and pain points
23
+ 7. **Run `devcheck`** — lint, format, typecheck, and security audit
24
+ 8. **Run the `polish-docs-meta` skill** — finalize README, CHANGELOG, metadata, and agent protocol for shipping
25
+ 9. **Run the `maintenance` skill** — sync skills and dependencies after framework updates
26
+
27
+ Tailor suggestions to what's actually missing or stale — don't recite the full list every time.
28
+
29
+ ---
30
+
31
+ ## Core Rules
32
+
33
+ - **Logic throws, framework catches.** Tool/resource handlers are pure — throw on failure, no `try/catch`. Plain `Error` is fine; the framework catches, classifies, and formats. Use error factories (`notFound()`, `validationError()`, etc.) when the error code matters.
34
+ - **Use `ctx.log`** for request-scoped logging. No `console` calls.
35
+ - **Secrets in env vars only** — never hardcoded.
36
+
37
+ ---
38
+
39
+ ## Patterns
40
+
41
+ ### Tool
42
+
43
+ ```ts
44
+ import { tool, z } from '@cyanheads/mcp-ts-core';
45
+ import { getOpenFdaService } from '@/services/openfda/openfda-service.js';
46
+
47
+ export const countTool = tool('openfda_count', {
48
+ description: 'Aggregate and tally unique values for any field across any openFDA endpoint.',
49
+ annotations: { readOnlyHint: true },
50
+ input: z.object({
51
+ endpoint: z.enum(['drug/event', 'drug/label', /* ... */]).describe('openFDA endpoint path'),
52
+ count: z.string().describe('Field to count. Append .exact for whole-phrase counting'),
53
+ search: z.string().optional().describe('Filter query to scope the count'),
54
+ limit: z.number().min(1).max(1000).default(100).optional().describe('Top terms to return'),
55
+ }),
56
+ output: z.object({
57
+ meta: z.object({ lastUpdated: z.string().describe('Dataset last updated date') }),
58
+ results: z.array(z.object({
59
+ term: z.string().describe('Field value'),
60
+ count: z.number().describe('Number of occurrences'),
61
+ })).describe('Term-count pairs sorted by count descending'),
62
+ }),
63
+
64
+ async handler(input, ctx) {
65
+ const svc = getOpenFdaService();
66
+ const response = await svc.query(input.endpoint, { search: input.search, count: input.count, limit: input.limit }, ctx);
67
+ ctx.log.info('Count query completed', { endpoint: input.endpoint, terms: response.results.length });
68
+ return { meta: { lastUpdated: response.meta.lastUpdated }, results: response.results.map(r => ({ term: String(r.term), count: r.count as number })) };
69
+ },
70
+
71
+ // format() populates content[] — the only field most LLM clients forward to
72
+ // the model. Render all data the LLM needs, not just a count or title.
73
+ format: (result) => [{
74
+ type: 'text',
75
+ text: result.results.map((r, i) => `${i + 1}. ${r.term}: ${r.count}`).join('\n'),
76
+ }],
77
+ });
78
+ ```
79
+
80
+ ### Server config
81
+
82
+ ```ts
83
+ // src/config/server-config.ts — lazy-parsed, separate from framework config
84
+ const ServerConfigSchema = z.object({
85
+ apiKey: z.string().optional().describe('openFDA API key — increases daily limit from 1K to 120K requests'),
86
+ baseUrl: z.string().default('https://api.fda.gov').describe('openFDA base URL'),
87
+ });
88
+ let _config: z.infer<typeof ServerConfigSchema> | undefined;
89
+ export function getServerConfig() {
90
+ _config ??= ServerConfigSchema.parse({
91
+ apiKey: process.env.OPENFDA_API_KEY,
92
+ baseUrl: process.env.OPENFDA_BASE_URL,
93
+ });
94
+ return _config;
95
+ }
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Context
101
+
102
+ Handlers receive a unified `ctx` object. Key properties:
103
+
104
+ | Property | Description |
105
+ |:---------|:------------|
106
+ | `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
107
+ | `ctx.signal` | `AbortSignal` for cancellation. Used by the openFDA service for request timeouts and retry abort. |
108
+ | `ctx.requestId` | Unique request ID. Passed to the service layer for retry context. |
109
+ | `ctx.tenantId` | Tenant ID from JWT or `'default'` for stdio. |
110
+
111
+ ---
112
+
113
+ ## Errors
114
+
115
+ Handlers throw — the framework catches, classifies, and formats. Three escalation levels:
116
+
117
+ ```ts
118
+ // 1. Plain Error — framework auto-classifies from message patterns
119
+ throw new Error('Item not found'); // → NotFound
120
+ throw new Error('Invalid query format'); // → ValidationError
121
+
122
+ // 2. Error factories — explicit code, concise
123
+ import { notFound, validationError, forbidden, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
124
+ throw notFound('Item not found', { itemId });
125
+ throw serviceUnavailable('API unavailable', { url }, { cause: err });
126
+
127
+ // 3. McpError — full control over code and data
128
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
129
+ throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
130
+ ```
131
+
132
+ Plain `Error` is fine for most cases. Use factories when the error code matters. See framework CLAUDE.md for the full auto-classification table and all available factories.
133
+
134
+ ---
135
+
136
+ ## Structure
137
+
138
+ ```text
139
+ src/
140
+ index.ts # createApp() entry point
141
+ config/
142
+ server-config.ts # Server-specific env vars (Zod schema)
143
+ services/
144
+ openfda/
145
+ openfda-service.ts # openFDA API client (retry, rate-limit, error normalization)
146
+ types.ts # Query params and response types
147
+ mcp-server/
148
+ tools/definitions/
149
+ count.tool.ts # openfda_count
150
+ get-drug-label.tool.ts # openfda_get_drug_label
151
+ lookup-ndc.tool.ts # openfda_lookup_ndc
152
+ search-adverse-events.tool.ts # openfda_search_adverse_events
153
+ search-device-clearances.tool.ts # openfda_search_device_clearances
154
+ search-drug-approvals.tool.ts # openfda_search_drug_approvals
155
+ search-recalls.tool.ts # openfda_search_recalls
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Naming
161
+
162
+ | What | Convention | Example |
163
+ |:-----|:-----------|:--------|
164
+ | Files | kebab-case with suffix | `search-recalls.tool.ts` |
165
+ | Tool/resource/prompt names | snake_case | `openfda_search_recalls` |
166
+ | Directories | kebab-case | `src/services/openfda/` |
167
+ | Descriptions | Single string or template literal, no `+` concatenation | `'Search enforcement reports and recall actions.'` |
168
+
169
+ ---
170
+
171
+ ## Skills
172
+
173
+ Skills are modular instructions in `skills/` at the project root. Read them directly when a task matches — e.g., `skills/add-tool/SKILL.md` when adding a tool.
174
+
175
+ **Agent skill directory:** Copy skills into the directory your agent discovers (Claude Code: `.claude/skills/`, others: equivalent). This makes skills available as context without needing to reference `skills/` paths manually. After framework updates, re-copy to pick up changes.
176
+
177
+ Available skills:
178
+
179
+ | Skill | Purpose |
180
+ |:------|:--------|
181
+ | `setup` | Post-init project orientation |
182
+ | `design-mcp-server` | Design tool surface, resources, and services for a new server |
183
+ | `add-tool` | Scaffold a new tool definition |
184
+ | `add-resource` | Scaffold a new resource definition |
185
+ | `add-prompt` | Scaffold a new prompt definition |
186
+ | `add-service` | Scaffold a new service integration |
187
+ | `add-test` | Scaffold test file for a tool, resource, or service |
188
+ | `field-test` | Exercise tools/resources/prompts with real inputs, verify behavior, report issues |
189
+ | `devcheck` | Lint, format, typecheck, audit |
190
+ | `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
191
+ | `maintenance` | Sync skills and dependencies after updates |
192
+ | `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
193
+ | `report-issue-local` | File a bug or feature request against this server's own repo via `gh` CLI |
194
+ | `api-auth` | Auth modes, scopes, JWT/OAuth |
195
+ | `api-config` | AppConfig, parseConfig, env vars |
196
+ | `api-context` | Context interface, logger, state, progress |
197
+ | `api-errors` | McpError, JsonRpcErrorCode, error patterns |
198
+ | `api-services` | LLM, Speech, Graph services |
199
+ | `api-testing` | createMockContext, test patterns |
200
+ | `api-utils` | Formatting, parsing, security, pagination, scheduling |
201
+ | `api-workers` | Cloudflare Workers runtime |
202
+
203
+ When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
204
+
205
+ ---
206
+
207
+ ## Commands
208
+
209
+ | Command | Purpose |
210
+ |:--------|:--------|
211
+ | `bun run build` | Compile TypeScript |
212
+ | `bun run rebuild` | Clean + build |
213
+ | `bun run clean` | Remove build artifacts |
214
+ | `bun run devcheck` | Lint + format + typecheck + security |
215
+ | `bun run tree` | Generate directory structure doc |
216
+ | `bun run format` | Auto-fix formatting |
217
+ | `bun run test` | Run tests (Vitest) |
218
+ | `bun run dev:stdio` | Dev mode (stdio) |
219
+ | `bun run dev:http` | Dev mode (HTTP) |
220
+ | `bun run start:stdio` | Production mode (stdio) |
221
+ | `bun run start:http` | Production mode (HTTP) |
222
+
223
+ ---
224
+
225
+ ## Imports
226
+
227
+ ```ts
228
+ // Framework — z is re-exported, no separate zod import needed
229
+ import { tool, z } from '@cyanheads/mcp-ts-core';
230
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
231
+
232
+ // Server's own code — via path alias
233
+ import { getOpenFdaService } from '@/services/openfda/openfda-service.js';
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Checklist
239
+
240
+ - [ ] Zod schemas: all fields have `.describe()`, only JSON-Schema-serializable types (no `z.custom()`, `z.date()`, `z.transform()`, etc.)
241
+ - [ ] Optional nested objects: handler guards for empty inner values from form-based clients (`if (input.obj?.field && ...)`, not just `if (input.obj)`)
242
+ - [ ] JSDoc `@fileoverview` + `@module` on every file
243
+ - [ ] `ctx.log` for logging, `ctx.signal` for cancellation
244
+ - [ ] Handlers throw on failure — error factories or plain `Error`, no try/catch
245
+ - [ ] `format()` renders all data the LLM needs — `content[]` is the only field most clients forward to the model
246
+ - [ ] Registered in `createApp()` arrays (directly or via barrel exports)
247
+ - [ ] Tests use `createMockContext()` from `@cyanheads/mcp-ts-core/testing`
248
+ - [ ] `bun run devcheck` passes
package/Dockerfile ADDED
@@ -0,0 +1,99 @@
1
+ # ==============================================================================
2
+ # Build Stage
3
+ #
4
+ # This stage installs all dependencies (including dev), builds the TypeScript
5
+ # source code into JavaScript, and prepares the production assets.
6
+ # ==============================================================================
7
+ FROM oven/bun:1 AS build
8
+
9
+ WORKDIR /usr/src/app
10
+
11
+ # Copy dependency manifests for optimized layer caching
12
+ COPY package.json bun.lock ./
13
+
14
+ # Install all dependencies (including dev dependencies for building)
15
+ RUN bun install --frozen-lockfile
16
+
17
+ # Copy the rest of the source code
18
+ COPY . .
19
+
20
+ # Build the application
21
+ RUN bun run build
22
+
23
+
24
+ # ==============================================================================
25
+ # Production Stage
26
+ #
27
+ # This stage creates a minimal, optimized, and secure image for running the
28
+ # application. It uses a slim base image and only includes production
29
+ # dependencies and build artifacts.
30
+ # ==============================================================================
31
+ FROM oven/bun:1-slim AS production
32
+
33
+ WORKDIR /usr/src/app
34
+
35
+ # Set the environment to production for performance and to ensure only
36
+ # production dependencies are installed.
37
+ ENV NODE_ENV=production
38
+
39
+ # OCI image metadata (https://github.com/opencontainers/image-spec/blob/main/annotations.md)
40
+ LABEL org.opencontainers.image.title="openfda-mcp-server"
41
+ LABEL org.opencontainers.image.description="MCP server for querying FDA data on drugs, food, devices, and recalls via openFDA."
42
+ LABEL org.opencontainers.image.source="https://github.com/cyanheads/openfda-mcp-server"
43
+ LABEL org.opencontainers.image.licenses="Apache-2.0"
44
+
45
+ # Copy dependency manifests
46
+ COPY package.json bun.lock ./
47
+
48
+ # Install only production dependencies, ignoring any lifecycle scripts (like 'prepare')
49
+ # that are not needed in the final production image.
50
+ RUN bun install --production --frozen-lockfile --ignore-scripts
51
+
52
+ # Conditionally install OpenTelemetry optional peer dependencies (Tier 3).
53
+ # These are not bundled by default to keep the base image lean. Enable at build time
54
+ # with: docker build --build-arg OTEL_ENABLED=true
55
+ ARG OTEL_ENABLED=true
56
+ RUN if [ "$OTEL_ENABLED" = "true" ]; then \
57
+ bun add @hono/otel \
58
+ @opentelemetry/instrumentation-http \
59
+ @opentelemetry/exporter-metrics-otlp-http \
60
+ @opentelemetry/exporter-trace-otlp-http \
61
+ @opentelemetry/instrumentation-pino \
62
+ @opentelemetry/resources \
63
+ @opentelemetry/sdk-metrics \
64
+ @opentelemetry/sdk-node \
65
+ @opentelemetry/sdk-trace-node \
66
+ @opentelemetry/semantic-conventions; \
67
+ fi
68
+
69
+ # Copy the compiled application code from the build stage
70
+ COPY --from=build /usr/src/app/dist ./dist
71
+
72
+ # The 'oven/bun' image already provides a non-root user named 'bun'.
73
+ # We will use this existing user for enhanced security.
74
+
75
+ # Create and set permissions for the log directory, assigning ownership to the 'bun' user.
76
+ RUN mkdir -p /var/log/openfda-mcp-server && chown -R bun:bun /var/log/openfda-mcp-server
77
+
78
+ # Switch to the non-root user
79
+ USER bun
80
+
81
+ # Define an argument for the port, allowing it to be overridden at build time.
82
+ # The `PORT` variable is often injected by cloud environments at runtime.
83
+ ARG PORT
84
+
85
+ # Set runtime environment variables
86
+ # Note: PORT is an automatic variable in many cloud environments (e.g., Cloud Run)
87
+ ENV MCP_HTTP_PORT=${PORT:-3010}
88
+ ENV MCP_HTTP_HOST="0.0.0.0"
89
+ ENV MCP_TRANSPORT_TYPE="http"
90
+ ENV MCP_SESSION_MODE="stateless"
91
+ ENV MCP_LOG_LEVEL="info"
92
+ ENV LOGS_DIR="/var/log/openfda-mcp-server"
93
+ ENV MCP_FORCE_CONSOLE_LOGGING="true"
94
+
95
+ # Expose the port the server listens on
96
+ EXPOSE ${MCP_HTTP_PORT}
97
+
98
+ # The command to start the server
99
+ CMD ["bun", "run", "dist/index.js"]
package/LICENSE ADDED
@@ -0,0 +1,190 @@
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 the 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 the 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 any 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
+ Copyright 2025 cyanheads
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.