Skip to main content
Glama
steveclarke

MCP Printer Server

by steveclarke

get_print_queue

Check pending and active print jobs for a specific printer or all printers to monitor print queue status.

Instructions

Check the print queue for a specific printer or all printers. Shows pending and active print jobs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
printerNoPrinter name to check queue for (optional, checks all if not specified)

Implementation Reference

  • The async handler function that implements the core logic of the get_print_queue tool. It constructs arguments for the 'lpq' command based on the optional printer input and executes it to retrieve the print queue status.
    async ({ printer }) => {
      const lpqArgs: string[] = []
      if (printer) {
        lpqArgs.push("-P", printer)
      }
    
      const output = await execCommand("lpq", lpqArgs)
      return {
        content: [
          {
            type: "text",
            text: output || "No print jobs in queue",
          },
        ],
      }
    }
  • The Zod input schema definition for the get_print_queue tool, specifying an optional 'printer' parameter.
    inputSchema: {
      printer: z
        .string()
        .optional()
        .describe("Printer name to check queue for (optional, checks all if not specified)"),
    },
  • The complete registration of the get_print_queue tool with the MCP server using server.registerTool, including name, metadata (title, description), input schema, and handler function.
    server.registerTool(
      "get_print_queue",
      {
        title: "Get Print Queue",
        description:
          "Check the print queue for a specific printer or all printers. Shows pending and active print jobs.",
        inputSchema: {
          printer: z
            .string()
            .optional()
            .describe("Printer name to check queue for (optional, checks all if not specified)"),
        },
      },
      async ({ printer }) => {
        const lpqArgs: string[] = []
        if (printer) {
          lpqArgs.push("-P", printer)
        }
    
        const output = await execCommand("lpq", lpqArgs)
        return {
          content: [
            {
              type: "text",
              text: output || "No print jobs in queue",
            },
          ],
        }
      }
    )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/steveclarke/mcp-printer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server