aiQrcode
Extract and decode QR code content from images stored in Tencent Cloud COS using the MCP protocol, enabling efficient data retrieval without manual processing.
Instructions
图片处理-二维码识别-识别存储桶内二维码图片内容
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| objectKey | Yes | COS对象键(完整路径)示例: images/qrcode.jpg |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"objectKey": {
"description": "COS对象键(完整路径)示例: images/qrcode.jpg",
"type": "string"
}
},
"required": [
"objectKey"
],
"type": "object"
}
Implementation Reference
- src/services/ci/ai.service.ts:154-192 (handler)The aiQrcode method in CIAIService class that performs QR code recognition on the specified objectKey using Tencent Cloud COS API (ci-process: 'QRcode'). Returns success/error response with data.async aiQrcode(objectKey: string) { try { const result = await new Promise((resolve, reject) => { this.cos.request( { Bucket: this.bucket, // 存储桶,必须字段 Region: this.region, // 存储桶所在地域,必须字段 如 ap-beijing Method: 'GET', Key: objectKey, // Url: url, Query: { 'ci-process': 'QRcode', // 数据万象处理能力,二维码识别固定为 QRcode, cover: 0, }, }, function (error, data) { if (error) { // 处理请求失败 reject(error); } else { // 处理请求成功 resolve(data); } }, ); }); return { isSuccess: true, message: '二维码识别成功', data: result, }; } catch (error) { return { isSuccess: false, message: '二维码识别失败', data: error, }; } }
- src/server.ts:401-421 (registration)Registers the 'aiQrcode' MCP tool, providing description, Zod input schema for objectKey, and handler that calls CIAIService.aiQrcode and formats response.server.tool( 'aiQrcode', '图片处理-二维码识别-识别存储桶内二维码图片内容', { objectKey: z .string() .describe('COS对象键(完整路径)示例: images/qrcode.jpg'), }, async ({ objectKey }) => { const res = await CIAIInstance.aiQrcode(objectKey); return { content: [ { type: 'text', text: JSON.stringify(res.data, null, 2), }, ], isError: !res.isSuccess, }; }, );
- src/server.ts:405-407 (schema)Zod schema definition for the input parameter 'objectKey' of the aiQrcode tool.objectKey: z .string() .describe('COS对象键(完整路径)示例: images/qrcode.jpg'),