ping-a-human 0.1.3 → 0.1.4
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/dist/index.d.ts +0 -8
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { type CreateChannelOptions } from "./channel-factory.js";
|
|
4
|
-
/**
|
|
5
|
-
* Build the MCP server with notify_human and ask_human registered.
|
|
6
|
-
*
|
|
7
|
-
* The Channel is resolved lazily (per tool call) via {@link createChannel} so
|
|
8
|
-
* the server still boots without configuration; a missing/invalid config
|
|
9
|
-
* surfaces as a tool error result instead of crashing at startup. Tests inject
|
|
10
|
-
* a stub Channel through `channelOptions.channel`.
|
|
11
|
-
*/
|
|
12
4
|
export declare function createServer(channelOptions?: CreateChannelOptions): McpServer;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import { realpathSync } from "node:fs";
|
|
4
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { z } from "zod";
|
|
7
8
|
import { createChannel } from "./channel-factory.js";
|
|
@@ -15,8 +16,20 @@ import { runSetup } from "./setup.js";
|
|
|
15
16
|
* surfaces as a tool error result instead of crashing at startup. Tests inject
|
|
16
17
|
* a stub Channel through `channelOptions.channel`.
|
|
17
18
|
*/
|
|
19
|
+
/** Read this package's version from package.json so MCP serverInfo never drifts. */
|
|
20
|
+
function packageVersion() {
|
|
21
|
+
try {
|
|
22
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
// dist/index.js -> ../package.json
|
|
24
|
+
const pkg = JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8"));
|
|
25
|
+
return pkg.version ?? "0.0.0";
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return "0.0.0";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
18
31
|
export function createServer(channelOptions = {}) {
|
|
19
|
-
const server = new McpServer({ name: "ping-a-human", version:
|
|
32
|
+
const server = new McpServer({ name: "ping-a-human", version: packageVersion() });
|
|
20
33
|
const resolveChannel = () => createChannel(channelOptions);
|
|
21
34
|
// 1.x registerTool: inputSchema is a ZodRawShape (plain object), NOT z.object(...).
|
|
22
35
|
server.registerTool("notify_human", {
|
package/package.json
CHANGED