Google 专利 MCP 服务器 ( google-patents-mcp )
该项目提供了一个模型上下文协议 (MCP) 服务器,允许通过SerpApi Google Patents API搜索 Google Patents 信息。
变更日志
v0.2.0 (2025-04-17)
**修复:**为
resources/list和prompts/listMCP 方法实现了空处理程序。**修复:**在服务器初始化中声明
prompts功能。**琐事:**更新依赖项。
这些变化旨在提高与可能需要这些标准端点的 MCP 客户端(如 Claude Desktop)的兼容性,尽管尚未对 Claude Desktop 进行直接测试。
Related MCP server: MCP Server for Google Search
特征
提供 MCP 工具
search_patents来搜索 Google Patents。使用 SerpApi 作为后端。
无需本地安装即可直接使用
npx运行。
先决条件
**Node.js:**建议使用 18 或更高版本。
**npm:**运行
npx命令所需。**SerpApi API 密钥:**您需要来自SerpApi的有效 API 密钥才能使用 Google Patents API。
快速启动(使用 npx)
运行此服务器最简单的方法是使用npx 。此命令会直接下载(如有必要)并运行服务器。
npx @kunihiros/google-patents-mcp**注意:**如果@kunihiros/google-patents-mcp名称不同,请将其替换为实际发布的包名称。
服务器将启动并监听标准输入/输出上的 MCP 请求。
配置
服务器需要您的 SerpApi API 密钥。您可以通过以下方式之一提供该密钥:
**环境变量(推荐用于 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" } } } }**.env 文件:**在运行
npx命令的目录中创建一个.env文件(用于本地测试或不使用 MCP 主机时),或者在您的主目录(~/.google-patents-mcp.env)中创建一个 .env 文件,其中包含以下内容:SERPAPI_API_KEY=YOUR_ACTUAL_SERPAPI_KEY # Optional: Set log level (e.g., debug, info, warn, error) # LOG_LEVEL=debug**注意:**虽然使用
.env文件方便进行本地测试、生产环境或与 MCP 主机集成,但直接通过主机配置设置环境变量是推荐且更安全的方法。主要用例是通过npx执行,其中环境变量通常由调用进程或 MCP 主机管理。
服务器按以下顺序搜索.env文件:* ./.env (相对于npx运行的位置)* ~/.google-patents-mcp.env (在您的主目录中)
提供MCP工具
search_patents
通过 SerpApi 搜索 Google 专利。
输入模式:
{
"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"
}
}
}发展
克隆存储库(如果开发需要):
# git clone <repository-url> # cd google-patents-mcp安装依赖项:
npm install**创建
.env文件:**将.env.example复制到.env并添加您的SERPAPI_API_KEY。建造:
npm run build本地运行:
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 许可证(参见 LICENSE 文件)