google-patents-mcp

SoftwareStartups/google-patents-mcp

3.2

If you are the rightful owner of google-patents-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Google Patents MCP Server allows users to search and retrieve patent information using the SerpApi Google Patents API.

Tools
2
Resources
0
Prompts
0

Google Patents MCP Server (google-patents-mcp)

smithery badge npm version

This project provides a Model Context Protocol (MCP) server that allows searching Google Patents information via the SerpApi Google Patents API.

Credits

This project is a fork of the original google-patents-mcp by Kunihiro Sasayama. We extend our gratitude for the foundational work and inspiration.

Installing via Smithery

To install Google Patents MCP Server for Claude Desktop automatically via Smithery:

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

Features

  • Provides two focused MCP tools for patent research:
    • search_patents - Fast metadata search via SerpApi
    • get_patent - Comprehensive patent data retrieval (claims, description, family members, citations, metadata)
  • Uses SerpApi for both search and detailed patent information via structured endpoints.
  • Can be run directly using npx without local installation.

Prerequisites

  • Node.js: Version 18 or higher is recommended.
  • npm: Required to run the npx command.
  • SerpApi API Key: You need a valid API key from SerpApi to use the Google Patents API.

Quick Start (Using npx)

The easiest way to run this server is using npx. This command downloads (if necessary) and runs the server directly.

npx @softwarestartups/google-patents-mcp

The server will start and listen for MCP requests on standard input/output.

Configuration

The server requires your SerpApi API key. You can provide it in one of the following ways:

  1. Environment Variable (Recommended for MCP Hosts): Set the SERPAPI_API_KEY environment variable when running the server. MCP Host configurations often allow setting environment variables for servers.

    Example MCP Host configuration snippet (config.json or similar):

    {
      "mcpServers": {
        "google-patents-mcp": {
          "command": "npx",
          "args": [
            "-y",
            "@softwarestartups/google-patents-mcp"
          ],
          "env": {
            "SERPAPI_API_KEY": "YOUR_ACTUAL_SERPAPI_KEY"
          }
        }
      }
    }
    
  2. .env File: Create a .env file in the directory where you run the npx command (for local testing or if not using an MCP Host), or in your home directory (~/.google-patents-mcp.env), with the following content:

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

    Note: While using a .env file is convenient for local testing, for production or integration with MCP Hosts, setting the environment variable directly via the host configuration is the recommended and more secure approach. The primary intended use case is execution via npx, where environment variables are typically managed by the calling process or MCP Host.

    The server searches for .env files in the following order:

    • ./.env (relative to where npx is run)
    • ~/.google-patents-mcp.env (in your home directory)

Provided MCP Tools

search_patents

Searches Google Patents via SerpApi. Returns patent metadata only (no full text).

Parameters:

ParameterTypeRequiredDescription
qstringNoSearch query. Use semicolon to separate terms
pageintegerNoPage number for pagination (default: 1)
numintegerNoResults per page (10-100, default: 10)
sortstringNoSort by: 'new' (newest by filing/publication date) or 'old' (oldest by filing/publication date)
beforestringNoMax date filter (e.g., 'publication:20231231')
afterstringNoMin date filter (e.g., 'publication:20230101')
inventorstringNoFilter by inventor names (comma-separated)
assigneestringNoFilter by assignee names (comma-separated)
countrystringNoFilter by country codes (e.g., 'US', 'WO,JP')
languagestringNoFilter by language (e.g., 'ENGLISH', 'JAPANESE')
statusstringNoFilter by status: 'GRANT' or 'APPLICATION'
typestringNoFilter by type: 'PATENT' or 'DESIGN'
scholarbooleanNoInclude Google Scholar results (default: false)

Returns: Patent metadata including title, publication number, assignee, inventor, dates, and patent_link (used for get_patent).

Example:

{
  "name": "search_patents",
  "arguments": {
    "q": "quantum computing",
    "num": 10,
    "status": "GRANT",
    "country": "US",
    "after": "publication:20230101"
  }
}

get_patent

Fetches comprehensive patent data from SerpAPI including claims, description, family members, citations, and metadata. Supports selective content retrieval through the include parameter.

Parameters:

ParameterTypeRequiredDescription
patent_urlstringNo*Full Google Patents URL (from search results)
patent_idstringNo*Patent ID (e.g., 'US1234567A')
includearrayNoArray of content sections to include. Valid values (case-insensitive): "claims", "description", "abstract", "family_members", "citations", "metadata". Defaults to ["metadata", "abstract"].
max_lengthintegerNoMaximum character length for returned content. Content will be truncated at natural boundaries (paragraph ends, complete claims). If omitted, no limit is applied.

*At least one parameter (patent_url or patent_id) must be provided. If both are provided, patent_url takes precedence.

