专利搜索服务

提供通过SerpApi Google Patents API搜索专利信息的Model Context Protocol (MCP)服务器。

  • by KunihiroS
  • JavaScript
  • 本地部署
  • 41 星标
  • 更新于
在 GitHub 查看 KunihiroS/google-patents-mcp

使用说明

谷歌MCP服务器专利(google-patents-mcp)

该项目提供了一个模型上下文协议(MCP)服务器,允许通过 SerpApi谷歌专利API.

通过Smithery安装

通过以下方式自动安装适用于克劳德桌面的谷歌专利MCP服务器 史密瑟里:

npx -y @smithery/cli install @KunihiroS/google-patents-mcp --client claude

更新日志

v0.2.0(2025-04-17)

  • 修复: 为实现了空处理程序 resources/list 和 prompts/list MCP方法。
  • 修复: 宣布 prompts 服务器初始化能力。
  • 家务活: 更新了依赖关系。

这些更改旨在提高与可能需要这些标准端点的MCP客户端(如Claude Desktop)的兼容性,尽管尚未对Claude Desktop进行直接测试。

特性

  • 提供MCP工具 search_patents 搜索谷歌专利。
  • 使用SerpApi作为后端。
  • 可以直接使用运行 npx 无需本地安装。

先决条件

  • Node.js: 建议使用18或更高版本。
  • npm: 需要运行 npx 命令。
  • SerpApi API密钥: 您需要来自的有效API密钥 SerpApi 使用谷歌专利API。

快速入门(使用npx)

运行此服务器的最简单方法是使用 npx。此命令下载(如果需要)并直接运行服务器。

npx @kunihiros/google-patents-mcp

注: 替换 @kunihiros/google-patents-mcp 如果实际发布的包名称不同,则使用该名称。

服务器将启动并监听标准输入/输出上的MCP请求。

配置

服务器需要您的SerpApi API密钥。您可以通过以下方式之一提供它:

  1. 环境变量(建议用于MCP主机): 设置 SERPAPI_API_KEY 运行服务器时的环境变量。MCP主机配置通常允许为服务器设置环境变量。

    MCP主机配置示例代码段(config.json 或类似):

    {
      "mcpServers": {
        "google-patents-mcp": {
          "command": "npx",
          "args": [
            "-y", // Skips confirmation if the package isn't installed locally
            "@kunihiros/google-patents-mcp" // Use the correct package name
          ],
          "env": {
            "SERPAPI_API_KEY": "YOUR_ACTUAL_SERPAPI_KEY"
            // Optional: Set log level
            // "LOG_LEVEL": "debug"
          }
        }
      }
    }
    
  2. .env文件: 创建一个 .env 运行文件的目录中的文件 npx 命令(用于本地测试或如果不使用MCP主机),或在您的主目录中(~/.google-patents-mcp.env),内容如下:

    SERPAPI_API_KEY=YOUR_ACTUAL_SERPAPI_KEY
    # Optional: Set log level (e.g., debug, info, warn, error)
    # LOG_LEVEL=debug
    

    注: 当使用a .env 该文件便于本地测试、生产或与MCP主机集成,建议直接通过主机配置设置环境变量,这是一种更安全的方法。主要预期用例是通过以下方式执行 npx,其中环境变量通常由调用进程或MCP主机管理。

服务器搜索 .env 文件按以下顺序排列: * ./.env (相对于何处 npx 正在运行) * ~/.google-patents-mcp.env (在您的主目录中)

提供MCP工具

search_patents

通过SerpApi搜索谷歌专利。

输入架构:

{
  "type": "object",
  "properties": {
    "q": {
      "type": "string",
      "description": "Search query (required). Although optional in SerpApi docs, a non-empty query is practically needed. Use semicolon (;) to separate multiple terms. Advanced syntax like '(Coffee) OR (Tea);(A47J)' is supported. See 'About Google Patents' for details."
    },
    "page": {
      "type": "integer",
      "description": "Page number for pagination (default: 1).",
      "default": 1
    },
    "num": {
      "type": "integer",
      "description": "Number of results per page (default: 10). **IMPORTANT: Must be 10 or greater (up to 100).**",
      "default": 10,
      "minimum": 10,
      "maximum": 100
    },
    "sort": {
      "type": "string",
      "enum": ["relevance", "new", "old"],
      "description": "Sorting method. 'relevance' (default), 'new' (newest by filing/publication date), 'old' (oldest by filing/publication date).",
      "default": "relevance"
    },
    "before": {
      "type": "string",
      "description": "Maximum date filter (e.g., 'publication:20231231', 'filing:20220101'). Format: type:YYYYMMDD where type is 'priority', 'filing', or 'publication'."
    },
    "after": {
      "type": "string",
      "description": "Minimum date filter (e.g., 'publication:20230101', 'filing:20220601'). Format: type:YYYYMMDD where type is 'priority', 'filing', or 'publication'."
    },
    "inventor": {
      "type": "string",
      "description": "Filter by inventor names. Separate multiple names with a comma (,)."
    },
    "assignee": {
      "type": "string",
      "description": "Filter by assignee names. Separate multiple names with a comma (,)."
    },
    "country": {
      "type": "string",
      "description": "Filter by country codes (e.g., 'US', 'WO,JP'). Separate multiple codes with a comma (,)."
    },
    "language": {
      "type": "string",
      "description": "Filter by language (e.g., 'ENGLISH', 'JAPANESE,GERMAN'). Separate multiple languages with a comma (,). Supported: ENGLISH, GERMAN, CHINESE, FRENCH, SPANISH, ARABIC, JAPANESE, KOREAN, PORTUGUESE, RUSSIAN, ITALIAN, DUTCH, SWEDISH, FINNISH, NORWEGIAN, DANISH."
    },
    "status": {
      "type": "string",
      "enum": ["GRANT", "APPLICATION"],
      "description": "Filter by patent status: 'GRANT' or 'APPLICATION'."
    },
    "type": {
      "type": "string",
      "enum": ["PATENT", "DESIGN"],
      "description": "Filter by patent type: 'PATENT' or 'DESIGN'."
    },
    "scholar": {
      "type": "boolean",
      "description": "Include Google Scholar results (default: false).",
      "default": false
    }
  },
  "required": ["q"]
}

输出:

返回一个包含SerpApi搜索结果的JSON对象。该结构遵循SerpApi响应格式。

示例用法(MCP请求):

{
  "mcp_version": "1.0",
  "type": "CallToolRequest",
  "id": "req-123",
  "server_name": "google-patents-mcp",
  "params": {
    "name": "search_patents",
    "arguments": {
      "q": "organic light emitting diode",
      "num": 10,
      "language": "ENGLISH",
      "status": "GRANT",
      "after": "publication:20230101"
    }
  }
}

发展

  1. 克隆存储库(如果开发需要):
    # git clone <repository-url>
    # cd google-patents-mcp
    
  2. 安装依赖项:
    npm install
    
  3. 创建 .env 文件: 复制 .env.example 向 .env 并添加您的 SERPAPI_API_KEY.
  4. 构建:
    npm run build
    
  5. 在本地运行:
    npm start
    
    或者用于自动重建的开发:
    npm run dev
    

日志记录

  • 日志输出为标准错误。
  • 日志级别可以通过以下方式控制 LOG_LEVEL 环境变量(error, warn, info, http, verbose, debug, silly).默认为 info.
  • 试图在项目根目录中创建日志文件(google-patents-server.log),用户的主目录(~/.google-patents-server.log),或 /tmp/google-patents-server.log.

许可证

MIT许可证(见许可证文件)