pixelate-mcp 0.2.0 → 0.3.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.
Files changed (2) hide show
  1. package/index.js +16 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { readFile, writeFile } from "node:fs/promises";
4
+ import os from "node:os";
5
+ import crypto from "node:crypto";
4
6
  import sharp from "sharp";
5
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
8
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -13,6 +15,15 @@ if (!API_URL || !API_KEY) {
13
15
  process.exit(1);
14
16
  }
15
17
 
18
+ // Stable per-machine id. A key binds to the first machine that uses it, so a
19
+ // shared key won't work on someone else's device. Derived from host/user/home
20
+ // (deterministic, no extra files); override with PIXELATE_MACHINE_ID if needed.
21
+ let _uname = "";
22
+ try { _uname = os.userInfo().username; } catch { /* ignore */ }
23
+ const MACHINE_ID =
24
+ process.env.PIXELATE_MACHINE_ID ||
25
+ crypto.createHash("sha256").update([os.hostname(), _uname, os.homedir(), os.platform()].join("|")).digest("hex").slice(0, 24);
26
+
16
27
  const stripDataUrl = (s) => {
17
28
  const i = s.indexOf(",");
18
29
  return s.startsWith("data:") && i !== -1 ? s.slice(i + 1) : s;
@@ -29,11 +40,11 @@ function billingLine(res) {
29
40
  }
30
41
 
31
42
  async function jobReq(query, body) {
43
+ const headers = { "x-api-key": API_KEY, "x-machine-id": MACHINE_ID };
44
+ if (body) headers["content-type"] = "application/octet-stream";
32
45
  const res = await fetch(`${API_URL}/job?${query}`, {
33
46
  method: "POST",
34
- headers: body
35
- ? { "content-type": "application/octet-stream", "x-api-key": API_KEY }
36
- : { "x-api-key": API_KEY },
47
+ headers,
37
48
  body: body ?? undefined,
38
49
  });
39
50
  const j = await res.json().catch(() => ({}));
@@ -42,7 +53,7 @@ async function jobReq(query, body) {
42
53
  return j;
43
54
  }
44
55
 
45
- const server = new McpServer({ name: "pixelate-mcp", version: "0.2.0" });
56
+ const server = new McpServer({ name: "pixelate-mcp", version: "0.3.0" });
46
57
 
47
58
  server.tool(
48
59
  "pixelate_account",
@@ -50,7 +61,7 @@ server.tool(
50
61
  {},
51
62
  async () => {
52
63
  try {
53
- const res = await fetch(`${API_URL}/account`, { headers: { "x-api-key": API_KEY } });
64
+ const res = await fetch(`${API_URL}/account`, { headers: { "x-api-key": API_KEY, "x-machine-id": MACHINE_ID } });
54
65
  const j = await res.json().catch(() => ({}));
55
66
  if (!res.ok || !j.success) return errText(`account error (${res.status}): ${j.error || "unknown"}`);
56
67
  const text =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelate-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "MCP server: turn any image into grid-perfect pixel art via the Pixelate Cloud API. Works in Codex, Claude Desktop, Cursor.",
5
5
  "type": "module",
6
6
  "bin": {