Tencent Cloud Passport Recognition (Multi-Country and Multi-Region): Wrapping MLIDPassportOCR for Agent

Introduction

In cross-border business, mobility applications, or KYC workflows, structured fields often need to be extracted from passport scans or photos. If you simply ask a model to “guess fields from the image” in a conversation, accuracy and auditability are unreliable. Integrating Tencent Cloud OCR yourself involves digging through API documentation, handling Base64/URL encoding, and aligning MRZ (Machine Readable Zone) with VRZ (Visual Readable Zone) fields. This article introduces @tencent-adm/tencentcloud-ocr-mlidpassport on SkillHub: a standard Skill wrapping Tencent Cloud’s MLIDPassportOCR capability, enabling Agents like Cursor, Claude Code, and Codex to execute official SDK scripts directly at the right time.

What is this?

Tencent Cloud Passport Recognition (Multi-country/Multi-region) is an “enterprise source” Skill published by the Tencent Cloud OCR team (current version 1.0.3, category ai-agent), located at @tencent-adm/tencentcloud-ocr-mlidpassport. It provides a SKILL.md documentation file and a scripts/main.py entry point within the Skill directory, backing the Tencent Cloud Passport Recognition API MLIDPassportOCR.

The tag requires_api_key=true indicates that Tencent Cloud API keys must be configured before use. Pay-as-you-go billing and account activation status are subject to the Tencent Cloud console.

Core Functions

Based on the Skill documentation and the upstream SKILL.md, the verified capabilities are as follows:

  1. Multi-country/Multi-region Passports: Covers machine-readable passports from Mainland China, Hong Kong, Macao, Taiwan, and other countries/regions. The documentation states support for 80+ countries/regions.
  2. MRZ (Machine Readable Zone): Extracts Passport ID, Last Name/First Name, Date of Birth, Sex, Validity Period, Issuing Country, Nationality, Country/Region Code, Type, MRZ Code Sequence, etc.
  3. VRZ (Visual Readable Zone): Extracts Document Type, Passport Number, Name, Nationality, Issue Date/Expiry Date, etc. Note that fields such as Signature, Place of Issue, and Issuing Authority are only validly returned for Mainland China Passports.
  4. Input Methods: ImageBase64 and ImageUrl (if both are provided, only the URL is used); supports PNG/JPG/JPEG/BMP/PDF. PDFs are converted from the first page for recognition.
  5. Portrait Cropping: Setting RetImage=true returns the Base64 of the passport portrait photo.
  6. Quality Alerts (International Site Only): Returns alerts for photocopies, reshoots, PS (photoshopping), glare, blur, incomplete borders, etc., via WarnCardInfos. This array is fixed as empty for the domestic site.

Agent Side: When a user requests passport field recognition, MRZ parsing, portrait cropping, or (on the international site) copy/reshoot detection, the Skill description guides the model to select this skill.

Installation and Activation

1. Install SkillHub CLI (if not installed)

command -v skillhub && skillhub --version

If not installed, follow the SkillHub installation documentation (full installation example):

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash

2. Install this Skill to the current Agent’s skills directory

During installation, you must use --dir to point to the skills directory actually read by the current Agent. Otherwise, it defaults to ./skills/ and may not be loaded.

skillhub install tencent-adm/tencentcloud-ocr-mlidpassport --dir <your skills directory>

Common paths (subject to SkillHub documentation):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ in the project

The SkillHub page also supports sending an installation prompt to the AI, with the content: Install @tencent-adm/tencentcloud-ocr-mlidpassport based on https://skillhub.cn/install/skillhub.md.

3. Runtime Environment and Keys

The Skill requires Python 3.6+ and the SDK installed:

pip install tencentcloud-sdk-python

Configure in your environment:

export TENCENTCLOUD_SECRET_ID="Your SecretId"
export TENCENTCLOUD_SECRET_KEY="Your SecretKey"

You must activate the OCR service in Tencent Cloud. Errors such as ResourceUnavailable.* will occur in cases of arrears, unactivated services, or exhausted resource packages.

Typical Usage

Call the API via scripts/main.py from the directory where the Skill is installed. Request parameters align with the API: ImageBase64 / ImageUrl, RetImage, optional UserAgent (documentation suggests fixing this as Skills). Domestic and International sites are distinguished via --region and other region configurations; to access warning information, you must use an International site region (e.g., ap-bangkok in examples).

Identify via Image URL:

python scripts/main.py --image-url "https://example.com/passport.jpg"

Identify and return portrait Base64:

python scripts/main.py --image-url "https://example.com/passport.jpg" --ret-image

Local file via Base64 (script accepts file path):

python scripts/main.py --image-base64 "/path/to/passport.jpg"

Specify region to use International site alert capabilities:

python scripts/main.py --image-url "https://example.com/passport.jpg" --region ap-bangkok

Upon success, it returns JSON containing top-level MRZ related fields, the PassportRecognizeInfos visual zone structure, RequestId, etc. The International site may include WarnCardInfos (alert codes -9101 to -9109, see Skill documentation table).

In Agent conversations, the user simply needs to specify the passport image (URL or local path) and whether portrait or alerts are needed; the model selects parameters and executes the script according to SKILL.md, which is more reproducible than writing ad-hoc curl commands.

Use Cases and Notes

Suitable for:

  • Stable invocation of Tencent Cloud Passport OCR within Agent workflows, rather than letting the model freely “read images.”
  • Multi-country passports, MRZ validation, and mapping to subsequent form/KYC fields.
  • API-level alerts for photocopies, reshoots, PS, etc., in International site scenarios (requires correct region and capability activation).

Notes:

  1. Keys and Compliance: Passports are sensitive personal information; do not write keys into repositories. Image transmission and storage must comply with business compliance requirements.
  2. Image Quality: Documentation suggests a resolution of approximately 500×800 or higher, with the document area occupying about 2/3 of the frame; URL download timeout is approx. 3 seconds, and Base64 encoded data must not exceed 10M.
  3. Frequency: Default API rate limit is 5 times/second; batch tasks require self-throttling.
  4. Domestic vs. International Differences: WarnCardInfos and certain field behaviors vary by region; Thai passports have additional consistency check logic between MRZ and OCR zones.
  5. SkillHub Metrics (at time of scraping): Rating 100000, Downloads 1730, Installs 126; subject to real-time data on the SkillHub page.

Conclusion

@tencent-adm/tencentcloud-ocr-mlidpassport consolidates the field descriptions, script entry points, and environment requirements of MLIDPassportOCR into a single Skill. It is suitable for developers already using Tencent Cloud OCR who want their Agents to automatically select tools based on scenarios. Official entries:

  • https://api.skillhub.cn/tencent-adm/tencentcloud-ocr-mlidpassport
  • https://www.skillhub.cn/skills/tencent-adm/tencentcloud-ocr-mlidpassport

API details and billing are subject to Tencent Cloud documentation: https://cloud.tencent.com/document/api/866/37657

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye