@yjzf/mcp-server-yjzf 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.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer, StdioServerTransport } from "@modelcontextprotocol/server";
3
+ import * as z from "zod/v4";
4
+ import * as fs from "node:fs";
5
+ import * as path from "node:path";
6
+ import * as os from "node:os";
7
+ // ---------------------------------------------------------------------------
8
+ // Environment helpers
9
+ // ---------------------------------------------------------------------------
10
+ function getDataDir() {
11
+ const envDir = process.env.DATA_DIR;
12
+ if (envDir) {
13
+ return envDir;
14
+ }
15
+ if (process.platform === "win32") {
16
+ const appData = process.env.APPDATA;
17
+ if (appData) {
18
+ return path.join(appData, "mcp-server-yjzf", "data");
19
+ }
20
+ return path.join(os.homedir(), "AppData", "Roaming", "mcp-server-yjzf", "data");
21
+ }
22
+ return path.join(os.homedir(), "mcp-server-yjzf", "data");
23
+ }
24
+ function getApiKey() {
25
+ return process.env.API_KEY;
26
+ }
27
+ // ---------------------------------------------------------------------------
28
+ // MCP Server
29
+ // ---------------------------------------------------------------------------
30
+ const server = new McpServer({
31
+ name: "mcp-server-yjzf",
32
+ version: "0.1.0",
33
+ });
34
+ server.registerTool("hello_world", {
35
+ description: "Send an HTTP GET request to https://mcp.yjzf.com/hello_world and write the response to $DATA_DIR/hello_world-response.txt",
36
+ inputSchema: z.object({}),
37
+ }, async () => {
38
+ const apiKey = getApiKey();
39
+ // Build request headers
40
+ const headers = {
41
+ Accept: "application/json",
42
+ };
43
+ if (apiKey) {
44
+ headers["Authorization"] = `Bearer ${apiKey}`;
45
+ }
46
+ // HTTP GET request
47
+ const response = await fetch("https://mcp.yjzf.com/hello_world", {
48
+ method: "GET",
49
+ headers,
50
+ });
51
+ if (!response.ok) {
52
+ return {
53
+ content: [
54
+ {
55
+ type: "text",
56
+ text: `Request failed with status ${response.status}: ${response.statusText}`,
57
+ },
58
+ ],
59
+ isError: true,
60
+ };
61
+ }
62
+ const body = await response.text();
63
+ // Ensure data directory exists
64
+ const dataDir = getDataDir();
65
+ fs.mkdirSync(dataDir, { recursive: true });
66
+ // Write response to file
67
+ const filePath = path.join(dataDir, "hello_world-response.txt");
68
+ fs.writeFileSync(filePath, body, "utf-8");
69
+ return {
70
+ content: [
71
+ {
72
+ type: "text",
73
+ text: `Response saved to ${filePath}\n\n${body}`,
74
+ },
75
+ ],
76
+ };
77
+ });
78
+ // ---------------------------------------------------------------------------
79
+ // Start
80
+ // ---------------------------------------------------------------------------
81
+ async function main() {
82
+ const transport = new StdioServerTransport();
83
+ await server.connect(transport);
84
+ }
85
+ main().catch((error) => {
86
+ console.error("Fatal error:", error);
87
+ process.exit(1);
88
+ });
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,SAAS,UAAU;IACjB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IACpC,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACj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./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "dev": "tsc --watch",
15
+ "start": "node dist/index.js"
16
+ },
17
+ "keywords": [
18
+ "mcp",
19
+ "mcp-server",
20
+ "yjzf"
21
+ ],
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "@modelcontextprotocol/server": "^1.29.0",
25
+ "zod": "^4.3.6"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^22.0.0",
29
+ "typescript": "^5.8.0"
30
+ }
31
+ }