teryt-mcp 0.1.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/README.md +96 -0
- package/dist/chunk-YEPFIU35.js +2434 -0
- package/dist/cli.d.ts +30 -0
- package/dist/cli.js +127 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +6 -0
- package/package.json +47 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as _mcp_craftman_core from '@mcp-craftman/core';
|
|
3
|
+
import { RuntimeConfig } from '@mcp-craftman/node';
|
|
4
|
+
|
|
5
|
+
type DatasetCode = "TERC" | "SIMC" | "ULIC" | "WMRODZ";
|
|
6
|
+
|
|
7
|
+
type SourceFile = {
|
|
8
|
+
readonly dataset: DatasetCode;
|
|
9
|
+
readonly content: Uint8Array;
|
|
10
|
+
readonly sourceUrl: string;
|
|
11
|
+
readonly stateDate: string;
|
|
12
|
+
};
|
|
13
|
+
type TerytSource = {
|
|
14
|
+
readonly download: (dataset: DatasetCode) => Promise<SourceFile>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type CreateAppOverrides = {
|
|
18
|
+
readonly syncSource?: TerytSource;
|
|
19
|
+
};
|
|
20
|
+
declare function createApp(config?: RuntimeConfig, overrides?: CreateAppOverrides): _mcp_craftman_core.McpApp;
|
|
21
|
+
|
|
22
|
+
type CliIo = {
|
|
23
|
+
readonly appFactory?: typeof createApp;
|
|
24
|
+
readonly env: NodeJS.ProcessEnv;
|
|
25
|
+
readonly stderr: NodeJS.WritableStream;
|
|
26
|
+
readonly stdout: NodeJS.WritableStream;
|
|
27
|
+
};
|
|
28
|
+
declare function runCli(argv?: readonly string[], io?: CliIo): Promise<void>;
|
|
29
|
+
|
|
30
|
+
export { runCli };
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
createApp,
|
|
4
|
+
getServerStatus,
|
|
5
|
+
serve
|
|
6
|
+
} from "./chunk-YEPFIU35.js";
|
|
7
|
+
|
|
8
|
+
// src/cli.ts
|
|
9
|
+
import { basename } from "path";
|
|
10
|
+
import { loadRuntimeConfig } from "@mcp-craftman/node";
|
|
11
|
+
import { callTool, mcpCraftmanCoreVersion } from "@mcp-craftman/core";
|
|
12
|
+
async function runCli(argv = process.argv.slice(2), io = defaultIo()) {
|
|
13
|
+
const [command, ...args] = argv;
|
|
14
|
+
if (command === "serve") {
|
|
15
|
+
await serve(loadRuntimeConfig(io.env));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (command === "status") {
|
|
19
|
+
const config = loadRuntimeConfig(io.env);
|
|
20
|
+
writeJson(
|
|
21
|
+
io.stdout,
|
|
22
|
+
getServerStatus({
|
|
23
|
+
dataDir: config.dataDir,
|
|
24
|
+
frameworkVersion: mcpCraftmanCoreVersion,
|
|
25
|
+
transport: config.transport
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (command === "source-status") {
|
|
31
|
+
await writeCliToolResult(io.stdout, "source_status", {}, io);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (command === "sync") {
|
|
35
|
+
await writeCliToolResult(io.stdout, "sync_database", { mode: parseSyncMode(args) }, io);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (command === "search") {
|
|
39
|
+
await runSearchCommand(args, io);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`Unknown command: ${command ?? "<missing>"}`);
|
|
43
|
+
}
|
|
44
|
+
function writeJson(stream, value) {
|
|
45
|
+
stream.write(`${JSON.stringify(value, null, 2)}
|
|
46
|
+
`);
|
|
47
|
+
}
|
|
48
|
+
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);
|
|
51
|
+
}
|
|
52
|
+
function defaultIo() {
|
|
53
|
+
return {
|
|
54
|
+
env: process.env,
|
|
55
|
+
stderr: process.stderr,
|
|
56
|
+
stdout: process.stdout
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function runSearchCommand(args, io) {
|
|
60
|
+
const [scope, ...queryParts] = args;
|
|
61
|
+
if (scope !== "places") {
|
|
62
|
+
throw new Error("search requires scope: places.");
|
|
63
|
+
}
|
|
64
|
+
const { limit, query } = parseSearchArgs(queryParts);
|
|
65
|
+
await writeCliToolResult(
|
|
66
|
+
io.stdout,
|
|
67
|
+
"search_places",
|
|
68
|
+
{
|
|
69
|
+
limit,
|
|
70
|
+
query
|
|
71
|
+
},
|
|
72
|
+
io
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
function parseSearchArgs(args) {
|
|
76
|
+
const queryParts = [];
|
|
77
|
+
let limit;
|
|
78
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
79
|
+
const value = args[index];
|
|
80
|
+
if (value === "--limit") {
|
|
81
|
+
limit = parseLimit(args[index + 1]);
|
|
82
|
+
index += 1;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
queryParts.push(value ?? "");
|
|
86
|
+
}
|
|
87
|
+
const query = queryParts.join(" ").trim();
|
|
88
|
+
if (!query) {
|
|
89
|
+
throw new Error("search places requires query.");
|
|
90
|
+
}
|
|
91
|
+
return limit === void 0 ? { query } : { limit, query };
|
|
92
|
+
}
|
|
93
|
+
function parseLimit(value) {
|
|
94
|
+
const limit = Number(value);
|
|
95
|
+
if (!Number.isInteger(limit) || limit < 1) {
|
|
96
|
+
throw new Error("search --limit requires a positive integer.");
|
|
97
|
+
}
|
|
98
|
+
return limit;
|
|
99
|
+
}
|
|
100
|
+
function parseSyncMode(args) {
|
|
101
|
+
if (args.includes("--force")) {
|
|
102
|
+
return "force";
|
|
103
|
+
}
|
|
104
|
+
const modeIndex = args.indexOf("--mode");
|
|
105
|
+
if (modeIndex >= 0) {
|
|
106
|
+
const mode = args[modeIndex + 1];
|
|
107
|
+
if (mode === "missing" || mode === "stale" || mode === "force") {
|
|
108
|
+
return mode;
|
|
109
|
+
}
|
|
110
|
+
throw new Error("sync --mode requires: missing | stale | force.");
|
|
111
|
+
}
|
|
112
|
+
return "missing";
|
|
113
|
+
}
|
|
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()) {
|
|
119
|
+
runCli().catch((error) => {
|
|
120
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
121
|
+
`);
|
|
122
|
+
process.exitCode = 1;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
runCli
|
|
127
|
+
};
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "teryt-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "MCP server for the official Polish TERYT registry.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"packageManager": "pnpm@10.12.1",
|
|
8
|
+
"bin": {
|
|
9
|
+
"teryt-mcp": "dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
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
|
+
"dependencies": {
|
|
25
|
+
"@mcp-craftman/core": "^0.1.1",
|
|
26
|
+
"@mcp-craftman/node": "^0.1.1",
|
|
27
|
+
"fflate": "^0.8.3",
|
|
28
|
+
"sql.js": "^1.14.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@mcp-craftman/cli": "^0.1.1",
|
|
32
|
+
"@types/node": "^24.0.3",
|
|
33
|
+
"@types/sql.js": "^1.4.11",
|
|
34
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
35
|
+
"dependency-cruiser": "^13.1.5",
|
|
36
|
+
"eslint": "^9.29.0",
|
|
37
|
+
"eslint-plugin-sonarjs": "^3.0.3",
|
|
38
|
+
"knip": "^5.61.3",
|
|
39
|
+
"tsup": "^8.5.0",
|
|
40
|
+
"typescript": "^5.8.3",
|
|
41
|
+
"typescript-eslint": "^8.34.1",
|
|
42
|
+
"vitest": "^3.2.4"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20.19.0"
|
|
46
|
+
}
|
|
47
|
+
}
|