z_ai_vision_mcp_server_clone 0.1.0 → 0.1.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/README.md +5 -4
- package/build/src/server.js +9 -3
- package/build/test/vision.test.js +7 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,11 +52,12 @@ npm start
|
|
|
52
52
|
"mcpServers": {
|
|
53
53
|
"z-ai-vision-clone": {
|
|
54
54
|
"type": "stdio",
|
|
55
|
-
"command": "
|
|
56
|
-
"args": ["
|
|
55
|
+
"command": "npx",
|
|
56
|
+
"args": ["-y", "z_ai_vision_mcp_server_clone"],
|
|
57
57
|
"env": {
|
|
58
|
-
"VISION_ENDPOINT": "
|
|
59
|
-
"VISION_MODEL": "
|
|
58
|
+
"VISION_ENDPOINT": "https://your-provider.com/v1/chat/completions",
|
|
59
|
+
"VISION_MODEL": "your-vision-model",
|
|
60
|
+
"VISION_API_KEY": "your-api-key"
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
}
|
package/build/src/server.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 { readFileSync } from "node:fs";
|
|
4
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
5
5
|
import { readFile, stat } from "node:fs/promises";
|
|
6
6
|
import { extname } from "node:path";
|
|
7
|
-
import {
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
8
|
import * as z from "zod/v4";
|
|
9
9
|
export const IMAGE_TOOL_NAMES = [
|
|
10
10
|
"ui_to_artifact",
|
|
@@ -383,7 +383,13 @@ async function main() {
|
|
|
383
383
|
const server = createServer();
|
|
384
384
|
await server.connect(new StdioServerTransport());
|
|
385
385
|
}
|
|
386
|
-
|
|
386
|
+
export function isMainModule(argvPath = process.argv[1]) {
|
|
387
|
+
if (!argvPath) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
return realpathSync(argvPath) === realpathSync(fileURLToPath(import.meta.url));
|
|
391
|
+
}
|
|
392
|
+
if (isMainModule()) {
|
|
387
393
|
main().catch((error) => {
|
|
388
394
|
console.error(error instanceof Error ? error.message : String(error));
|
|
389
395
|
process.exit(1);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { chdir, cwd } from "node:process";
|
|
3
|
-
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { mkdir, mkdtemp, rm, stat, symlink, writeFile } from "node:fs/promises";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
-
import { IMAGE_TOOL_NAMES, buildVisionMessages, imageContentFromSource, loadVisionConfig, } from "../src/server.js";
|
|
6
|
+
import { IMAGE_TOOL_NAMES, buildVisionMessages, imageContentFromSource, isMainModule, loadVisionConfig, } from "../src/server.js";
|
|
7
7
|
const expectedTools = [
|
|
8
8
|
"ui_to_artifact",
|
|
9
9
|
"extract_text_from_screenshot",
|
|
@@ -14,6 +14,8 @@ const expectedTools = [
|
|
|
14
14
|
"analyze_image",
|
|
15
15
|
];
|
|
16
16
|
assert.deepEqual(IMAGE_TOOL_NAMES, expectedTools);
|
|
17
|
+
const serverBuild = await stat(new URL("../src/server.js", import.meta.url));
|
|
18
|
+
assert.ok(serverBuild.mode & 0o111, "build/src/server.js must be executable for npx");
|
|
17
19
|
const config = loadVisionConfig({
|
|
18
20
|
VISION_PROVIDER: "local",
|
|
19
21
|
VISION_ENDPOINT: "http://localhost:11434/v1/chat/completions",
|
|
@@ -33,6 +35,9 @@ try {
|
|
|
33
35
|
delete process.env[key];
|
|
34
36
|
}
|
|
35
37
|
chdir(dir);
|
|
38
|
+
await mkdir("bin");
|
|
39
|
+
await symlink(new URL("../src/server.js", import.meta.url), "bin/z_ai_vision_mcp_server_clone");
|
|
40
|
+
assert.equal(isMainModule(join(dir, "bin/z_ai_vision_mcp_server_clone")), true);
|
|
36
41
|
await writeFile(".env", "VISION_PROVIDER=file-provider\nVISION_ENDPOINT=http://example.test/v1/chat/completions\nVISION_MODEL=file-model\nVISION_API_KEY=file-key\n");
|
|
37
42
|
const fileConfig = loadVisionConfig();
|
|
38
43
|
assert.equal(fileConfig.provider, "file-provider");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "z_ai_vision_mcp_server_clone",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "OpenAI-compatible MCP server for custom vision model endpoints",
|
|
5
5
|
"main": "build/src/server.js",
|
|
6
6
|
"type": "module",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/1orzero/z_ai_vision_mcp_server_clone#readme",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
19
|
+
"build": "tsc && chmod 755 build/src/server.js",
|
|
20
20
|
"prepack": "npm run build",
|
|
21
21
|
"start": "node build/src/server.js",
|
|
22
22
|
"test": "npm run build && node build/test/vision.test.js"
|