encarapi-mcp 1.0.0

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,25 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 EnCarAPI (encarapi.com)
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.
22
+
23
+ Note: This MIT license covers the client library only. Access to the EnCarAPI
24
+ service and its data requires a valid API key and is subject to the terms at
25
+ https://encarapi.com.
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # EnCarAPI MCP server: Korean and Chinese used car data for AI assistants
2
+
3
+ [Model Context Protocol](https://modelcontextprotocol.io) server for
4
+ [EnCarAPI](https://encarapi.com). Lets Claude, Cursor, ChatGPT and other MCP clients search
5
+ **live used car listings from South Korea** (Encar, KB Chachacha, K Car) and **China**
6
+ (Dongchedi, Che168), and pull full details, inspection reports and accident records.
7
+
8
+ > **An API key is required.** Get one (5-day trial) at [encarapi.com](https://encarapi.com).
9
+ > Chinese data works with a [ChinaCarAPI](https://chinacarapi.com) key or an EnCarAPI key
10
+ > with the China add-on.
11
+
12
+ ## Tools
13
+
14
+ | Tool | What it does |
15
+ |---|---|
16
+ | `search_korean_cars` | Search Korean listings (brand, model, year, price in 10,000 KRW, mileage, fuel, accident-free, source: encar / kbc / kcar / all) |
17
+ | `get_korean_car` | Full detail for one listing (specs, options, photos, price history, seller) |
18
+ | `get_korean_inspection` | Official Korean inspection report |
19
+ | `get_korean_accident_record` | Insurance accident history and ownership changes |
20
+ | `find_korean_models` | Model name autocomplete across brands |
21
+ | `korean_filter_values` | Valid filter values |
22
+ | `search_chinese_cars` | Search Chinese listings (brand, model, year, price in CNY, mileage, city, export-ready) |
23
+ | `get_chinese_car` | Full record for one Chinese listing |
24
+ | `get_chinese_inspection` | Chinese inspection report (accident, flood, fire, EV battery) |
25
+ | `chinese_models` | Models of a brand with listing counts |
26
+
27
+ All tools are read-only.
28
+
29
+ ## Option 1: hosted (no install)
30
+
31
+ Add this URL as a remote MCP server and send your key as a Bearer token:
32
+
33
+ ```
34
+ https://mcp.encarapi.com/mcp
35
+ Authorization: Bearer YOUR_ENCARAPI_KEY
36
+ ```
37
+
38
+ Claude Code:
39
+
40
+ ```bash
41
+ claude mcp add --transport http encarapi https://mcp.encarapi.com/mcp \
42
+ --header "Authorization: Bearer YOUR_ENCARAPI_KEY"
43
+ ```
44
+
45
+ Clients that only accept a URL can use `https://mcp.encarapi.com/mcp?key=YOUR_ENCARAPI_KEY`
46
+ (the Bearer header is preferred, since URLs can end up in logs). A separate ChinaCarAPI key
47
+ goes into the `x-china-key` header.
48
+
49
+ ## Option 2: local (npx)
50
+
51
+ Claude Desktop (`claude_desktop_config.json`), Cursor (`.cursor/mcp.json`) and most other
52
+ clients:
53
+
54
+ ```json
55
+ {
56
+ "mcpServers": {
57
+ "encarapi": {
58
+ "command": "npx",
59
+ "args": ["-y", "encarapi-mcp"],
60
+ "env": {
61
+ "ENCARAPI_KEY": "YOUR_ENCARAPI_KEY"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ Claude Code:
69
+
70
+ ```bash
71
+ claude mcp add encarapi -e ENCARAPI_KEY=YOUR_ENCARAPI_KEY -- npx -y encarapi-mcp
72
+ ```
73
+
74
+ Optional: `CHINACARAPI_KEY` for a separate ChinaCarAPI key.
75
+
76
+ ## Example prompts
77
+
78
+ - "Find accident-free Genesis GV80 from 2022 or newer under 50 million KRW and compare the mileage."
79
+ - "Show the inspection report and accident record for Encar listing 41000001."
80
+ - "What are the cheapest export-ready BYD Seal listings in China right now?"
81
+
82
+ ## Self-hosting the HTTP endpoint
83
+
84
+ ```bash
85
+ docker build -t encarapi-mcp .
86
+ docker run -p 3000:3000 encarapi-mcp # POST /mcp, GET /health
87
+ ```
88
+
89
+ Stateless: every request carries its own key, nothing is stored.
90
+
91
+ ## Links
92
+
93
+ - EnCarAPI: https://encarapi.com
94
+ - ChinaCarAPI: https://chinacarapi.com
95
+ - SDKs: [Node.js](https://github.com/ThatMojo/encarapi-node), [Python](https://github.com/ThatMojo/encarapi-python)
96
+
97
+ EnCarAPI is an independent service and not affiliated with Encar, KB Chachacha, K Car,
98
+ Dongchedi or Che168.
99
+
100
+ ## License
101
+
102
+ MIT
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "encarapi-mcp",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for EnCarAPI: live Korean (Encar, KB Chachacha, K Car) and Chinese (Dongchedi, Che168) used car listings for Claude, Cursor and other AI assistants.",
5
+ "type": "module",
6
+ "main": "src/server.js",
7
+ "bin": {
8
+ "encarapi-mcp": "src/stdio.js"
9
+ },
10
+ "files": [
11
+ "src"
12
+ ],
13
+ "scripts": {
14
+ "start": "node src/stdio.js",
15
+ "start:http": "node src/http.js",
16
+ "test": "node test/offline.test.js"
17
+ },
18
+ "mcpName": "io.github.ThatMojo/encarapi-mcp",
19
+ "keywords": [
20
+ "mcp",
21
+ "model context protocol",
22
+ "mcp server",
23
+ "encar",
24
+ "encar api",
25
+ "kbchacha",
26
+ "kcar",
27
+ "korean car api",
28
+ "china car api",
29
+ "che168",
30
+ "dongchedi",
31
+ "used cars",
32
+ "car export",
33
+ "claude",
34
+ "cursor"
35
+ ],
36
+ "homepage": "https://encarapi.com",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/ThatMojo/encarapi-mcp.git"
40
+ },
41
+ "bugs": {
42
+ "url": "https://github.com/ThatMojo/encarapi-mcp/issues"
43
+ },
44
+ "author": "EnCarAPI (https://encarapi.com)",
45
+ "license": "MIT",
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "dependencies": {
50
+ "@modelcontextprotocol/sdk": "^1.32.0",
51
+ "encarapi": "^1.0.0",
52
+ "zod": "^4.1.0"
53
+ }
54
+ }
package/src/http.js ADDED
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+ // Hosted MCP endpoint (Streamable HTTP, stateless). Each request brings its own
3
+ // key: "Authorization: Bearer <key>", "x-api-key: <key>" or "?key=<key>" for
4
+ // clients that only accept a URL. Optional "x-china-key" for a separate
5
+ // ChinaCarAPI key. Nothing is stored server-side.
6
+ import http from "node:http";
7
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
8
+ import { createServer, VERSION } from "./server.js";
9
+
10
+ const PORT = Number(process.env.PORT || 3000);
11
+ const MAX_BODY = 1024 * 1024;
12
+
13
+ function keysFrom(req, url) {
14
+ const auth = req.headers.authorization || "";
15
+ const bearer = auth.toLowerCase().startsWith("bearer ") ? auth.slice(7).trim() : "";
16
+ return {
17
+ apiKey: bearer || req.headers["x-api-key"] || url.searchParams.get("key") || undefined,
18
+ chinaKey: req.headers["x-china-key"] || url.searchParams.get("china_key") || undefined,
19
+ };
20
+ }
21
+
22
+ function readJson(req) {
23
+ return new Promise((resolve, reject) => {
24
+ let size = 0;
25
+ const chunks = [];
26
+ req.on("data", (c) => {
27
+ size += c.length;
28
+ if (size > MAX_BODY) {
29
+ reject(new Error("body too large"));
30
+ req.destroy();
31
+ } else chunks.push(c);
32
+ });
33
+ req.on("end", () => {
34
+ try {
35
+ resolve(chunks.length ? JSON.parse(Buffer.concat(chunks).toString("utf8")) : undefined);
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ });
40
+ req.on("error", reject);
41
+ });
42
+ }
43
+
44
+ const send = (res, status, body) => {
45
+ res.writeHead(status, { "Content-Type": "application/json" });
46
+ res.end(JSON.stringify(body));
47
+ };
48
+
49
+ const httpServer = http.createServer(async (req, res) => {
50
+ const url = new URL(req.url, "http://localhost");
51
+
52
+ if (url.pathname === "/health") return send(res, 200, { ok: true, version: VERSION });
53
+ if (url.pathname === "/" && req.method === "GET") {
54
+ res.writeHead(302, { Location: "https://github.com/ThatMojo/encarapi-mcp" });
55
+ return res.end();
56
+ }
57
+ if (url.pathname !== "/mcp") return send(res, 404, { error: "Not found. MCP endpoint: /mcp" });
58
+
59
+ // Stateless mode: no sessions, so GET (SSE stream) and DELETE are not offered.
60
+ if (req.method !== "POST") {
61
+ res.writeHead(405, { Allow: "POST" });
62
+ return res.end();
63
+ }
64
+
65
+ const { apiKey, chinaKey } = keysFrom(req, url);
66
+ if (!apiKey && !chinaKey) {
67
+ return send(res, 401, {
68
+ jsonrpc: "2.0",
69
+ error: { code: -32001, message: "API key required: Authorization: Bearer <key> (get one at https://encarapi.com)" },
70
+ id: null,
71
+ });
72
+ }
73
+
74
+ let body;
75
+ try {
76
+ body = await readJson(req);
77
+ } catch {
78
+ return send(res, 400, { jsonrpc: "2.0", error: { code: -32700, message: "Parse error" }, id: null });
79
+ }
80
+
81
+ const server = createServer({ apiKey, chinaKey });
82
+ const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });
83
+ res.on("close", () => {
84
+ transport.close();
85
+ server.close();
86
+ });
87
+ try {
88
+ await server.connect(transport);
89
+ await transport.handleRequest(req, res, body);
90
+ } catch (e) {
91
+ console.error("mcp request failed:", e?.message);
92
+ if (!res.headersSent) send(res, 500, { jsonrpc: "2.0", error: { code: -32603, message: "Internal error" }, id: null });
93
+ }
94
+ });
95
+
96
+ httpServer.listen(PORT, () => console.log(`encarapi-mcp HTTP on :${PORT} (POST /mcp)`));
package/src/server.js ADDED
@@ -0,0 +1,264 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import encarapi from "encarapi";
4
+
5
+ const { KoreaClient, ChinaClient } = encarapi;
6
+
7
+ export const VERSION = "1.0.0";
8
+ const MAX_TEXT = 40000;
9
+
10
+ const asText = (data) => {
11
+ let text = typeof data === "string" ? data : JSON.stringify(data, null, 1);
12
+ if (text.length > MAX_TEXT) text = text.slice(0, MAX_TEXT) + "\n... (truncated)";
13
+ return { content: [{ type: "text", text }] };
14
+ };
15
+
16
+ const asError = (e) => ({
17
+ isError: true,
18
+ content: [{ type: "text", text: e?.body ? `${e.message}` : String(e?.message || e) }],
19
+ });
20
+
21
+ const firstPhoto = (photos) => {
22
+ const p = Array.isArray(photos) ? photos[0] : null;
23
+ if (!p) return undefined;
24
+ return typeof p === "string" ? p : p.url || p.location || p.Url || undefined;
25
+ };
26
+
27
+ // Compact, English-first view of a Korean catalog item for LLM context.
28
+ const koreaItem = (c) => ({
29
+ id: c.Id,
30
+ source: c.Source || "encar",
31
+ make: c.ManufacturerEnglish || c.Manufacturer,
32
+ model: c.ModelEnglish || c.Model,
33
+ trim: c.BadgeEnglish || c.Badge,
34
+ year: c.Year,
35
+ priceKRW: typeof c.Price === "number" ? c.Price * 10000 : undefined,
36
+ mileageKm: c.Mileage,
37
+ fuel: c.FuelTypeEnglish || c.FuelType,
38
+ transmission: c.Transmission,
39
+ powerPs: c.PowerPs,
40
+ color: c.Color,
41
+ duplicateOf: c.IsDuplicate ? c.DuplicateOf : undefined,
42
+ url: c.Url,
43
+ photo: firstPhoto(c.Photos),
44
+ });
45
+
46
+ const chinaItem = (c) => ({
47
+ id: c.id,
48
+ source: c.source,
49
+ title: c.title,
50
+ make: c.make?.name,
51
+ model: c.model?.name,
52
+ trim: c.trim?.name,
53
+ modelYear: c.modelYear,
54
+ firstRegistration: c.firstRegistration,
55
+ mileageKm: c.mileageKm,
56
+ price: c.price,
57
+ city: c.city,
58
+ fuel: c.fuel,
59
+ transmission: c.transmission,
60
+ inspectionReport: c.hasInspectionReport,
61
+ url: c.url,
62
+ photo: c.image,
63
+ });
64
+
65
+ const readOnly = { readOnlyHint: true, openWorldHint: true };
66
+
67
+ /**
68
+ * Builds an MCP server for one caller. `apiKey` is an EnCarAPI key (Korean data;
69
+ * also Chinese data if it has the China add-on), `chinaKey` an optional separate
70
+ * ChinaCarAPI key.
71
+ */
72
+ export function createServer({ apiKey, chinaKey, fetchImpl } = {}) {
73
+ const server = new McpServer(
74
+ { name: "encarapi", title: "EnCarAPI - Korean & Chinese used car data", version: VERSION },
75
+ {
76
+ instructions:
77
+ "Live used car listings from South Korea (Encar, KB Chachacha, K Car) and China (Dongchedi, Che168). " +
78
+ "Korean prices are in KRW, Chinese prices in CNY with USD/EUR conversions. " +
79
+ "Use find_korean_models or korean_filter_values to get exact names before filtering. " +
80
+ "Requires an API key from https://encarapi.com (China: https://chinacarapi.com).",
81
+ }
82
+ );
83
+
84
+ const korea = apiKey ? new KoreaClient(apiKey, { fetch: fetchImpl }) : null;
85
+ const china = chinaKey || apiKey ? new ChinaClient(chinaKey || apiKey, { fetch: fetchImpl }) : null;
86
+ const needKorea = () => {
87
+ if (!korea) throw new Error("No EnCarAPI key configured (ENCARAPI_KEY). Get one at https://encarapi.com");
88
+ return korea;
89
+ };
90
+ const needChina = () => {
91
+ if (!china) throw new Error("No ChinaCarAPI key configured (CHINACARAPI_KEY). Get one at https://chinacarapi.com");
92
+ return china;
93
+ };
94
+ const run = (fn) => async (args) => {
95
+ try {
96
+ return asText(await fn(args));
97
+ } catch (e) {
98
+ return asError(e);
99
+ }
100
+ };
101
+
102
+ // -- Korea -----------------------------------------------------------------
103
+
104
+ server.registerTool(
105
+ "search_korean_cars",
106
+ {
107
+ title: "Search Korean used cars",
108
+ description:
109
+ "Search live used car listings in South Korea. Default source is Encar; 'kbc' = KB Chachacha, " +
110
+ "'kcar' = K Car, 'all' = all three deduplicated (plan-dependent). Prices are filtered in 10,000 KRW " +
111
+ "units (e.g. max_price 3000 = 30,000,000 KRW). Returns the total count and compact listings.",
112
+ inputSchema: {
113
+ source: z.enum(["encar", "kbc", "kcar", "all"]).optional().describe("Marketplace; default encar"),
114
+ manufacturer: z.string().optional().describe("Brand in English, e.g. Hyundai, Kia, Genesis, BMW. Comma = OR"),
115
+ model_group: z.string().optional().describe("Model line, e.g. Grandeur, Sorento, 5 Series"),
116
+ model: z.string().optional().describe("Specific generation"),
117
+ model_search: z.string().optional().describe("Free-text model search across brands, e.g. 'GV80' or 's63 coupe'"),
118
+ fuel: z.enum(["gasoline", "diesel", "hybrid", "electric", "lpg", "hydrogen", "other"]).optional(),
119
+ transmission: z.enum(["automatic", "manual", "cvt", "semi-automatic", "other"]).optional(),
120
+ category: z.enum(["suv", "rv", "large", "midsize", "compact", "small", "kei", "van", "light-van", "truck", "sports", "other"]).optional(),
121
+ min_year: z.number().int().optional(),
122
+ max_year: z.number().int().optional(),
123
+ min_price: z.number().int().optional().describe("Minimum price in 10,000 KRW"),
124
+ max_price: z.number().int().optional().describe("Maximum price in 10,000 KRW"),
125
+ max_mileage: z.number().int().optional().describe("Maximum mileage in km"),
126
+ frame_clean: z.boolean().optional().describe("Only cars with an accident-free chassis frame"),
127
+ no_damage_cost: z.boolean().optional().describe("Only cars with zero insurance-reported repair cost"),
128
+ has_inspection: z.boolean().optional().describe("Only cars with an official inspection report"),
129
+ sort: z.enum(["newest", "price_asc", "price_desc", "mileage_asc", "mileage_desc", "year_desc", "year_asc"]).optional(),
130
+ limit: z.number().int().min(1).max(50).optional().describe("Results per page, default 10"),
131
+ page: z.number().int().min(1).optional(),
132
+ },
133
+ annotations: readOnly,
134
+ },
135
+ run(async (args) => {
136
+ const res = await needKorea().catalog({ ...args, limit: args.limit || 10, lang: "en", count: true });
137
+ return { total: res.Count, page: args.page || 1, results: (res.SearchResults || []).map(koreaItem) };
138
+ })
139
+ );
140
+
141
+ server.registerTool(
142
+ "get_korean_car",
143
+ {
144
+ title: "Get a Korean car",
145
+ description: "Full details for one Korean listing: specs, options, photos, price history, seller. Id: Encar id, 'kbc:<id>' or 'kcar:<id>'.",
146
+ inputSchema: { id: z.string().describe("Listing id from search_korean_cars") },
147
+ annotations: readOnly,
148
+ },
149
+ run(({ id }) => needKorea().vehicle(id, { lang: "en" }))
150
+ );
151
+
152
+ server.registerTool(
153
+ "get_korean_inspection",
154
+ {
155
+ title: "Get a Korean inspection report",
156
+ description: "Official Korean inspection report (performance check) for one car: panels, frame, mechanical condition.",
157
+ inputSchema: { id: z.string() },
158
+ annotations: readOnly,
159
+ },
160
+ run(({ id }) => needKorea().inspection(id))
161
+ );
162
+
163
+ server.registerTool(
164
+ "get_korean_accident_record",
165
+ {
166
+ title: "Get a Korean accident & ownership record",
167
+ description: "Insurance accident history and ownership changes for one Korean car (own vs. other-party damage in KRW).",
168
+ inputSchema: { id: z.string() },
169
+ annotations: readOnly,
170
+ },
171
+ run(({ id }) => needKorea().record(id))
172
+ );
173
+
174
+ server.registerTool(
175
+ "find_korean_models",
176
+ {
177
+ title: "Find Korean model names",
178
+ description: "Autocomplete model names across brands (e.g. 'sorento', 'gv70'). Use the result to filter search_korean_cars.",
179
+ inputSchema: { search: z.string(), limit: z.number().int().min(1).max(50).optional() },
180
+ annotations: readOnly,
181
+ },
182
+ run(({ search, limit }) => needKorea().modelSearch(search, { limit: limit || 10 }))
183
+ );
184
+
185
+ server.registerTool(
186
+ "korean_filter_values",
187
+ {
188
+ title: "Korean filter values",
189
+ description: "Valid values for the Korean search filters (fuels, colors, categories, ...).",
190
+ inputSchema: { source: z.enum(["encar", "kbc", "kcar", "all"]).optional() },
191
+ annotations: readOnly,
192
+ },
193
+ run((args) => needKorea().enums(args))
194
+ );
195
+
196
+ // -- China -----------------------------------------------------------------
197
+
198
+ server.registerTool(
199
+ "search_chinese_cars",
200
+ {
201
+ title: "Search Chinese used cars",
202
+ description:
203
+ "Search live used car listings in China (Dongchedi and Che168, duplicates merged), in English. " +
204
+ "Prices are in CNY; results include USD and EUR conversions.",
205
+ inputSchema: {
206
+ make: z.string().optional().describe("Brand in English, e.g. BYD, Toyota, Audi"),
207
+ model: z.string().optional(),
208
+ source: z.enum(["dongchedi", "che168"]).optional(),
209
+ year_min: z.number().int().optional(),
210
+ year_max: z.number().int().optional(),
211
+ price_min: z.number().int().optional().describe("Minimum price in CNY"),
212
+ price_max: z.number().int().optional().describe("Maximum price in CNY"),
213
+ mileage_max: z.number().int().optional().describe("Maximum mileage in km"),
214
+ city: z.string().optional(),
215
+ fuel: z.string().optional(),
216
+ export_ready: z.boolean().optional().describe("Only cars that can be exported now"),
217
+ has_report: z.boolean().optional().describe("Only cars with an inspection report"),
218
+ sort: z.enum(["newest", "price_asc", "price_desc", "mileage_asc", "year_desc"]).optional(),
219
+ limit: z.number().int().min(1).max(50).optional().describe("Results per page, default 10"),
220
+ page: z.number().int().min(1).optional(),
221
+ },
222
+ annotations: readOnly,
223
+ },
224
+ run(async (args) => {
225
+ const res = await needChina().catalog({ ...args, limit: args.limit || 10 });
226
+ return { total: res.total, page: res.page, results: (res.results || []).map(chinaItem) };
227
+ })
228
+ );
229
+
230
+ server.registerTool(
231
+ "get_chinese_car",
232
+ {
233
+ title: "Get a Chinese car",
234
+ description: "Full record for one Chinese listing: price history, photos, seller, export status, same car on the other marketplace.",
235
+ inputSchema: { id: z.string().describe("Listing id from search_chinese_cars") },
236
+ annotations: readOnly,
237
+ },
238
+ run(({ id }) => needChina().vehicle(id))
239
+ );
240
+
241
+ server.registerTool(
242
+ "get_chinese_inspection",
243
+ {
244
+ title: "Get a Chinese inspection report",
245
+ description: "Inspection report for one Chinese car: accident, flood and fire checks, battery data for EVs.",
246
+ inputSchema: { id: z.string() },
247
+ annotations: readOnly,
248
+ },
249
+ run(({ id }) => needChina().inspection(id))
250
+ );
251
+
252
+ server.registerTool(
253
+ "chinese_models",
254
+ {
255
+ title: "Chinese models of a brand",
256
+ description: "Models of one brand in the Chinese catalog, with listing counts.",
257
+ inputSchema: { make: z.string().describe("Brand name in English or brand id") },
258
+ annotations: readOnly,
259
+ },
260
+ run(({ make }) => needChina().models(make))
261
+ );
262
+
263
+ return server;
264
+ }
package/src/stdio.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { createServer } from "./server.js";
4
+
5
+ const apiKey = process.env.ENCARAPI_KEY;
6
+ const chinaKey = process.env.CHINACARAPI_KEY;
7
+
8
+ if (!apiKey && !chinaKey) {
9
+ console.error(
10
+ "encarapi-mcp: set ENCARAPI_KEY (Korea, https://encarapi.com) and/or CHINACARAPI_KEY (China, https://chinacarapi.com)."
11
+ );
12
+ process.exit(1);
13
+ }
14
+
15
+ const server = createServer({ apiKey, chinaKey });
16
+ await server.connect(new StdioServerTransport());