@uniquedomains/mcp-server 0.0.0-stage → 0.1.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Unique Domains
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,248 @@
1
- # Temporary Holding Version
1
+ # Unique Domains MCP server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An MCP server for the [Unique Domains API](https://unique.domains/api). It lets an AI assistant read domain names, words, TLDs, registrar prices, the domain market, trends and the industry agenda from the Unique Domains catalog.
4
+
5
+ Every tool reads stored data as of its day. None registers, buys or changes a name.
6
+
7
+ - Hosted, no install and no key: `https://mcp.unique.domains/mcp`
8
+ - On your machine: `npx -y @uniquedomains/mcp-server`
9
+
10
+ ## Connect your assistant
11
+
12
+ ### Claude
13
+
14
+ In Claude (web or Desktop), open Settings, then Connectors, add a custom connector and paste `https://mcp.unique.domains/mcp`. No sign-in is needed.
15
+
16
+ To run it on your machine instead, add this to Claude Desktop's `claude_desktop_config.json`:
17
+
18
+ ```json
19
+ {
20
+ "mcpServers": {
21
+ "uniquedomains": { "command": "npx", "args": ["-y", "@uniquedomains/mcp-server"] }
22
+ }
23
+ }
24
+ ```
25
+
26
+ ### Claude Code
27
+
28
+ ```bash
29
+ claude mcp add --transport http uniquedomains https://mcp.unique.domains/mcp
30
+ ```
31
+
32
+ Or on your machine, with a member key:
33
+
34
+ ```bash
35
+ claude mcp add uniquedomains -e UD_API_KEY=ud_live_your_key -- npx -y @uniquedomains/mcp-server
36
+ ```
37
+
38
+ ### Cursor
39
+
40
+ [Add to Cursor](https://cursor.com/en/install-mcp?name=uniquedomains&config=eyJ1cmwiOiJodHRwczovL21jcC51bmlxdWUuZG9tYWlucy9tY3AifQ==) (the direct link is `cursor://anysphere.cursor-deeplink/mcp/install?name=uniquedomains&config=eyJ1cmwiOiJodHRwczovL21jcC51bmlxdWUuZG9tYWlucy9tY3AifQ==`), or put this in `.cursor/mcp.json`:
41
+
42
+ ```json
43
+ {
44
+ "mcpServers": {
45
+ "uniquedomains": { "url": "https://mcp.unique.domains/mcp" }
46
+ }
47
+ }
48
+ ```
49
+
50
+ ### VS Code
51
+
52
+ ```bash
53
+ code --add-mcp '{"name":"uniquedomains","type":"http","url":"https://mcp.unique.domains/mcp"}'
54
+ ```
55
+
56
+ Or in `.vscode/mcp.json`:
57
+
58
+ ```json
59
+ {
60
+ "servers": {
61
+ "uniquedomains": { "type": "http", "url": "https://mcp.unique.domains/mcp" }
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### ChatGPT
67
+
68
+ With developer mode on (Settings, Apps and Connectors, Advanced settings), create a connector with the URL `https://mcp.unique.domains/mcp` and no authentication.
69
+
70
+ ### Any other client
71
+
72
+ Streamable HTTP at `https://mcp.unique.domains/mcp`, or stdio with `npx -y @uniquedomains/mcp-server`.
73
+
74
+ ## Free tools and a member key
75
+
76
+ Without a key, the server answers what the Unique Domains website shows anyone: a name's status and registry record, an ending's facts, registrar prices, market aggregates, trends and the agenda.
77
+
78
+ A member key adds the keyed tools of its plan, the Founder or the Investor plan. Create the key in Unique Domains under Settings, Account, API, then pass it to the server on your machine:
79
+
80
+ ```bash
81
+ UD_API_KEY=ud_live_your_key npx -y @uniquedomains/mcp-server
82
+ ```
83
+
84
+ The server reads the key's plan once at start and lists the tools that plan opens. The plans are described at [unique.domains/api](https://unique.domains/api).
85
+
86
+ The hosted connector serves the free tools only and takes no key. Three free tools are on the npm server only (`ud_get_market_sales_word`, `ud_get_word_market`, `ud_list_tld_prices`): each answers one word or one ending a caller a day, and the hosted connector is one caller for all its users.
87
+
88
+ ## What an answer holds
89
+
90
+ - `structuredContent`: the API's `data`, `meta` and `links`, as the tool's output schema describes them.
91
+ - `content`: one line for a reader (the name and its headline fact, or the row count and the first names), then the same JSON as text.
92
+ - `links.details`: the public Unique Domains page about the subject, when there is one (hosted connector).
93
+ - A list answers 20 rows by default. When `meta.cursor` is set, pass it as `cursor` to read the next page.
94
+ - A refusal is a sentence the assistant can act on: what was wrong, what is accepted, or when a limit resets.
95
+
96
+ ## The same data elsewhere
97
+
98
+ - The API reference: [unique.domains/api](https://unique.domains/api)
99
+ - The SDK and the command line: [UniqueDomains/nodejs](https://github.com/UniqueDomains/nodejs) (`@uniquedomains/sdk`, `@uniquedomains/cli`)
100
+ - The open datasets on GitHub: [one-word domains](https://github.com/uniquedomains/oneword-domains), [expiring one-word domains](https://github.com/uniquedomains/expiring-oneword-domains), [the daily editions](https://github.com/uniquedomains/trending-domains-business-ideas), [the 2026 new gTLD applications](https://github.com/uniquedomains/new-gtld-applications-2026) and [the rest of the organization](https://github.com/uniquedomains)
101
+
102
+ ## Tools
103
+
104
+ <!-- tools:start (generated by scripts/generate.mjs) -->
105
+
106
+ 56 tools answer without a key (53 on the hosted connector); a member key adds 25 more, the Investor ones for an Investor key only.
107
+
108
+ | Tool | What it reads | Needs |
109
+ |---|---|---|
110
+ | `ud_get_name` | Stored answer for one domain name | free |
111
+ | `ud_batch_names` | Keyed name resource for up to 100 names in one call | Investor key |
112
+ | `ud_check_name` | Reads one name live from its registry and a registrar | member key |
113
+ | `ud_get_name_prices` | Every stored registrar quote for one name | member key |
114
+ | `ud_get_name_registry` | Latest stored registry record of one name | free |
115
+ | `ud_get_name_registry_history` | Stored registry record versions of one name and what moved between them | Investor key |
116
+ | `ud_get_name_dns` | Latest stored DNS reading of one name | free |
117
+ | `ud_list_name_changes` | Change events of one name, newest first | Investor key |
118
+ | `ud_get_name_history` | Web history of one name as our bands | Investor key |
119
+ | `ud_get_name_value` | Stored value estimate of one name and its last 20 estimates | member key |
120
+ | `ud_appraise_name` | Runs the appraisal of one stored name when its estimate is missing | Investor key |
121
+ | `ud_get_name_comps` | Similar-sales aggregate of one name and the endings its word sold on | free |
122
+ | `ud_get_name_auction` | Open auction of one name, if any | free |
123
+ | `ud_resolve_word` | Turns what a caller typed into the catalog word it names | free |
124
+ | `ud_list_word_categories` | Catalog's word categories, by name | free |
125
+ | `ud_batch_words` | Up to 100 word profiles in one call | Investor key |
126
+ | `ud_list_words` | Searches the catalog's words by text and facets | member key |
127
+ | `ud_get_word` | A word's profile | member key |
128
+ | `ud_get_word_endings` | A word's endings as the nightly update holds them | free |
129
+ | `ud_list_word_names` | A word's catalog names on the endings that sell, by name | member key |
130
+ | `ud_get_word_trademarks` | A word's trademark counts and its exact-match marks | Investor key |
131
+ | `ud_get_word_notability` | A word's Wikipedia and Wikidata facts | free |
132
+ | `ud_get_word_market` | A word's sales and auction aggregates from the nightly update | free, npm only |
133
+ | `ud_list_related_words` | A word's synonyms then related words | Investor key |
134
+ | `ud_list_word_fits` | How well the word fits each ending whose keywords list it | Investor key |
135
+ | `ud_request_word` | Brings a word into the catalog | Investor key |
136
+ | `ud_get_word_request` | State of a word request | Investor key |
137
+ | `ud_list_domains` | One-word catalog names under filters | free |
138
+ | `ud_get_domain` | One catalog name, by name or id | free |
139
+ | `ud_list_expiring_domains` | Catalog names expiring or expired, by expiry day | Investor key |
140
+ | `ud_get_domain_drops` | Names dropping on one day | free |
141
+ | `ud_list_domain_hacks` | Domain hacks | free |
142
+ | `ud_list_domain_changes` | Catalog's change feed, newest first | Investor key |
143
+ | `ud_get_catalog_stats` | Catalog headline totals for the latest day | free |
144
+ | `ud_list_tlds` | Every root TLD with its registry facts and launch phases | free |
145
+ | `ud_get_tld` | One TLD in full | free |
146
+ | `ud_get_tld_stats` | Ending's latest market rollup | free |
147
+ | `ud_list_tld_phases` | Every dated launch phase of the ending, chronological | free |
148
+ | `ud_list_tld_changes` | Ending's public registry changes, newest first | free |
149
+ | `ud_list_tld_keywords` | Keywords the catalog attaches to the ending, by type | free |
150
+ | `ud_list_tld_applications` | 2026 new gTLD round as ICANN publishes it | free |
151
+ | `ud_list_tld_application_changes` | Every recorded status or contention change of the round | free |
152
+ | `ud_get_tld_application_string` | One applied-for string | free |
153
+ | `ud_list_registrars` | Nine registrars whose daily price lists are compared | free |
154
+ | `ud_list_registrar_prices` | A registrar's list prices, alphabetical by ending | free |
155
+ | `ud_list_registrar_changes` | A registrar's confirmed list-price changes, newest first | free |
156
+ | `ud_get_registrar_footprint` | Names tracked under the registrar on the latest footprint day | member key |
157
+ | `ud_list_tld_prices` | Every registrar's list price for one ending | free, npm only |
158
+ | `ud_list_tld_price_history` | Change-only price rows of one ending, newest first | Investor key |
159
+ | `ud_list_price_changes` | Confirmed registrar price changes across the nine | free |
160
+ | `ud_list_price_traps` | Endings whose cheapest first year renews at a trap price | free |
161
+ | `ud_list_cheapest_prices` | Cheapest registrar per ending for up to 100 endings | member key |
162
+ | `ud_list_venues` | Parking and marketplace venues with a profile and their rounded footprint | free |
163
+ | `ud_get_venue` | One venue's profile with its verified listing terms | free |
164
+ | `ud_list_iana_registrars` | IANA registrar list as the registry sync stores it | free |
165
+ | `ud_get_iana_registrar` | One IANA registrar by id | free |
166
+ | `ud_get_market_sales` | Domain sales pulse as headline aggregates | free |
167
+ | `ud_list_market_sales_series` | One sales series by day, week or month, oldest first | free |
168
+ | `ud_list_market_sales_endings` | Each ending's 12-month and 30-day sales figures | free |
169
+ | `ud_get_market_sales_lengths` | Sales by label length for .com, .ai, .io and .co | free |
170
+ | `ud_list_market_sales_movers` | Up to ten words whose sales moved over the last 30 days | free |
171
+ | `ud_get_market_sales_word` | One word's sales market over 12 months | free, npm only |
172
+ | `ud_get_market_auctions` | Today's domain auctions by venue | free |
173
+ | `ud_list_market_auctions_sample` | Day's frozen sample of up to 20 single-word names at auction | free |
174
+ | `ud_list_market_auction_venues` | Seven auction venues with their verified rules and today's counts | free |
175
+ | `ud_list_market_auction_outcomes` | Confirmed auction outcomes by venue | Investor key |
176
+ | `ud_list_trends` | Every published trend with its latest edition figures and its first and last edition day | free |
177
+ | `ud_get_trend` | One trend | free |
178
+ | `ud_list_trend_categories` | Trend categories, the `category` filter of `GET /trends` | free |
179
+ | `ud_list_trend_pool` | Admitted trend candidates the editions draw from | member key |
180
+ | `ud_list_events` | Industry events of one month | free |
181
+ | `ud_get_event` | One industry event with its organizer | free |
182
+ | `ud_get_agenda` | Whole public agenda of one month | free |
183
+ | `ud_get_latest_edition` | Latest published daily edition of one page | free |
184
+ | `ud_get_edition` | One dated published edition of one page | free |
185
+ | `ud_get_meta_enums` | Every enum the payloads use, read from the code catalogs | free |
186
+ | `ud_get_meta_freshness` | How current the scanner's passes are | free |
187
+ | `ud_list_meta_datasets` | GitHub datasets and the API path serving the same rows | free |
188
+ | `ud_list_meta_trademark_classes` | 45 Nice classes a trademark is filed under | free |
189
+ | `ud_get_meta_providers` | Registrar identities and the auction venue and parking service catalogs | free |
190
+ | `ud_get_key` | Calling key's own plan, allowances and month | member key |
191
+
192
+ <!-- tools:end -->
193
+
194
+ ## Settings
195
+
196
+ | Variable | Profile | What it does |
197
+ |---|---|---|
198
+ | `UD_API_KEY` | local | A member key: adds the keyed tools of its plan. |
199
+ | `UD_MCP_PROFILE` | both | `local` (the default) or `hosted`. |
200
+ | `UD_API_BASE` | both | Another API base, for a local run of the API. |
201
+ | `UD_CONNECTOR_SECRET` | hosted | The connector's shared secret, sent as `X-UD-Connector-Secret`. |
202
+ | `UD_WELLKNOWN_FILES` | hosted | Files served under `/.well-known/`, as a JSON object (see below). |
203
+ | `PORT` | hosted | The HTTP port, 8080 by default. |
204
+
205
+ The hosted profile registers the free tools only, sends no `Authorization` header whatever `UD_API_KEY` holds, removes the `register` and `product` links from answers and adds `links.details`. Without a key (the hosted profile, or the npm server with no `UD_API_KEY`), the inputs only a key may send, such as `sort` or `prefix`, are not listed.
206
+
207
+ `UD_WELLKNOWN_FILES` maps a file name to its body (served as plain text) or to `{ "body": "...", "contentType": "..." }`, so a directory's proof takes a variable change and no deploy:
208
+
209
+ ```json
210
+ {
211
+ "openai-apps-challenge": "<the token from OpenAI's portal>",
212
+ "mcp-registry-auth": "v=MCPv1; k=ed25519; p=<public key>",
213
+ "glama.json": { "body": "{\"$schema\":\"https://glama.ai/mcp/schemas/connector.json\",\"claim\":\"<token>\"}", "contentType": "application/json" }
214
+ }
215
+ ```
216
+
217
+ ## Run the hosted connector yourself
218
+
219
+ ```bash
220
+ docker build -t uniquedomains-mcp-server .
221
+ docker run -p 8080:8080 uniquedomains-mcp-server
222
+ ```
223
+
224
+ The image runs `node dist/http.js` with `UD_MCP_PROFILE=hosted`: `POST /mcp` (stateless Streamable HTTP, plain JSON answers), `GET /healthz`, and the well-known files. Every answer is `Cache-Control: no-store`, and `/mcp` allows any origin.
225
+
226
+ The same image speaks stdio when given the stdio entry, for catalogs that inspect a server that way:
227
+
228
+ ```bash
229
+ docker run -i --rm -e UD_MCP_PROFILE=local uniquedomains-mcp-server dist/stdio.js
230
+ ```
231
+
232
+ ## Development
233
+
234
+ ```bash
235
+ npm ci
236
+ npm run build
237
+ npm test
238
+ npm run smoke
239
+ ```
240
+
241
+ - `npm run generate` rebuilds `src/generated/tools.ts`, `openapi/v1.json` and the tool list above from the API document that `@uniquedomains/sdk` ships; `-- --check` fails when they are out of date, `-- --live` compares the live document.
242
+ - `npm run smoke` runs the MCP Inspector against both transports and a fixture API; `-- --live` uses the live API.
243
+ - `npm run plugin` builds `dist/chatgpt-plugin.zip` and checks it against OpenAI's limits; it refuses while `plugin/review.json` holds placeholder texts (`npm run plugin:test` builds anyway, for CI).
244
+ - The nightly contract workflow opens its pull request with the workflow token, which needs the repository setting "Allow GitHub Actions to create and approve pull requests" (Settings, Actions, General).
245
+
246
+ ## License
247
+
248
+ MIT
@@ -0,0 +1,157 @@
1
+ import {
2
+ ConfigError,
3
+ DRAIN_LIMIT_BYTES,
4
+ HTTP_BODY_LIMIT_BYTES,
5
+ SERVER_VERSION,
6
+ createMcpServer,
7
+ prepareServer,
8
+ readConfig
9
+ } from "./chunk-LOMVELQR.js";
10
+
11
+ // src/httpApp.ts
12
+ import { createServer as createHttpServer } from "http";
13
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
14
+ var readWellKnownFiles = (env) => {
15
+ const raw = env.UD_WELLKNOWN_FILES?.trim();
16
+ const files = /* @__PURE__ */ new Map();
17
+ if (!raw) return files;
18
+ let parsed;
19
+ try {
20
+ parsed = JSON.parse(raw);
21
+ } catch {
22
+ throw new ConfigError("UD_WELLKNOWN_FILES must be a JSON object.");
23
+ }
24
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new ConfigError("UD_WELLKNOWN_FILES must be a JSON object.");
25
+ for (const [key, value] of Object.entries(parsed)) {
26
+ const name = key.replace(/^\/?(\.well-known\/)?/u, "");
27
+ if (!/^[A-Za-z0-9._-]+$/u.test(name)) throw new ConfigError(`UD_WELLKNOWN_FILES: "${key}" is not a file name.`);
28
+ if (typeof value === "string") {
29
+ files.set(name, { body: value, contentType: name.endsWith(".json") ? "application/json" : "text/plain; charset=utf-8" });
30
+ } else if (value !== null && typeof value === "object" && typeof value.body === "string") {
31
+ files.set(name, { body: value.body, contentType: typeof value.contentType === "string" ? value.contentType : "text/plain; charset=utf-8" });
32
+ } else {
33
+ throw new ConfigError(`UD_WELLKNOWN_FILES: "${key}" must be a string or { "body": string, "contentType"?: string }.`);
34
+ }
35
+ }
36
+ return files;
37
+ };
38
+ var CORS_HEADERS = {
39
+ "Access-Control-Allow-Origin": "*",
40
+ "Access-Control-Allow-Methods": "POST, GET, DELETE, OPTIONS",
41
+ "Access-Control-Allow-Headers": "Content-Type, Accept, Mcp-Protocol-Version, Mcp-Session-Id, Last-Event-ID",
42
+ "Access-Control-Expose-Headers": "Mcp-Session-Id, Mcp-Protocol-Version",
43
+ "Access-Control-Max-Age": "86400"
44
+ };
45
+ var send = (res, status, body, contentType, extra = {}) => {
46
+ res.writeHead(status, { "Content-Type": contentType, "Cache-Control": "no-store", "X-Content-Type-Options": "nosniff", ...extra });
47
+ res.end(body);
48
+ };
49
+ var sendJsonRpcError = (res, status, code, message, extra = {}) => {
50
+ send(res, status, JSON.stringify({ jsonrpc: "2.0", error: { code, message }, id: null }), "application/json", { ...CORS_HEADERS, ...extra });
51
+ };
52
+ var BodyTooLargeError = class extends Error {
53
+ };
54
+ var readBody = (req, limit) => new Promise((resolve, reject) => {
55
+ const declared = Number(req.headers["content-length"]);
56
+ if (Number.isFinite(declared) && declared > DRAIN_LIMIT_BYTES) {
57
+ req.destroy();
58
+ reject(new BodyTooLargeError());
59
+ return;
60
+ }
61
+ const chunks = [];
62
+ let size = 0;
63
+ req.on("data", (chunk) => {
64
+ size += chunk.length;
65
+ if (size > DRAIN_LIMIT_BYTES) {
66
+ req.destroy();
67
+ reject(new BodyTooLargeError());
68
+ return;
69
+ }
70
+ if (size > limit) chunks.length = 0;
71
+ else chunks.push(chunk);
72
+ });
73
+ req.on("end", () => size > limit ? reject(new BodyTooLargeError()) : resolve(Buffer.concat(chunks).toString("utf8")));
74
+ req.on("error", reject);
75
+ });
76
+ var handleMcpPost = async (prepared, req, res) => {
77
+ let parsed;
78
+ try {
79
+ const body = await readBody(req, HTTP_BODY_LIMIT_BYTES);
80
+ parsed = JSON.parse(body);
81
+ } catch (error) {
82
+ if (error instanceof BodyTooLargeError) sendJsonRpcError(res, 413, -32600, "The request body is over 1 MB.", { Connection: "close" });
83
+ else sendJsonRpcError(res, 400, -32700, "The request body is not JSON.");
84
+ return;
85
+ }
86
+ const server = createMcpServer(prepared);
87
+ const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: void 0, enableJsonResponse: true });
88
+ res.on("close", () => {
89
+ void transport.close();
90
+ void server.close();
91
+ });
92
+ for (const [name, value] of Object.entries(CORS_HEADERS)) res.setHeader(name, value);
93
+ res.setHeader("Cache-Control", "no-store");
94
+ await server.connect(transport);
95
+ await transport.handleRequest(req, res, parsed);
96
+ };
97
+ var createRequestHandler = (prepared, options) => async (req, res) => {
98
+ const url = new URL(req.url ?? "/", "http://localhost");
99
+ const path = url.pathname.replace(/\/+$/u, "") || "/";
100
+ try {
101
+ if (path === "/mcp") {
102
+ if (req.method === "OPTIONS") return send(res, 204, "", "text/plain", CORS_HEADERS);
103
+ if (req.method === "POST") return await handleMcpPost(prepared, req, res);
104
+ return sendJsonRpcError(res, 405, -32e3, "This server is stateless: send JSON-RPC requests with POST.", { Allow: "POST, OPTIONS" });
105
+ }
106
+ if (req.method !== "GET" && req.method !== "HEAD") return send(res, 405, "Method not allowed.\n", "text/plain; charset=utf-8", { Allow: "GET, HEAD" });
107
+ if (path === "/healthz") {
108
+ return send(res, 200, JSON.stringify({ ok: true, version: SERVER_VERSION, tools: prepared.tools.length }), "application/json");
109
+ }
110
+ if (path.startsWith("/.well-known/")) {
111
+ const file = options.wellKnown.get(path.slice("/.well-known/".length));
112
+ if (file) return send(res, 200, file.body, file.contentType, { "Access-Control-Allow-Origin": "*" });
113
+ return send(res, 404, "Not found.\n", "text/plain; charset=utf-8");
114
+ }
115
+ if (path === "/") {
116
+ return send(res, 200, "Unique Domains MCP server. Connect an MCP client to /mcp. Documentation: https://github.com/UniqueDomains/mcp-server\n", "text/plain; charset=utf-8");
117
+ }
118
+ return send(res, 404, "Not found.\n", "text/plain; charset=utf-8");
119
+ } catch (error) {
120
+ process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}
121
+ `);
122
+ if (!res.headersSent) sendJsonRpcError(res, 500, -32603, "The server could not answer. Try again in a minute.");
123
+ else res.end();
124
+ }
125
+ };
126
+ var assertServable = (config) => {
127
+ if (config.profile === "local" && config.apiKey !== null) {
128
+ throw new ConfigError("The HTTP server answers anyone, so it does not serve UD_API_KEY: set UD_MCP_PROFILE=hosted, or run the npm server over stdio for a member key.");
129
+ }
130
+ };
131
+ var startHttpServer = async (env = process.env) => {
132
+ const config = readConfig(env);
133
+ assertServable(config);
134
+ const wellKnown = readWellKnownFiles(env);
135
+ const prepared = await prepareServer(config);
136
+ const port = Number(env.PORT ?? 8080);
137
+ const http = createHttpServer((req, res) => void createRequestHandler(prepared, { wellKnown })(req, res));
138
+ http.listen(port, () => {
139
+ process.stdout.write(
140
+ `uniquedomains-mcp-server ${SERVER_VERSION} on :${port}, ${config.profile} profile, ${prepared.tools.length} tools, connector secret ${config.connectorSecret ? "set" : "not set"}, ${wellKnown.size} well-known files.
141
+ `
142
+ );
143
+ });
144
+ const stop = () => {
145
+ http.close(() => process.exit(0));
146
+ setTimeout(() => process.exit(0), 5e3).unref();
147
+ };
148
+ process.on("SIGTERM", stop);
149
+ process.on("SIGINT", stop);
150
+ };
151
+
152
+ export {
153
+ readWellKnownFiles,
154
+ createRequestHandler,
155
+ assertServable,
156
+ startHttpServer
157
+ };