G

Google OCR 服务器框架

这是一项使用Google Cloud Vision API执行光学字符识别(OCR)的服务器实现。它基于**FastMCP**框架构建,该框架允许创建模块化和可扩展的命令处理工具。

image-and-video-processingcloud-platforms

700 查看 · 2026-07-07 更新

简介

这是一项使用Google Cloud Vision API执行光学字符识别(OCR)的服务器实现。它基于FastMCP框架构建,该框架允许创建模块化和可扩展的命令处理工具。

简介

这是一项使用Google Cloud Vision API执行光学字符识别(OCR)的服务器实现。它基于FastMCP框架构建,该框架允许创建模块化和可扩展的命令处理工具。

Google OCR MCP 服务器

smithery 徽章

组件

资源

该服务器实现了一个简单的笔记存储系统,包含:

  • 自定义的 note:// URI 方案,用于访问单个笔记
  • 每个笔记资源都有名称、描述和 text/plain MIME 类型

提示

该服务器提供了一个提示:

  • summarize-notes: 创建所有已存储笔记的摘要
    • 可选的 "style" 参数以控制详细程度(简短/详细)
    • 生成结合了所有当前笔记及样式偏好的提示

工具

该服务器实现了一个工具:

  • add-note: 向服务器添加新笔记
    • 需要 "name" 和 "content" 作为必需的字符串参数
    • 更新服务器状态并通知客户端资源变更

配置

[TODO:添加特定于您实现的配置细节]

快速开始

安装

Claude Desktop

  • 在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json
  • 在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json
开发/未发布的服务器配置
{ "mcpServers": { "google-ocr-mcp-server": { "command": "uv", "args": ["run", "google-ocr-mcp-server"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/google-application-credentials.json", "SAVE_RESULTS": false } } } }
已发布服务器配置
{ "mcpServers": { "google-ocr-mcp-server": { "command": "uvx", "args": ["google-ocr-mcp-server"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/google-application-credentials.json", "SAVE_RESULTS": false } } } }

通过 Smithery 安装

要通过 Smithery 自动为 Claude Desktop 安装 google-ocr-mcp-server:

npx -y @smithery/cli install @Zerohertz/google-ocr-mcp-server --client claude

开发

构建与发布

准备分发包:

  1. 同步依赖项并更新锁文件:
uv sync
  1. 构建包分发文件:
uv build

这将在 dist/ 目录中创建源码和 wheel 分发文件。

  1. 发布到 PyPI:
uv publish

注意:您需要通过环境变量或命令标志设置 PyPI 凭证:

  • 令牌: --tokenUV_PUBLISH_TOKEN
  • 或用户名/密码: --username/UV_PUBLISH_USERNAME--password/UV_PUBLISH_PASSWORD

调试

由于 MCP 服务器运行在标准输入输出上,调试可能会比较困难。为了获得最佳调试体验,我们强烈推荐使用 MCP Inspector

您可以使用以下命令通过 npm 启动 MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory /Users/zerohertz/Downloads/google-ocr-mcp-server run google-ocr-mcp-server

启动后,Inspector 将显示一个 URL,您可以在浏览器中访问该 URL 开始调试。

工具列表

  • ocr: Perform Optical Character Recognition (OCR) on the provided image file. Args: path (str): The absolute file path to the image on which OCR will be performed. Returns: str: The extracted text from the image. Raises: Exception: If an error occurs during the OCR process, it will be logged. Notes: - The function uses Google Cloud Vision API for text detection. - If SAVE_RESULTS is enabled, the OCR results will be saved as a JSON file in the same directory as the input image, with the same name but a .json extension.

服务配置

[{'mcpServers': {'google-ocr-mcp-server': {'args': ['google-ocr-mcp-server'], 'command': 'uvx', 'env': {'GOOGLE_APPLICATION_CREDENTIALS': '/path/to/google-application-credentials.json', 'SAVE_RESULTS': False}}}}, {'mcpServers': {'google-ocr-mcp-server': {'args': ['run', 'google-ocr-mcp-server'], 'command': 'uv', 'env': {'GOOGLE_APPLICATION_CREDENTIALS': '/path/to/google-application-credentials.json', 'SAVE_RESULTS': False}}}}]

来源