aiSuperResolution
Enhance image resolution using AI processing to improve clarity and detail from stored files.
Instructions
图片处理-超分辨率
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| objectKey | Yes | 图片在存储桶里的路径 |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"objectKey": {
"description": "图片在存储桶里的路径",
"type": "string"
}
},
"required": [
"objectKey"
],
"type": "object"
}
Implementation Reference
- src/services/ci/ai.service.ts:15-61 (handler)The aiSuperResolution method in CIAIService that executes the AI super resolution image processing using Tencent Cloud COS 'ci-process=AISuperResolution' API.async aiSuperResolution(objectKey: string) { try { const result = await new Promise((resolve, reject) => { const outPutFileid = generateOutPutFileId(objectKey); this.cos.request( { Bucket: this.bucket, // 存储桶,必须字段 Region: this.region, // 存储桶所在地域,必须字段 如 ap-beijing Key: objectKey, // 对象文件名,例如:folder/document.jpg。 Method: 'POST', // 固定值 Action: 'image_process', // 固定值 Headers: { 'Pic-Operations': JSON.stringify({ rules: [ { fileid: `${outPutFileid}`, rule: 'ci-process=AISuperResolution', }, ], }), }, }, 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:359-377 (registration)Registration of the 'aiSuperResolution' tool in the MCP server using server.tool(), including input schema for objectKey and the wrapper handler that calls CIAIInstance.aiSuperResolution.server.tool( 'aiSuperResolution', '图片处理-超分辨率', { objectKey: z.string().describe('图片在存储桶里的路径'), }, async ({ objectKey }) => { const res = await CIAIInstance.aiSuperResolution(objectKey); return { content: [ { type: 'text', text: JSON.stringify(res.data, null, 2), }, ], isError: !res.isSuccess, }; }, );
- src/server.ts:363-364 (schema)Zod input schema definition for the aiSuperResolution tool: requires objectKey as string describing the image path in the bucket.objectKey: z.string().describe('图片在存储桶里的路径'), },
- src/server.ts:44-44 (helper)Creation of CIAIInstance used by the aiSuperResolution tool handler.const CIAIInstance = new CIAIService(bucket, region, cos);