Skip to main content
Glama
sweetwisdom

MCP Project Query Server

by sweetwisdom

get_random_wallpaper

Retrieve random Bing wallpapers with customizable resolution and region settings to refresh desktop backgrounds or find visual inspiration.

Instructions

从Bing壁纸获取随机壁纸,返回壁纸的URL、标题和描述信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resolutionNo壁纸分辨率,可选值:1920x1080, 3840x2160, 1366x768等,默认为1920x1080
marketNo地区市场,如zh-CN(中国), en-US(美国)等,默认为zh-CN

Implementation Reference

  • Registers the 'get_random_wallpaper' MCP tool, including input schema with optional resolution and market parameters using Zod, description, and a thin handler delegating to WallpaperController.
    server.tool(
        'get_random_wallpaper',
        '从Bing壁纸获取随机壁纸,返回壁纸的URL、标题和描述信息',
        {
            resolution: z.string().optional().describe('壁纸分辨率,可选值:1920x1080, 3840x2160, 1366x768等,默认为1920x1080'),
            market: z.string().optional().describe('地区市场,如zh-CN(中国), en-US(美国)等,默认为zh-CN'),
        },
        async ({ resolution = AppConfig.DEFAULT_WALLPAPER_RESOLUTION, market = AppConfig.DEFAULT_MARKET }) => {
            return await wallpaperController.getRandomWallpaper(resolution, market);
        }
    );
  • Controller handler that invokes the wallpaper service, stringifies the result as JSON, and formats it into MCP-compatible response structure with error handling.
    async getRandomWallpaper(resolution: string = '1920x1080', market: string = 'zh-CN'): Promise<{ content: Array<{ type: 'text'; text: string }> }> {
      try {
        const wallpaperInfo = await this.wallpaperService.getRandomWallpaper(resolution, market);
        
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(wallpaperInfo, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `获取壁纸时出错: ${error instanceof Error ? error.message : '未知错误'}`,
            },
          ],
        };
      }
    }
  • Core tool logic: constructs Bing wallpaper API URL, performs HTTPS request, parses JSON response, extracts image details, and returns structured WallpaperInfo.
    async getRandomWallpaper(resolution: string = '1920x1080', market: string = 'zh-CN'): Promise<WallpaperInfo> {
      const apiUrl = `https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=${market}&uhd=1&uhdwidth=${resolution.split('x')[0]}&uhdheight=${resolution.split('x')[1]}`;
      
      const wallpaperData = await this.makeHttpRequest(apiUrl);
      
      if (!wallpaperData.images || wallpaperData.images.length === 0) {
        throw new Error('未找到可用的壁纸');
      }
    
      const wallpaper = wallpaperData.images[0];
      const baseUrl = 'https://www.bing.com';
      const imageUrl = baseUrl + wallpaper.url;
      
      return {
        title: wallpaper.title,
        description: wallpaper.copyright,
        imageUrl: imageUrl,
        resolution: resolution,
        date: wallpaper.startdate,
        market: market,
        fullUrl: imageUrl
      };
    }
  • Zod input schema for the tool parameters: optional resolution and market strings.
    {
        resolution: z.string().optional().describe('壁纸分辨率,可选值:1920x1080, 3840x2160, 1366x768等,默认为1920x1080'),
        market: z.string().optional().describe('地区市场,如zh-CN(中国), en-US(美国)等,默认为zh-CN'),
    },
  • Private helper method to perform HTTPS GET request to Bing API, accumulate response data, parse JSON, with error handling.
    private makeHttpRequest(url: string): Promise<any> {
      return new Promise((resolve, reject) => {
        https.get(url, (res) => {
          let data = '';
          res.on('data', (chunk) => {
            data += chunk;
          });
          res.on('end', () => {
            try {
              const jsonData = JSON.parse(data);
              resolve(jsonData);
            } catch (error) {
              reject(new Error('解析壁纸数据失败'));
            }
          });
        }).on('error', (error) => {
          reject(new Error(`获取壁纸失败: ${error.message}`));
        });
      });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it fetches from Bing and returns specific data fields, but doesn't mention rate limits, authentication requirements, error conditions, whether results are truly random or cached, or any other behavioral traits. The description is minimal and lacks important operational context.

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

Conciseness4/5

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

The description is a single, efficient sentence that communicates the core functionality. It's appropriately concise without being overly terse, though it could potentially benefit from slightly more context about the tool's behavior.

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

Completeness2/5

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

For a tool with no annotations and no output schema, the description is insufficient. It doesn't explain the return format beyond listing fields, doesn't mention error handling, rate limits, or authentication requirements. Given the lack of structured metadata, the description should provide more complete operational context.

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

Parameters3/5

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

The schema description coverage is 100%, with both parameters ('resolution' and 'market') well-documented in the schema. The description doesn't add any parameter-specific information beyond what's already in the schema, so it meets the baseline score of 3 for high schema coverage.

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 action ('获取随机壁纸' - get random wallpaper), source ('从Bing壁纸' - from Bing wallpaper), and return values ('返回壁纸的URL、标题和描述信息' - returns wallpaper URL, title, and description). It's specific about what the tool does, though it doesn't explicitly differentiate from sibling tools which appear unrelated to wallpaper fetching.

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. It doesn't mention any prerequisites, limitations, or context for when this tool is appropriate versus other wallpaper-fetching methods or the unrelated sibling tools listed.

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

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/sweetwisdom/mcp-demo'

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