Content
# 验证码识别 MCP 服务
## 简介
本项目基于 [ddddocr](https://github.com/sml2h3/ddddocr) 和 [Model Context Protocol (MCP) Python SDK](https://github.com/modelcontextprotocol/python-sdk),实现了一个通过 MCP 协议对外提供验证码图片识别服务的智能后端。
---
## 依赖
- ddddocr
- mcp[fastmcp]
---
## 安装
1. 克隆本项目
```bash
git clone <your-repo-url>
cd <your-project-dir>
```
2. 安装依赖
```bash
pip install ddddocr mcp[fastmcp]
```
---
## 使用方法
### 启动服务端
```bash
python main.py
```
### 客户端调用示例
```python
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)`
识别本地图片验证码,返回内容对象
---
## 客户端使用
```json
{
"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
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
everything-claude-code
Complete Claude Code configuration collection - agents, skills, hooks,...
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
Sequential Thinking
A structured MCP server for dynamic problem-solving and reflective thinking.