krs-poland-mcp-server 1.0.17 → 1.1.2
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/build/index.mjs +27 -8
- package/package.json +12 -3
package/build/index.mjs
CHANGED
|
@@ -4052,21 +4052,40 @@ var coerce = {
|
|
|
4052
4052
|
var NEVER = INVALID;
|
|
4053
4053
|
|
|
4054
4054
|
// src/utils/api.ts
|
|
4055
|
+
var USER_AGENT = "krs-mcp/1.0";
|
|
4056
|
+
var REQUEST_TIMEOUT_MS = 1e4;
|
|
4057
|
+
var RETRY_DELAYS_MS = [3e4, 6e4];
|
|
4055
4058
|
var KRS_API_BASE = "https://api-krs.ms.gov.pl/api/krs";
|
|
4056
4059
|
function buildExtractUrl(opts) {
|
|
4057
4060
|
const { type, rejestr, krs } = opts;
|
|
4058
4061
|
return `${KRS_API_BASE}/${type}/${krs}?rejestr=${rejestr}&format=json`;
|
|
4059
4062
|
}
|
|
4063
|
+
function sleep(ms) {
|
|
4064
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4065
|
+
}
|
|
4060
4066
|
async function makeKRSRequest(url) {
|
|
4061
|
-
const headers = { Accept: "application/json" };
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4067
|
+
const headers = { Accept: "application/json", "User-Agent": USER_AGENT };
|
|
4068
|
+
const maxAttempts = RETRY_DELAYS_MS.length + 1;
|
|
4069
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
4070
|
+
const controller = new AbortController();
|
|
4071
|
+
const timeoutId = setTimeout(() => controller.abort(new Error("Request timeout")), REQUEST_TIMEOUT_MS);
|
|
4072
|
+
try {
|
|
4073
|
+
const res = await fetch(url, { headers, signal: controller.signal });
|
|
4074
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
4075
|
+
return await res.json();
|
|
4076
|
+
} catch (err) {
|
|
4077
|
+
if (attempt === maxAttempts - 1) {
|
|
4078
|
+
console.error("KRS request error:", err);
|
|
4079
|
+
return null;
|
|
4080
|
+
}
|
|
4081
|
+
console.error("KRS request error (will retry):", err);
|
|
4082
|
+
const delay = RETRY_DELAYS_MS[attempt] ?? RETRY_DELAYS_MS[RETRY_DELAYS_MS.length - 1];
|
|
4083
|
+
await sleep(delay);
|
|
4084
|
+
} finally {
|
|
4085
|
+
clearTimeout(timeoutId);
|
|
4086
|
+
}
|
|
4069
4087
|
}
|
|
4088
|
+
return null;
|
|
4070
4089
|
}
|
|
4071
4090
|
|
|
4072
4091
|
// src/utils/format.ts
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"mcpName": "io.github.pkolawa/krs-poland-mcp-server",
|
|
3
3
|
"name": "krs-poland-mcp-server",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "The MCP server for KRS Poland public API.",
|
|
6
6
|
"main": "./build/index.mjs",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "npm run test && node build.mjs",
|
|
9
|
-
"
|
|
8
|
+
"build": "npm run test:unit && node build.mjs",
|
|
9
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
10
|
+
"test": "npm run test:unit && npm run test:integration",
|
|
11
|
+
"test:unit": "jest --testPathIgnorePatterns=api.integration.test.ts",
|
|
12
|
+
"test:integration": "jest --runTestsByPath src/utils/api.integration.test.ts",
|
|
13
|
+
"typecheck": "tsc --noEmit"
|
|
10
14
|
},
|
|
11
15
|
"repository": {
|
|
12
16
|
"type": "git",
|
|
@@ -39,10 +43,15 @@
|
|
|
39
43
|
"zod": "^3.25.76"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
47
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
42
48
|
"@types/jest": "^30.0.0",
|
|
43
49
|
"@types/node": "^24.3.1",
|
|
44
50
|
"esbuild": "^0.25.9",
|
|
51
|
+
"eslint": "^8.57.1",
|
|
52
|
+
"eslint-config-prettier": "^9.1.0",
|
|
45
53
|
"jest": "^29.7.0",
|
|
54
|
+
"prettier": "^3.6.2",
|
|
46
55
|
"ts-jest": "^29.4.4",
|
|
47
56
|
"typescript": "^5.9.2"
|
|
48
57
|
}
|