printer-doctor 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 CHANGED
@@ -1,5 +1,7 @@
1
1
  # Printer Doctor
2
2
 
3
+ [![getlarkwright/printer-doctor MCP server](https://glama.ai/mcp/servers/getlarkwright/printer-doctor/badges/score.svg)](https://glama.ai/mcp/servers/getlarkwright/printer-doctor)
4
+
3
5
  Ask your AI assistant "why won't my printer print?" and get a real answer.
4
6
 
5
7
  Printer Doctor is an [MCP](https://modelcontextprotocol.io) server. It looks at the print queue on
@@ -64,7 +66,7 @@ You need [Node.js](https://nodejs.org) 20 or newer.
64
66
  **Claude Code**
65
67
 
66
68
  ```bash
67
- claude mcp add printer-doctor -- npx -y printer-doctor@0.1.0
69
+ claude mcp add printer-doctor -- npx -y printer-doctor@0.1.1
68
70
  ```
69
71
 
70
72
  **Claude Desktop, Cursor, VS Code and other MCP apps**: add this to the app's MCP settings:
@@ -74,7 +76,7 @@ claude mcp add printer-doctor -- npx -y printer-doctor@0.1.0
74
76
  "mcpServers": {
75
77
  "printer-doctor": {
76
78
  "command": "npx",
77
- "args": ["-y", "printer-doctor@0.1.0"]
79
+ "args": ["-y", "printer-doctor@0.1.1"]
78
80
  }
79
81
  }
80
82
  }
@@ -83,9 +85,9 @@ claude mcp add printer-doctor -- npx -y printer-doctor@0.1.0
83
85
  **Without an AI app**, in a terminal:
84
86
 
85
87
  ```bash
86
- npx -y printer-doctor@0.1.0 find # printers on this computer and on your network
87
- npx -y printer-doctor@0.1.0 check # check the default printer, 3 to 15 seconds
88
- npx -y printer-doctor@0.1.0 check brother # check the printer with this name, or part of it
88
+ npx -y printer-doctor@0.1.1 find # printers on this computer and on your network
89
+ npx -y printer-doctor@0.1.1 check # check the default printer, 3 to 15 seconds
90
+ npx -y printer-doctor@0.1.1 check brother # check the printer with this name, or part of it
89
91
  ```
90
92
 
91
93
  ## The two tools
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "printer-doctor",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Ask your AI why the printer won't print. Checks the print queue on your computer and asks the printer itself: offline, paused, out of paper, low ink, a stuck job, or a changed address. Read-only, no admin rights, no telemetry.",
5
5
  "license": "MIT",
6
6
  "author": "Larkwright LLC",
@@ -196,6 +196,15 @@ export function diagnose(f) {
196
196
  f.platform === "linux" ? ["Install or start the print system: on most Linux systems, install the \"cups\" package and start the cups service.", S.again] : ["Restart the computer.", S.again],
197
197
  );
198
198
  }
199
+ if (sys.listUnreadable) {
200
+ const seen = announced.length ? ` I can see ${announced.length === 1 ? "one printer" : `${announced.length} printers`} announcing ${announced.length === 1 ? "itself" : "themselves"} on your network: ${announced.map((a) => a.instance).join(", ")}.` : "";
201
+ add("warning", "computer", `I could not read this computer's printer list: Windows did not answer when I asked${sys.serviceRunning === true ? ", although its print service is running" : ""}.${seen}`);
202
+ return done("list_unreadable", "I could not read this computer's printer list, so I can't tell yet what is wrong.", [
203
+ "Restart the computer.",
204
+ S.again,
205
+ "Meanwhile, Settings > Bluetooth & devices > Printers & scanners shows the printers set up on this computer and whether each one is ready.",
206
+ ]);
207
+ }
199
208
  const found = announced.length ? ` I can see ${announced.length === 1 ? "one printer" : `${announced.length} printers`} announcing ${announced.length === 1 ? "itself" : "themselves"} on your network: ${announced.map((a) => a.instance).join(", ")}.` : "";
200
209
  if (sel.problem === "no_printers" || sel.problem === "only_virtual") {
201
210
  const only = sel.problem === "only_virtual" ? ` The printers it lists (${sel.candidates.join(", ")}) save a file or send a fax: none of them puts ink on paper.` : "";
package/src/lib/report.js CHANGED
@@ -47,6 +47,8 @@ export function renderList(f) {
47
47
  lines.push("Windows' print service (the \"Print Spooler\") is not running, so this computer's printer list can't be read and nothing can print. Ask me to check the printer and I will explain how to start it.", "");
48
48
  } else if (!sys.available) {
49
49
  lines.push("This computer's print system is not running or not installed, so no printers are set up on it.", "");
50
+ } else if (sys.listUnreadable) {
51
+ lines.push(`I could not read this computer's printer list: Windows did not answer when I asked${sys.serviceRunning === true ? ", although its print service is running" : ""}. Restarting the computer usually fixes this.`, "");
50
52
  } else {
51
53
  const real = sys.printers.filter((p) => !p.virtual);
52
54
  const virtual = sys.printers.filter((p) => p.virtual);
@@ -56,7 +58,7 @@ export function renderList(f) {
56
58
  for (const p of virtual) lines.push(queueLine(p));
57
59
  lines.push("");
58
60
  }
59
- lines.push("Found on your network, not set up on this computer");
61
+ lines.push(sys.listUnreadable ? "Found on your network" : "Found on your network, not set up on this computer");
60
62
  if (f.notSetUp.length) {
61
63
  for (const a of f.notSetUp) lines.push(`- ${a.instance}${a.model && a.model.toLowerCase() !== a.instance.toLowerCase() ? ` (${a.model})` : ""}${a.addresses.length ? ` at ${a.addresses[0]}` : ""}`);
62
64
  } else if (f.announcedCount) {
@@ -80,7 +82,7 @@ export function details(f) {
80
82
  const when = new Date().toISOString().replace("T", " ").slice(0, 16) + " UTC";
81
83
  const out = [`Details (${when}, ${OS_NAME[f.platform] || f.platform})`];
82
84
  const sys = f.system || {};
83
- out.push(` Print system on this computer: ${sys.system === "windows" ? "Windows spooler" : sys.system === "cups" ? "CUPS" : "none"}, ${sys.available ? (sys.serviceRunning === false ? "not running" : "running") : "not available"}; ${plural((sys.printers || []).length, "printer")} set up`);
85
+ out.push(` Print system on this computer: ${sys.system === "windows" ? "Windows spooler" : sys.system === "cups" ? "CUPS" : "none"}, ${sys.available ? (sys.serviceRunning === false ? "not running" : sys.serviceRunning === null ? "could not tell whether it is running" : "running") : "not available"}; ${sys.listUnreadable ? "the printer list could not be read" : `${plural((sys.printers || []).length, "printer")} set up`}`);
84
86
  const p = f.target;
85
87
  if (p) {
86
88
  const to = p.kind === "network" ? `network${p.scheme ? ` (${p.scheme}${p.port ? `, port ${p.port}` : ""})` : ""}${p.host ? ` to ${hostText(p.host)}` : p.instance ? ", found by its announced name" : ""}` : CONNECTION[p.kind] || p.kind;
@@ -10,10 +10,12 @@ import { cleanText } from "./text.js";
10
10
  export const WINDOWS_SCRIPT = [
11
11
  "$ErrorActionPreference = 'Stop'",
12
12
  "$o = @{ spooler = $null; printers = @(); ports = @(); jobs = @(); errors = @() }",
13
- "try { $s = Get-CimInstance -ClassName Win32_Service -Filter 'Name=''Spooler'''; if ($s) { $o.spooler = @{ state = [string]$s.State; start = [string]$s.StartMode } } } catch { $o.errors += 'spooler' }",
13
+ // The service manager answers even when WMI refuses or is broken; WMI is only the fallback.
14
+ "try { $g = Get-Service -Name Spooler; $o.spooler = @{ state = [string]$g.Status; start = [string]$g.StartType } } catch { try { $s = Get-CimInstance -ClassName Win32_Service -Filter 'Name=''Spooler'''; if ($s) { $o.spooler = @{ state = [string]$s.State; start = [string]$s.StartMode } } } catch { $o.errors += 'spooler' } }",
14
15
  "try { $o.printers = @(Get-CimInstance -ClassName Win32_Printer | ForEach-Object { @{ name = [string]$_.Name; driver = [string]$_.DriverName; port = [string]$_.PortName; offline = [bool]$_.WorkOffline; isDefault = [bool]$_.Default; shared = [bool]$_.Shared; network = [bool]$_.Network; state = [long]$_.PrinterState; error = [int]$_.DetectedErrorState; extended = [int]$_.ExtendedPrinterStatus; attributes = [long]$_.Attributes } }) } catch { $o.errors += 'printers' }",
15
- "try { $o.ports = @(Get-CimInstance -ClassName Win32_TCPIPPrinterPort | ForEach-Object { @{ name = [string]$_.Name; address = [string]$_.HostAddress; number = [int]$_.PortNumber; protocol = [int]$_.Protocol } }) } catch { $o.errors += 'ports' }",
16
- "try { $o.jobs = @(Get-CimInstance -ClassName Win32_PrintJob | ForEach-Object { $t = $null; if ($_.TimeSubmitted) { $t = $_.TimeSubmitted.ToUniversalTime().ToString('o') }; @{ printer = ([string]$_.Name -replace ',\\s*\\d+$', ''); mask = [long]$_.StatusMask; submitted = $t } }) } catch { $o.errors += 'jobs' }",
16
+ // Ports and jobs come from the same place as the printer list: if that failed, don't wait for two more failures.
17
+ "if ($o.errors -notcontains 'printers') { try { $o.ports = @(Get-CimInstance -ClassName Win32_TCPIPPrinterPort | ForEach-Object { @{ name = [string]$_.Name; address = [string]$_.HostAddress; number = [int]$_.PortNumber; protocol = [int]$_.Protocol } }) } catch { $o.errors += 'ports' }",
18
+ "try { $o.jobs = @(Get-CimInstance -ClassName Win32_PrintJob | ForEach-Object { $t = $null; if ($_.TimeSubmitted) { $t = $_.TimeSubmitted.ToUniversalTime().ToString('o') }; @{ printer = ([string]$_.Name -replace ',\\s*\\d+$', ''); mask = [long]$_.StatusMask; submitted = $t } }) } catch { $o.errors += 'jobs' } }",
17
19
  "[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(($o | ConvertTo-Json -Depth 4 -Compress)))",
18
20
  ].join("; ");
19
21
 
@@ -88,13 +90,17 @@ function portKind(port, tcpPort, virtual) {
88
90
 
89
91
  /**
90
92
  * Turns the script's JSON into the same shape the other systems produce:
91
- * { available, serviceRunning, serviceDisabled, printers: [...], defaultName }.
93
+ * { available, serviceRunning (true, false, or null when unknown), serviceDisabled, listUnreadable,
94
+ * printers: [...], defaultName }.
92
95
  */
93
96
  export function readWindows(data, nowMs = Date.now()) {
94
97
  if (!data || typeof data !== "object") return { system: "windows", available: false, printers: [], defaultName: null };
95
98
  const errors = list(data.errors);
96
99
  const spooler = data.spooler && typeof data.spooler === "object" ? data.spooler : null;
97
- const serviceRunning = spooler ? /^running$/i.test(String(spooler.state)) : !errors.includes("printers");
100
+ const listUnreadable = errors.includes("printers");
101
+ // Not being able to ask is not the same as "stopped": with no answer about the service and no
102
+ // printer list, the state is unknown (null), and the report says it could not read the list.
103
+ const serviceRunning = spooler ? /^running$/i.test(String(spooler.state)) : listUnreadable ? null : true;
98
104
  const ports = new Map(list(data.ports).map((p) => [String(p.name), p]));
99
105
  const jobsByPrinter = new Map();
100
106
  for (const j of list(data.jobs)) {
@@ -154,6 +160,7 @@ export function readWindows(data, nowMs = Date.now()) {
154
160
  serviceDisabled: spooler ? /^disabled$/i.test(String(spooler.start)) : false,
155
161
  printers,
156
162
  defaultName: printers.find((p) => p.isDefault)?.name || null,
163
+ listUnreadable,
157
164
  partial: errors,
158
165
  };
159
166
  }