teryt-mcp 0.1.0 → 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.
@@ -951,7 +951,7 @@ async function getPlace(input, dependencies) {
951
951
  }
952
952
 
953
953
  // src/features/get-place/mcp/get-place.tool.ts
954
- import { defineTool as defineTool2 } from "@mcp-craftman/core";
954
+ import { defineTool as defineTool2, readRequiredStringField } from "@mcp-craftman/core";
955
955
  function createGetPlaceTool(dependencies) {
956
956
  return defineTool2({
957
957
  name: "get_place",
@@ -1017,11 +1017,8 @@ function createGetPlaceTool(dependencies) {
1017
1017
  });
1018
1018
  }
1019
1019
  function parseInput(input) {
1020
- if (typeof input !== "object" || input === null || !("id" in input) || typeof input.id !== "string") {
1021
- throw new Error("get_place requires id.");
1022
- }
1023
1020
  return {
1024
- id: input.id
1021
+ id: readRequiredStringField(input, "id", "get_place")
1025
1022
  };
1026
1023
  }
1027
1024
 
@@ -1039,7 +1036,7 @@ async function getStreet(input, dependencies) {
1039
1036
  }
1040
1037
 
1041
1038
  // src/features/get-street/mcp/get-street.tool.ts
1042
- import { defineTool as defineTool3 } from "@mcp-craftman/core";
1039
+ import { defineTool as defineTool3, readRequiredStringField as readRequiredStringField2 } from "@mcp-craftman/core";
1043
1040
  function createGetStreetTool(dependencies) {
1044
1041
  return defineTool3({
1045
1042
  name: "get_street",
@@ -1108,11 +1105,8 @@ function createGetStreetTool(dependencies) {
1108
1105
  });
1109
1106
  }
1110
1107
  function parseInput2(input) {
1111
- if (typeof input !== "object" || input === null || !("id" in input) || typeof input.id !== "string") {
1112
- throw new Error("get_street requires id.");
1113
- }
1114
1108
  return {
1115
- id: input.id
1109
+ id: readRequiredStringField2(input, "id", "get_street")
1116
1110
  };
1117
1111
  }
1118
1112
 
@@ -1130,7 +1124,7 @@ async function getUnit(input, dependencies) {
1130
1124
  }
1131
1125
 
1132
1126
  // src/features/get-unit/mcp/get-unit.tool.ts
1133
- import { defineTool as defineTool4 } from "@mcp-craftman/core";
1127
+ import { defineTool as defineTool4, readRequiredStringField as readRequiredStringField3 } from "@mcp-craftman/core";
1134
1128
  function createGetUnitTool(dependencies) {
1135
1129
  return defineTool4({
1136
1130
  name: "get_unit",
@@ -1196,11 +1190,8 @@ function createGetUnitTool(dependencies) {
1196
1190
  });
1197
1191
  }
1198
1192
  function parseInput3(input) {
1199
- if (typeof input !== "object" || input === null || !("id" in input) || typeof input.id !== "string") {
1200
- throw new Error("get_unit requires id.");
1201
- }
1202
1193
  return {
1203
- id: input.id
1194
+ id: readRequiredStringField3(input, "id", "get_unit")
1204
1195
  };
1205
1196
  }
1206
1197
 
@@ -1304,7 +1295,7 @@ function normalizeName(value) {
1304
1295
  }
1305
1296
 
1306
1297
  // src/features/resolve-address/mcp/resolve-address.tool.ts
1307
- import { defineTool as defineTool6 } from "@mcp-craftman/core";
1298
+ import { defineTool as defineTool6, readOptionalNumberField, readRequiredStringField as readRequiredStringField4 } from "@mcp-craftman/core";
1308
1299
  function createResolveAddressTool(dependencies) {
1309
1300
  return defineTool6({
1310
1301
  inputSchema,
@@ -1430,16 +1421,11 @@ var outputSchema = {
1430
1421
  required: ["addresses", "stateDate"]
1431
1422
  };
1432
1423
  function parseInput4(input) {
1433
- if (typeof input !== "object" || input === null || !("query" in input) || typeof input.query !== "string") {
1434
- throw new Error("resolve_address requires query.");
1435
- }
1436
- const limit = "limit" in input ? input.limit : void 0;
1437
- if (limit !== void 0 && typeof limit !== "number") {
1438
- throw new Error("resolve_address limit must be a number.");
1439
- }
1424
+ const query = readRequiredStringField4(input, "query", "resolve_address");
1425
+ const limit = readOptionalNumberField(input, "limit", "resolve_address");
1440
1426
  return {
1441
1427
  limit,
1442
- query: input.query
1428
+ query
1443
1429
  };
1444
1430
  }
1445
1431
 
@@ -1516,7 +1502,7 @@ function normalizeName2(value) {
1516
1502
  }
1517
1503
 
1518
1504
  // src/features/search-places/mcp/search-places.tool.ts
1519
- import { defineTool as defineTool7 } from "@mcp-craftman/core";
1505
+ import { defineTool as defineTool7, readOptionalNumberField as readOptionalNumberField2, readRequiredStringField as readRequiredStringField5 } from "@mcp-craftman/core";
1520
1506
  function createSearchPlacesTool(dependencies) {
1521
1507
  return defineTool7({
1522
1508
  name: "search_places",
@@ -1597,16 +1583,11 @@ function createSearchPlacesTool(dependencies) {
1597
1583
  });
1598
1584
  }
1599
1585
  function parseInput5(input) {
1600
- if (typeof input !== "object" || input === null || !("query" in input) || typeof input.query !== "string") {
1601
- throw new Error("search_places requires query.");
1602
- }
1603
- const limit = "limit" in input ? input.limit : void 0;
1604
- if (limit !== void 0 && typeof limit !== "number") {
1605
- throw new Error("search_places limit must be a number.");
1606
- }
1586
+ const query = readRequiredStringField5(input, "query", "search_places");
1587
+ const limit = readOptionalNumberField2(input, "limit", "search_places");
1607
1588
  return {
1608
1589
  limit,
1609
- query: input.query
1590
+ query
1610
1591
  };
1611
1592
  }
1612
1593
 
@@ -1683,7 +1664,7 @@ function normalizeName3(value) {
1683
1664
  }
1684
1665
 
1685
1666
  // src/features/search-streets/mcp/search-streets.tool.ts
1686
- import { defineTool as defineTool8 } from "@mcp-craftman/core";
1667
+ import { defineTool as defineTool8, readOptionalNumberField as readOptionalNumberField3, readRequiredStringField as readRequiredStringField6 } from "@mcp-craftman/core";
1687
1668
  function createSearchStreetsTool(dependencies) {
1688
1669
  return defineTool8({
1689
1670
  inputSchema: inputSchema2,
@@ -1769,16 +1750,11 @@ var outputSchema2 = {
1769
1750
  required: ["stateDate", "streets"]
1770
1751
  };
1771
1752
  function parseInput6(input) {
1772
- if (typeof input !== "object" || input === null || !("query" in input) || typeof input.query !== "string") {
1773
- throw new Error("search_streets requires query.");
1774
- }
1775
- const limit = "limit" in input ? input.limit : void 0;
1776
- if (limit !== void 0 && typeof limit !== "number") {
1777
- throw new Error("search_streets limit must be a number.");
1778
- }
1753
+ const query = readRequiredStringField6(input, "query", "search_streets");
1754
+ const limit = readOptionalNumberField3(input, "limit", "search_streets");
1779
1755
  return {
1780
1756
  limit,
1781
- query: input.query
1757
+ query
1782
1758
  };
1783
1759
  }
1784
1760
 
@@ -1855,7 +1831,7 @@ function normalizeName4(value) {
1855
1831
  }
1856
1832
 
1857
1833
  // src/features/search-units/mcp/search-units.tool.ts
1858
- import { defineTool as defineTool9 } from "@mcp-craftman/core";
1834
+ import { defineTool as defineTool9, readOptionalNumberField as readOptionalNumberField4, readRequiredStringField as readRequiredStringField7 } from "@mcp-craftman/core";
1859
1835
  function createSearchUnitsTool(dependencies) {
1860
1836
  return defineTool9({
1861
1837
  name: "search_units",
@@ -1936,16 +1912,11 @@ function createSearchUnitsTool(dependencies) {
1936
1912
  });
1937
1913
  }
1938
1914
  function parseInput7(input) {
1939
- if (typeof input !== "object" || input === null || !("query" in input) || typeof input.query !== "string") {
1940
- throw new Error("search_units requires query.");
1941
- }
1942
- const limit = "limit" in input ? input.limit : void 0;
1943
- if (limit !== void 0 && typeof limit !== "number") {
1944
- throw new Error("search_units limit must be a number.");
1945
- }
1915
+ const query = readRequiredStringField7(input, "query", "search_units");
1916
+ const limit = readOptionalNumberField4(input, "limit", "search_units");
1946
1917
  return {
1947
1918
  limit,
1948
- query: input.query
1919
+ query
1949
1920
  };
1950
1921
  }
1951
1922
 
@@ -2402,29 +2373,11 @@ function createApp(config = loadRuntimeConfig(), overrides = {}) {
2402
2373
  }
2403
2374
 
2404
2375
  // src/server/serve.ts
2405
- import { loadRuntimeConfig as loadRuntimeConfig2 } from "@mcp-craftman/node";
2406
-
2407
- // src/server/transports/http.ts
2408
- import { startHttpServer } from "@mcp-craftman/node";
2409
- function startHttpTransport(app, options = {}) {
2410
- return startHttpServer(app, options);
2411
- }
2412
-
2413
- // src/server/transports/stdio.ts
2414
- import { startStdioServer } from "@mcp-craftman/node";
2415
- function startStdioTransport(app, options = {}) {
2416
- return startStdioServer(app, options);
2417
- }
2418
-
2419
- // src/server/serve.ts
2376
+ import { loadRuntimeConfig as loadRuntimeConfig2, serveMcpApp } from "@mcp-craftman/node";
2420
2377
  async function serve(config = loadRuntimeConfig2()) {
2421
- const app = createApp(config);
2422
- if (config.transport === "http") {
2423
- return startHttpTransport(app, {
2424
- port: config.port
2425
- });
2426
- }
2427
- return startStdioTransport(app);
2378
+ return serveMcpApp(createApp, {
2379
+ config
2380
+ });
2428
2381
  }
2429
2382
 
2430
2383
  export {
package/dist/cli.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { RuntimeConfig, CliIo } from '@mcp-craftman/node';
2
3
  import * as _mcp_craftman_core from '@mcp-craftman/core';
3
- import { RuntimeConfig } from '@mcp-craftman/node';
4
4
 
5
5
  type DatasetCode = "TERC" | "SIMC" | "ULIC" | "WMRODZ";
6
6
 
@@ -19,12 +19,9 @@ type CreateAppOverrides = {
19
19
  };
20
20
  declare function createApp(config?: RuntimeConfig, overrides?: CreateAppOverrides): _mcp_craftman_core.McpApp;
21
21
 
22
- type CliIo = {
22
+ type TerytCliIo = CliIo & {
23
23
  readonly appFactory?: typeof createApp;
24
- readonly env: NodeJS.ProcessEnv;
25
- readonly stderr: NodeJS.WritableStream;
26
- readonly stdout: NodeJS.WritableStream;
27
24
  };
28
- declare function runCli(argv?: readonly string[], io?: CliIo): Promise<void>;
25
+ declare function runCli(argv?: readonly string[], io?: TerytCliIo): Promise<void>;
29
26
 
30
27
  export { runCli };
package/dist/cli.js CHANGED
@@ -3,12 +3,17 @@ import {
3
3
  createApp,
4
4
  getServerStatus,
5
5
  serve
6
- } from "./chunk-YEPFIU35.js";
6
+ } from "./chunk-GSWKF6BK.js";
7
7
 
8
8
  // src/cli.ts
9
- import { basename } from "path";
10
- import { loadRuntimeConfig } from "@mcp-craftman/node";
11
- import { callTool, mcpCraftmanCoreVersion } from "@mcp-craftman/core";
9
+ import {
10
+ createDefaultCliIo,
11
+ isCliEntrypoint,
12
+ loadRuntimeConfig,
13
+ writeCliToolStructuredContent,
14
+ writeJson
15
+ } from "@mcp-craftman/node";
16
+ import { mcpCraftmanCoreVersion } from "@mcp-craftman/core";
12
17
  async function runCli(argv = process.argv.slice(2), io = defaultIo()) {
13
18
  const [command, ...args] = argv;
14
19
  if (command === "serve") {
@@ -41,20 +46,11 @@ async function runCli(argv = process.argv.slice(2), io = defaultIo()) {
41
46
  }
42
47
  throw new Error(`Unknown command: ${command ?? "<missing>"}`);
43
48
  }
44
- function writeJson(stream, value) {
45
- stream.write(`${JSON.stringify(value, null, 2)}
46
- `);
47
- }
48
49
  async function writeCliToolResult(stream, toolName, input, io) {
49
- const result = await callTool((io.appFactory ?? createApp)(loadRuntimeConfig(io.env)), toolName, input);
50
- writeJson(stream, result.structuredContent);
50
+ await writeCliToolStructuredContent(stream, io.appFactory ?? createApp, toolName, input, io.env);
51
51
  }
52
52
  function defaultIo() {
53
- return {
54
- env: process.env,
55
- stderr: process.stderr,
56
- stdout: process.stdout
57
- };
53
+ return createDefaultCliIo();
58
54
  }
59
55
  async function runSearchCommand(args, io) {
60
56
  const [scope, ...queryParts] = args;
@@ -111,11 +107,7 @@ function parseSyncMode(args) {
111
107
  }
112
108
  return "missing";
113
109
  }
114
- function isCliEntrypoint(argvPath = process.argv[1]) {
115
- const entrypoint = argvPath ? basename(argvPath) : "";
116
- return entrypoint === "teryt-mcp" || entrypoint === "cli.js";
117
- }
118
- if (isCliEntrypoint()) {
110
+ if (isCliEntrypoint("teryt-mcp")) {
119
111
  runCli().catch((error) => {
120
112
  process.stderr.write(`${error instanceof Error ? error.message : String(error)}
121
113
  `);
package/dist/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serve
3
- } from "./chunk-YEPFIU35.js";
3
+ } from "./chunk-GSWKF6BK.js";
4
4
 
5
5
  // src/main.ts
6
6
  await serve();
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "teryt-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "MCP server for the official Polish TERYT registry.",
6
6
  "type": "module",
7
- "packageManager": "pnpm@10.12.1",
8
7
  "bin": {
9
8
  "teryt-mcp": "dist/cli.js"
10
9
  },
@@ -15,20 +14,14 @@
15
14
  "publishConfig": {
16
15
  "access": "public"
17
16
  },
18
- "scripts": {
19
- "build": "tsup src/main.ts src/cli.ts --format esm --dts --clean",
20
- "prepare": "git rev-parse --is-inside-work-tree >/dev/null 2>&1 && git config core.hooksPath .githooks || true",
21
- "quality": "mcp-craftman quality",
22
- "test": "vitest run"
23
- },
24
17
  "dependencies": {
25
- "@mcp-craftman/core": "^0.1.1",
26
- "@mcp-craftman/node": "^0.1.1",
18
+ "@mcp-craftman/core": "^0.1.2",
19
+ "@mcp-craftman/node": "^0.1.2",
27
20
  "fflate": "^0.8.3",
28
21
  "sql.js": "^1.14.1"
29
22
  },
30
23
  "devDependencies": {
31
- "@mcp-craftman/cli": "^0.1.1",
24
+ "@mcp-craftman/cli": "^0.1.5",
32
25
  "@types/node": "^24.0.3",
33
26
  "@types/sql.js": "^1.4.11",
34
27
  "@vitest/coverage-v8": "^3.2.4",
@@ -43,5 +36,10 @@
43
36
  },
44
37
  "engines": {
45
38
  "node": ">=20.19.0"
39
+ },
40
+ "scripts": {
41
+ "build": "tsup src/main.ts src/cli.ts --format esm --dts --clean",
42
+ "quality": "mcp-craftman quality",
43
+ "test": "vitest run"
46
44
  }
47
- }
45
+ }