Skip to main content
Glama

imageSearchPic

Search for visually similar images in a dataset by providing an input image URL. This tool enables content-based image retrieval for finding matching or related visual content.

Instructions

根据输入的图片,从数据集中检索出与输入的图片内容相似的图片

Input Schema

NameRequiredDescriptionDefault
uriYes图片地址

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "uri": { "description": "图片地址", "type": "string" } }, "required": [ "uri" ], "type": "object" }

Implementation Reference

  • The main handler function that validates input, constructs the COS API request for image search by picture, and returns the result or error.
    async imageSearchPic(params: ImageSearchPicParams) { // 验证并解析参数 const validParams = ImageSearchPicParamsSchema.parse(params); const { uri } = validParams; try { const key = 'datasetquery/imagesearch'; // 固定值 const appid = this.bucket.split('-').pop(); const host = `${appid}.ci.${this.region}.myqcloud.com`; const url = `https://${host}/${key}`; const body = JSON.stringify({ DatasetName: this.datasetName, Mode: 'pic', URI: uri, }); const result = await this.cos.request({ Method: 'POST', // 固定值,必须 Key: key, // 必须 Url: url, // 请求的url,必须 Body: body, // 请求体参数,必须 Headers: { // 设置请求体为 json,固定值,必须 'Content-Type': 'application/json', // 设置响应体为json,固定值,必须 Accept: 'application/json', }, }); return { success: true, message: '图像检索成功', // data: result.Body.toString() data: result, }; } catch (error) { return { isSuccess: false, message: '图像检索失败', data: error, }; } }
  • Zod schema and TypeScript type definition for the imageSearchPic tool parameters (uri: string). Used for input validation within the handler.
    export const ImageSearchPicParamsSchema = z.object({ uri: z.string(), }); export type ImageSearchPicParams = z.infer<typeof ImageSearchPicParamsSchema>;
  • src/server.ts:491-509 (registration)
    MCP server tool registration for 'imageSearchPic', defining the input schema, description, and wrapper handler that delegates to the CIMateInsightService instance.
    server.tool( 'imageSearchPic', '根据输入的图片,从数据集中检索出与输入的图片内容相似的图片', { uri: z.string().describe('图片地址'), }, async ({ uri }) => { const res = await CIMateInsightInstance.imageSearchPic({ uri }); return { content: [ { type: 'text', text: JSON.stringify(res.data, null, 2), }, ], isError: !res.isSuccess, }; }, );

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/xiaomizhoubaobei/MCP'

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