验证码识别服务

jcvn1zc/CaptchaMCP
0 Stars 702 次浏览 更新于 2026-08-23

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "ocr": {
      "args": [
        "run",
        "--with",
        "mcp",
        "mcp",
        "run",
        "\u003ccode_path\u003e/server/main.py"
      ],
      "command": "uv"
    }
  }
}

服务介绍

验证码识别 MCP 服务

简介

本项目基于 ddddocrModel Context Protocol (MCP) Python SDK,实现了一个通过 MCP 协议对外提供验证码图片识别服务的智能后端。


依赖

  • ddddocr
  • mcp[fastmcp]

安装

  1. 克隆本项目
    git clone <your-repo-url>
    cd <your-project-dir>
    
  2. 安装依赖
    pip install ddddocr mcp[fastmcp]
    

使用方法

启动服务端

python main.py

客户端调用示例

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
import asyncio

async def main():
    server_params = StdioServerParameters(
        command="python",
        args=["main.py"],
        env=None,
    )
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            result = await session.call_tool(
                "recognize_captcha",
                arguments={"image_path": "E:/code/bug/service/ocr/captchaImage.jpg"}
            )
            print("识别结果:", result)

if __name__ == "__main__":
    asyncio.run(main())

工具接口

  • recognize_captcha(image_path: str)
    识别本地图片验证码,返回内容对象

客户端使用

{
    "mcpServers": {
        "ocr": {
            "command": "F:\\AI\\anaconda3\\Scripts\\uv.exe",
            "args": [
                "run",
                "--with",
                "mcp",
                "mcp",
                "run",
                "E:\\code\\bug\\service\\ocr\\mcp-server-demo\\main.py"
            ]
        }
    }
}

License

MIT

相关 MCP 服务