Returns: JSON object with requested fields:

  • patent_id (string): Patent identifier
  • title (string): Patent title (if "metadata" is in include array)
  • abstract (string): Patent abstract summary (if "abstract" is in include array)
  • description (string): Full patent description text (if "description" is in include array)
  • claims (string[]): Array of patent claims (if "claims" is in include array)
  • family_members (array): Patent family members with region and status (if "family_members" is in include array)
  • citations (object): Citation counts including forward_citations, backward_citations, family_to_family_citations (if "citations" is in include array)
  • publication_number (string): Patent publication number (if "metadata" is in include array)
  • assignee (string): Patent assignee (if "metadata" is in include array)
  • inventor (string): Patent inventor (if "metadata" is in include array)
  • priority_date (string): Priority filing date (if "metadata" is in include array)
  • filing_date (string): Filing date (if "metadata" is in include array)
  • publication_date (string): Publication date (if "metadata" is in include array)
  • grant_date (string): Grant date (if "metadata" is in include array)

Fields are omitted from the response if they are not requested in the include array or if the content could not be retrieved.

Examples:

Fetch metadata and abstract (default):

{
  "name": "get_patent",
  "arguments": {
    "patent_url": "https://patents.google.com/patent/US7654321B2"
  }
}

Using patent ID:

{
  "name": "get_patent",
  "arguments": {
    "patent_id": "US7654321B2"
  }
}

Fetch only claims:

{
  "name": "get_patent",
  "arguments": {
    "patent_id": "US7654321B2",
    "include": ["claims"]
  }
}

Fetch only abstract:

{
  "name": "get_patent",
  "arguments": {
    "patent_id": "US7654321B2",
    "include": ["abstract"]
  }
}

Fetch comprehensive patent analysis with all sections:

{
  "name": "get_patent",
  "arguments": {
    "patent_url": "https://patents.google.com/patent/US7654321B2",
    "include": ["metadata", "abstract", "description", "claims", "family_members", "citations"]
  }
}

Fetch content with length limit to minimize token usage:

{
  "name": "get_patent",
  "arguments": {
    "patent_id": "US7654321B2",
    "include": ["description", "claims"],
    "max_length": 5000
  }
}

Typical Workflow

The two tools are designed to work together:

  1. Search for patents using search_patents to find relevant patents
  2. Get comprehensive data using get_patent for patents of interest

Example workflow:

// Step 1: Search for patents
const searchResult = await callTool({
  name: "search_patents",
  arguments: {
    q: "neural network chip",
    num: 10,
    status: "GRANT"
  }
});

// Step 2: Get comprehensive data for first result
const firstPatent = searchResult.organic_results[0];
const patentData = await callTool({
  name: "get_patent",
  arguments: {
    patent_url: firstPatent.patent_link,
    include: ["metadata", "abstract", "description", "claims", "family_members", "citations"]
  }
});

// Now you have comprehensive patent data including:
// - Basic metadata (title, assignee, dates)
// - Abstract summary
// - Full description and claims
// - Patent family members across different countries
// - Citation counts for patent strength assessment
console.log(patentData.family_members);
console.log(patentData.citations);

Development

Setup

  1. Clone the repository:

    git clone https://github.com/SoftwareStartups/google-patents-mcp.git
    cd google-patents-mcp
    
  2. Install dependencies:

    make install
    # or: npm install
    
  3. Set up environment variables:

    Create a .env file in the project root. First, create a .env.example file with the following content:

    # SerpApi Configuration
    # Get your API key from https://serpapi.com/
    SERPAPI_API_KEY=your_serpapi_key_here
    
    # Optional: Set log level (error, warn, info, http, verbose, debug, silly)
    # LOG_LEVEL=info
    

    Then copy it to .env and edit with your actual API key:

    cp .env.example .env
    # Edit .env and replace 'your_serpapi_key_here' with your actual SerpApi key
    

Development Workflow

Build the project:

make build
# or: npm run build

Format code:

make format
# or: npm run format

Check code quality (lint + typecheck):

make check
# or: npm run lint && npm run typecheck

Run tests:

make test
# or: npm test

Clean build artifacts:

make clean

Full build pipeline:

make all
# Runs: clean → install → build → check → test

Run Locally

Production mode:

npm start

Development mode (with auto-rebuild):

npm run dev

Testing

The project includes unit tests, integration tests, and end-to-end tests with real API calls:

# Install dependencies and build
make install
make build

# Set up environment variables (see Development Setup section above)
# The e2e tests will automatically load SERPAPI_API_KEY from .env file

# Run all tests (unit + integration)
make test

# Run unit tests only
make test-unit

# Run integration tests only
make test-integration

# Run end-to-end tests with real SerpAPI calls
make test-e2e

# Run all tests including e2e
make test-all

Test Types

  • Unit Tests: Test individual functions and classes in isolation
  • Integration Tests: Test the MCP server functionality with mocked API responses
  • End-to-End Tests: Test complete workflows with real SerpAPI calls

The end-to-end tests validate that the server can successfully:

  • Search for patents using real SerpAPI queries
  • Fetch patent content with claims, descriptions, and metadata
  • Handle various search filters and parameters
  • Process patent family members and citations
  • Complete full workflows from search to content retrieval

Note: End-to-end tests automatically load SERPAPI_API_KEY from the .env file and will make actual API calls, which may consume your SerpAPI quota.

Logging

  • Logs are output to standard error.
  • Log level can be controlled via the LOG_LEVEL environment variable (error, warn, info, http, verbose, debug, silly). Defaults to info.
  • A log file is attempted to be created in the project root (google-patents-server.log), user's home directory (~/.google-patents-server.log), or /tmp/google-patents-server.log.