Skip to main content
Glama
zhixiaoqiang

Desktop Image Manager MCP Server

count-desktop-images

Counts the number of image files stored on your desktop, enabling users to manage and organize their desktop image collections efficiently with the Desktop Image Manager MCP Server.

Instructions

统计桌面上的图片文件数量

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • server.ts:53-71 (handler)
    The asynchronous handler function that executes the tool logic: fetches desktop image files and returns the count in a text response, with error handling.
    async () => {
      try {
        const imageFiles = await getDesktopImageFiles();
        return {
          content: [{ 
            type: "text", 
            text: `桌面上共有 ${imageFiles.length} 个图片文件。` 
          }]
        };
      } catch (error) {
        return {
          content: [{ 
            type: "text", 
            text: `获取图片数量时出错: ${error instanceof Error ? error.message : String(error)}` 
          }],
          isError: true
        };
      }
    }
  • server.ts:49-72 (registration)
    Registration of the 'count-desktop-images' tool with the MCP server, specifying name, description, empty input schema, and handler function.
    server.tool(
      "count-desktop-images",
      "统计桌面上的图片文件数量",
      {},
      async () => {
        try {
          const imageFiles = await getDesktopImageFiles();
          return {
            content: [{ 
              type: "text", 
              text: `桌面上共有 ${imageFiles.length} 个图片文件。` 
            }]
          };
        } catch (error) {
          return {
            content: [{ 
              type: "text", 
              text: `获取图片数量时出错: ${error instanceof Error ? error.message : String(error)}` 
            }],
            isError: true
          };
        }
      }
    );
  • Core helper function that reads the desktop directory, filters image files using isImageFile, and returns their names.
    const getDesktopImageFiles = async (): Promise<string[]> => {
      const desktopPath = getDesktopPath();
      try {
        const files = await fs.readdir(desktopPath);
        const imagePaths = files.filter(file => {
          const filePath = path.join(desktopPath, file);
          return fs.statSync(filePath).isFile() && isImageFile(filePath);
        });
        return imagePaths;
      } catch (error) {
        console.error(`Error reading desktop directory: ${error}`, );
        return [];
      }
    };
  • Helper function to check if a file path corresponds to a supported image extension.
    const isImageFile = (filePath: string): boolean => {
      const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.tiff', '.svg'];
      const ext = path.extname(filePath).toLowerCase();
      return imageExtensions.includes(ext);
    };
  • Helper function to resolve the user's desktop directory path.
    const getDesktopPath = () => {
      const { homedir } = os.userInfo();
      return path.join(homedir, 'Desktop');
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states what the tool does (counts images) but doesn't describe how it behaves—e.g., whether it's read-only, if it accesses system files, potential errors, or output format. This leaves significant gaps in understanding the tool's operational characteristics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function with no wasted words. It's front-loaded and appropriately sized for a simple tool with no parameters, making it easy to parse and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on behavior, output format, or usage context. For a counting tool, this is acceptable but leaves room for improvement in guiding the agent effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100%, so there's no need for parameter details in the description. The baseline for this scenario is 4, as the description appropriately focuses on the tool's purpose without redundant parameter information, though it doesn't add extra value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('统计' meaning 'count') and resource ('桌面上的图片文件' meaning 'desktop image files'), making it immediately understandable. However, it doesn't explicitly differentiate from its sibling 'list-desktop-images', which likely lists files rather than counting them, so it misses the highest clarity tier.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list-desktop-images' or 'compress-image'. It lacks any context about use cases, prerequisites, or exclusions, leaving the agent to infer usage based solely on the tool name and description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/zhixiaoqiang/desktop-image-manager-mcp'

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