Skip to main content
Glama

imageSearchText

Search for images in a dataset using text queries to find matching visual content based on natural language descriptions.

Instructions

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

Input Schema

NameRequiredDescriptionDefault
textYes检索的文本

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "text": { "description": "检索的文本", "type": "string" } }, "required": [ "text" ], "type": "object" }

Implementation Reference

  • Core handler function implementing the imageSearchText tool logic using Tencent Cloud CI API for text-based image search.
    async imageSearchText(params: ImageSearchTextParams) { // 验证并解析参数 const validParams = ImageSearchTextParamsSchema.parse(params); const { text } = 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: 'text', Text: text, }); 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 { isSuccess: true, message: '图像检索成功', data: result, }; } catch (error) { return { isSuccess: false, message: '请求异常: ${error.message}', data: error, }; } }
  • Zod schema and TypeScript type definition for input parameters of the imageSearchText tool.
    export const ImageSearchTextParamsSchema = z.object({ text: z.string(), }); export type ImageSearchTextParams = z.infer<typeof ImageSearchTextParamsSchema>;
  • src/server.ts:511-529 (registration)
    MCP server registration of the 'imageSearchText' tool, including inline input schema and delegation to the service handler.
    server.tool( 'imageSearchText', '根据输入的文本内容,从数据集中检索出与输入的文本内容相符的图片', { text: z.string().describe('检索的文本'), }, async ({ text }) => { const res = await CIMateInsightInstance.imageSearchText({ text }); 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