Skip to main content
Glama

get_patent_trends

Analyze annual patent application and issuance trends by technology field or keywords to identify innovation patterns and competitive landscapes.

Instructions

Analyze annual application and issued trends for patents. Understand the trends of patents related to specific technology fields or keywords. Either keywords or IPC classification must be specified.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordsNoKeywords to search within patent title and abstract/summary. Supports AND, OR, NOT logic. Example: "mobile phone AND (screen OR battery)"
ipcNoPatent IPC classification code. Used to specify a particular technology field.
apply_start_timeNoPatent application start year (yyyy format). Filters by application filing date.
apply_end_timeNoPatent application end year (yyyy format). Filters by application filing date.
public_start_timeNoPatent publication start year (yyyy format). Filters by publication date.
public_end_timeNoPatent publication end year (yyyy format). Filters by publication date.
authorityNoPatent authority code (e.g., CN, US, EP, JP). Filters by patent office. Use OR for multiple, e.g., "US OR EP".

Implementation Reference

  • The handler function that implements the get_patent_trends tool by constructing query parameters from input args and delegating to the shared PatSnap API caller for the 'patent-trends' endpoint.
    async function getPatentTrends(args: BasePatentArgs): Promise<ServerResult> {
      const params = buildCommonSearchParams(args);
      return callPatsnapApi('patent-trends', params, 'get patent trends');
    }
  • TypeScript object schema defining the input parameters for the get_patent_trends tool (and others), including optional fields for keywords, IPC, date ranges, and authority.
    const basePatentInputSchema = {
        type: 'object' as const, // Use 'as const' for stricter type checking
        properties: {
            keywords: { type: 'string', description: 'Keywords to search within patent title and abstract/summary. Supports AND, OR, NOT logic. Example: "mobile phone AND (screen OR battery)"' },
            ipc: { type: 'string', description: 'Patent IPC classification code. Used to specify a particular technology field.' },
            apply_start_time: { type: 'string', description: 'Patent application start year (yyyy format). Filters by application filing date.' },
            apply_end_time: { type: 'string', description: 'Patent application end year (yyyy format). Filters by application filing date.' },
            public_start_time: { type: 'string', description: 'Patent publication start year (yyyy format). Filters by publication date.' },
            public_end_time: { type: 'string', description: 'Patent publication end year (yyyy format). Filters by publication date.' },
            authority: { type: 'string', description: 'Patent authority code (e.g., CN, US, EP, JP). Filters by patent office. Use OR for multiple, e.g., "US OR EP".' }
        },
        // Add a note about requiring keywords or IPC for most tools
        description: "Requires either 'keywords' or 'ipc' to be specified for a meaningful search. If both are provided, IPC is prioritized by the API."
    };
  • src/index.ts:336-340 (registration)
    Registers the get_patent_trends tool in the ListToolsRequestHandler response, specifying its name, description, and input schema.
    {
      name: 'get_patent_trends',
      description: 'Analyze annual application and issued trends for patents. Understand the trends of patents related to specific technology fields or keywords. Either keywords or IPC classification must be specified.',
      inputSchema: basePatentInputSchema
    },
  • src/index.ts:394-394 (registration)
    Registers the tool name to handler mapping in the dispatch object used by CallToolRequestHandler.
    'get_patent_trends': getPatentTrends,
  • Core helper function that performs authenticated GET requests to PatSnap API endpoints, handles errors, token management, and formats responses as ServerResult. Called by the getPatentTrends handler.
    async function callPatsnapApi(endpoint: string, params: URLSearchParams, errorContext: string): Promise<ServerResult> {
        const token = await getAccessToken(); // Will use cached token if available and valid
        const url = `${PATSNAP_API_BASE_URL}/insights/${endpoint}?${params.toString()}`;
        console.log(`Calling PatSnap API: ${url}`); // Log the request URL (consider using a proper logger)
    
        let response: Response;
        try {
            response = await fetch(url, {
                method: 'GET',
                headers: {
                    // 'Content-Type': 'application/json', // Typically not needed for GET
                    'Authorization': `Bearer ${token}`
                }
                // Consider adding a timeout
                // signal: AbortSignal.timeout(15000) // e.g., 15 seconds timeout
            });
        } catch (error) {
            console.error(`Network error calling PatSnap API endpoint ${endpoint}:`, error);
            throw new McpError(503, `Network error connecting to PatSnap API (${endpoint}): ${error instanceof Error ? error.message : String(error)}`);
        }
    
    
        if (!response.ok) {
            let errorText = `Status code ${response.status}`;
            try {
                errorText = await response.text();
            } catch (e) {
                console.error("Failed to read error response body:", e);
            }
            console.error(`API Error (${response.status}) for ${endpoint}: ${errorText}`); // Log error details
            // Invalidate cache on auth errors (401 Unauthorized, 403 Forbidden)
            if (response.status === 401 || response.status === 403) {
                 cachedToken = null;
                 console.log('Authentication error detected, clearing token cache.');
            }
            // Map common PatSnap error codes to potentially more user-friendly messages if desired
            // Example: if (errorText.includes("67200002")) { throw new McpError(429, "PatSnap API quota exceeded."); }
            throw new McpError(response.status, `Failed to ${errorContext}: ${errorText}`);
        }
    
        let json: PatsnapApiResponse; // Use interface type
        try {
            json = await response.json() as PatsnapApiResponse; // Type assertion
        } catch (error) {
            console.error(`Error parsing JSON response from ${endpoint}:`, error);
            throw new McpError(500, `Failed to parse JSON response from PatSnap API (${endpoint}): ${error instanceof Error ? error.message : String(error)}`);
        }
    
        // Basic check for PatSnap's own error structure within a 200 OK response
        if (json && typeof json.status === 'boolean' && json.status === false && json.error_code !== 0) {
            console.error(`PatSnap API returned error within successful response for ${endpoint}: Code ${json.error_code}, Msg: ${json.error_msg}`);
            // You might want to map these internal errors to McpError as well
            throw new McpError(400, `PatSnap API Error (${json.error_code || 'N/A'}): ${json.error_msg || 'Unknown error'}`);
        }
    
        return {
            content: [
                {
                    type: 'text',
                    // Return the raw JSON response as text, formatted for readability
                    text: JSON.stringify(json, null, 2)
                }
            ]
        };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions that 'IPC is prioritized by the API' when both keywords and IPC are provided, which adds useful behavioral context. However, it doesn't describe what the analysis returns (e.g., time series data, charts, statistics), whether there are rate limits, authentication requirements, or what happens with missing parameters. For a 7-parameter analytical tool with no annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with three sentences that each serve a purpose: stating the tool's function, elaborating on the analysis scope, and specifying parameter requirements. It's front-loaded with the core purpose and avoids unnecessary repetition. However, the second sentence could be slightly more direct.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a 7-parameter analytical tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (trend data format, visualization, statistical summary), doesn't mention any limitations or constraints, and provides minimal behavioral context. For a tool that presumably returns complex analytical results, this leaves significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 7 parameters thoroughly. The description adds minimal value beyond the schema by emphasizing the 'either keywords or IPC' requirement and the IPC prioritization rule. It doesn't provide additional semantic context about how the analysis works or what the parameters mean in the context of trend analysis, so the baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Analyze annual application and issued trends for patents' with a specific focus on 'trends related to specific technology fields or keywords.' It uses a clear verb ('Analyze') and resource ('patents'), but doesn't explicitly differentiate from siblings like 'get_most_cited_patents' or 'get_top_assignees' which focus on different aspects of patent data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides some usage context by stating 'Either keywords or IPC classification must be specified,' which helps understand when to use this tool versus a generic search. However, it doesn't explicitly contrast with sibling tools or provide guidance on when to choose this trend analysis tool over alternatives like 'get_word_cloud' or 'get_wheel_of_innovation' for similar analytical purposes.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/KunihiroS/patsnap-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server