Skip to main content
Glama
Augmented-Nature

SureChEMBL MCP Server

get_patent_statistics

Analyze chemical content statistics for patents to understand composition and annotations in the SureChEMBL database.

Instructions

Get statistical overview of chemical content in patents

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idYesPatent document ID for statistics
include_annotationsNoInclude detailed annotation statistics (default: true)

Implementation Reference

  • src/index.ts:523-534 (registration)
    Tool registration entry in the tools list, including name, description, and input schema definition.
    {
      name: 'get_patent_statistics',
      description: 'Get statistical overview of chemical content in patents',
      inputSchema: {
        type: 'object',
        properties: {
          document_id: { type: 'string', description: 'Patent document ID for statistics' },
          include_annotations: { type: 'boolean', description: 'Include detailed annotation statistics (default: true)' },
        },
        required: ['document_id'],
      },
    },
  • src/index.ts:576-577 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes tool calls to the handler method.
    case 'get_patent_statistics':
      return await this.handleGetPatentStatistics(args);
  • The core handler function that implements the tool logic: validates input, fetches patent document from SureChEMBL API, parses annotations from abstracts and descriptions, computes comprehensive statistics on chemical content, and returns formatted JSON results.
    private async handleGetPatentStatistics(args: any) {
      if (!isValidDocumentArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid document arguments');
      }
    
      try {
        const response = await this.apiClient.get(`/document/${args.document_id}/contents`);
        const document = response.data.data;
    
        if (!document) {
          throw new Error('Document not found');
        }
    
        const includeAnnotations = args.include_annotations !== false;
    
        // Extract basic document information
        const docInfo = document.contents?.patentDocument?.bibliographicData;
        const abstracts = document.contents?.patentDocument?.abstracts || [];
        const descriptions = document.contents?.patentDocument?.descriptions || [];
    
        // Collect all chemical annotations
        const allAnnotations: any[] = [];
    
        abstracts.forEach((abstract: any) => {
          if (abstract.section?.annotations) {
            abstract.section.annotations.forEach((annotation: any) => {
              allAnnotations.push({
                ...annotation,
                source: 'abstract',
                language: abstract.lang
              });
            });
          }
        });
    
        descriptions.forEach((description: any) => {
          if (description.section?.annotations) {
            description.section.annotations.forEach((annotation: any) => {
              allAnnotations.push({
                ...annotation,
                source: 'description',
                language: description.lang
              });
            });
          }
        });
    
        // Calculate statistics
        const chemicalAnnotations = allAnnotations.filter(a => a.category === 'chemical');
        const uniqueChemicals = [...new Set(chemicalAnnotations.map(a => a.name))];
        const chemicalFrequencies = chemicalAnnotations.reduce((acc: any, annotation: any) => {
          acc[annotation.name] = (acc[annotation.name] || 0) + 1;
          return acc;
        }, {});
    
        const statistics = {
          document_id: args.document_id,
          document_info: {
            title: docInfo?.inventionTitles?.find((t: any) => t.lang === 'EN')?.title || 'N/A',
            publication_number: docInfo?.publicationReference?.[0]?.ucid || 'N/A',
            publication_date: docInfo?.publicationReference?.[0]?.documentId?.[0]?.date || 'N/A'
          },
          content_statistics: {
            total_sections: abstracts.length + descriptions.length,
            abstract_sections: abstracts.length,
            description_sections: descriptions.length,
            languages: [...new Set([...abstracts, ...descriptions].map((s: any) => s.lang))]
          },
          chemical_statistics: {
            total_chemical_annotations: chemicalAnnotations.length,
            unique_chemicals_count: uniqueChemicals.length,
            most_frequent_chemicals: Object.entries(chemicalFrequencies)
              .sort(([,a], [,b]) => (b as number) - (a as number))
              .slice(0, 10)
              .map(([name, count]) => ({ name, count })),
            annotation_sources: {
              abstract: chemicalAnnotations.filter(a => a.source === 'abstract').length,
              description: chemicalAnnotations.filter(a => a.source === 'description').length
            }
          },
          annotation_categories: {
            chemical: chemicalAnnotations.length,
            other: allAnnotations.length - chemicalAnnotations.length,
            total: allAnnotations.length
          }
        };
    
        if (includeAnnotations) {
          (statistics as any).detailed_annotations = {
            chemical_annotations: chemicalAnnotations,
            unique_chemicals: uniqueChemicals,
            chemical_frequencies: chemicalFrequencies
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(statistics, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to get patent statistics: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
  • Type guard function for validating input arguments matching the tool's input schema (document_id required, include_annotations optional). Used in the handler.
    const isValidDocumentArgs = (
      args: any
    ): args is { document_id: string; include_annotations?: boolean } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.document_id === 'string' &&
        args.document_id.length > 0 &&
        (args.include_annotations === undefined || typeof args.include_annotations === 'boolean')
      );
    };
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it 'gets' statistics, implying a read-only operation, but doesn't specify if it's safe, has rate limits, requires authentication, or what the output format might be. For a tool with no annotations, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 statistical analysis, no annotations, and no output schema, the description is incomplete. It doesn't explain what 'statistical overview' entails, the types of statistics returned, or any behavioral traits like error handling. For a tool with these gaps, it should provide more context to be fully helpful.

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 both parameters ('document_id' and 'include_annotations') with clear descriptions. The description adds no additional meaning beyond what the schema provides, such as examples or context for the parameters, so it meets the baseline for high coverage.

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 action ('Get statistical overview') and resource ('chemical content in patents'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'get_chemical_frequency' or 'analyze_patent_chemistry', which might offer overlapping functionality, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'get_chemical_frequency' or 'analyze_patent_chemistry'. It lacks context about use cases, prerequisites, or exclusions, leaving the agent to infer usage from the name and schema alone.

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/Augmented-Nature/SureChEMBL-MCP-Server'

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