@kynver-app/mcp-estimator 0.2.0 → 0.2.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/package.json +1 -1
- package/src/index.ts +18 -13
- package/src/lib/package-version.ts +55 -0
- package/src/server.ts +4 -1
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Kynver Estimator MCP server — stdio entry point.
|
|
4
|
-
* Run: node dist/index.js
|
|
5
|
-
* Env: KYNVER_API_URL (default https://kynver.com), KYNVER_API_KEY (required for all tools)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Kynver Estimator MCP server — stdio entry point.
|
|
4
|
+
* Run: node dist/index.js
|
|
5
|
+
* Env: KYNVER_API_URL (default https://kynver.com), KYNVER_API_KEY (required for all tools)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import { handleCliVersionFlag } from "./lib/package-version.js";
|
|
10
|
+
import { createEstimatorServer } from "./server.js";
|
|
11
|
+
|
|
12
|
+
if (handleCliVersionFlag(process.argv.slice(2), import.meta.url, "kynver-mcp-estimator")) {
|
|
13
|
+
// exits
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const server = createEstimatorServer();
|
|
17
|
+
const transport = new StdioServerTransport();
|
|
18
|
+
await server.connect(transport);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @generated — synced from packages/kynver-mcp-sse-lib/src/package-version.ts via scripts/sync-mcp-sse-server.mjs
|
|
2
|
+
// Do not edit by hand; change the canonical file and re-run the sync script.
|
|
3
|
+
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
function resolvePackageRoot(moduleUrl: string): string {
|
|
9
|
+
let dir = dirname(fileURLToPath(moduleUrl));
|
|
10
|
+
for (let depth = 0; depth < 6; depth += 1) {
|
|
11
|
+
if (existsSync(join(dir, "package.json"))) return dir;
|
|
12
|
+
const parent = dirname(dir);
|
|
13
|
+
if (parent === dir) break;
|
|
14
|
+
dir = parent;
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`package.json not found above ${dirname(fileURLToPath(moduleUrl))}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Read a field from the nearest `package.json` above this module. */
|
|
20
|
+
export function readOwnPackageJsonField(
|
|
21
|
+
moduleUrl: string,
|
|
22
|
+
field: "version" | "name",
|
|
23
|
+
): string {
|
|
24
|
+
const pkgPath = join(resolvePackageRoot(moduleUrl), "package.json");
|
|
25
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8")) as Record<string, unknown>;
|
|
26
|
+
const value = pkg[field];
|
|
27
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
28
|
+
throw new Error(`Missing package.json ${field} at ${pkgPath}`);
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function readOwnPackageVersion(moduleUrl: string = import.meta.url): string {
|
|
34
|
+
return readOwnPackageJsonField(moduleUrl, "version");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function wantsCliVersion(argv: string[]): boolean {
|
|
38
|
+
return argv.some((arg) => arg === "--version" || arg === "-v");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function printCliVersionAndExit(version: string, binName?: string): never {
|
|
42
|
+
console.log(binName ? `${binName} ${version}` : version);
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** When `--version` / `-v` is present, print package version and exit before side effects. */
|
|
47
|
+
export function handleCliVersionFlag(
|
|
48
|
+
argv: string[],
|
|
49
|
+
moduleUrl: string = import.meta.url,
|
|
50
|
+
binName?: string,
|
|
51
|
+
): boolean {
|
|
52
|
+
if (!wantsCliVersion(argv)) return false;
|
|
53
|
+
printCliVersionAndExit(readOwnPackageVersion(moduleUrl), binName);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -14,6 +14,9 @@ import * as visionTools from "./tools/vision-tools.js";
|
|
|
14
14
|
import * as companyTools from "./tools/company-tools.js";
|
|
15
15
|
import * as clientTools from "./tools/client-tools.js";
|
|
16
16
|
import * as takeoffTools from "./tools/takeoff-tools.js";
|
|
17
|
+
import { readOwnPackageVersion } from "./lib/package-version.js";
|
|
18
|
+
|
|
19
|
+
const PACKAGE_VERSION = readOwnPackageVersion(import.meta.url);
|
|
17
20
|
|
|
18
21
|
type ToolConfig = { description: string; inputSchema: unknown };
|
|
19
22
|
|
|
@@ -23,7 +26,7 @@ function toolResult(text: string) {
|
|
|
23
26
|
|
|
24
27
|
export function createEstimatorServer(): McpServer {
|
|
25
28
|
const server = new McpServer(
|
|
26
|
-
{ name: "kynver-mcp-estimator", version:
|
|
29
|
+
{ name: "kynver-mcp-estimator", version: PACKAGE_VERSION },
|
|
27
30
|
{ capabilities: { tools: {} } }
|
|
28
31
|
);
|
|
29
32
|
|