Skip to main content
Glama
Augmented-Nature

SureChEMBL MCP Server

analyze_patent_chemistry

Extract chemical compounds and annotations from patent documents to identify chemical content and related information.

Instructions

Analyze chemical content and annotations in a patent document

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idYesPatent document ID to analyze

Implementation Reference

  • Executes the tool logic: validates input, fetches patent document contents via SureChEMBL API, extracts and aggregates chemical annotations from abstracts and descriptions, computes analysis statistics (total annotations, unique chemicals, categories), and returns formatted JSON response.
    private async handleAnalyzePatentChemistry(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');
        }
    
        // Extract chemical annotations from abstracts and descriptions
        const chemicalAnnotations: any[] = [];
    
        // Process abstracts
        if (document.contents?.patentDocument?.abstracts) {
          document.contents.patentDocument.abstracts.forEach((abstract: any) => {
            if (abstract.section?.annotations) {
              abstract.section.annotations.forEach((annotation: any) => {
                chemicalAnnotations.push({
                  source: 'abstract',
                  language: abstract.lang,
                  annotation: annotation
                });
              });
            }
          });
        }
    
        // Process descriptions
        if (document.contents?.patentDocument?.descriptions) {
          document.contents.patentDocument.descriptions.forEach((description: any) => {
            if (description.section?.annotations) {
              description.section.annotations.forEach((annotation: any) => {
                chemicalAnnotations.push({
                  source: 'description',
                  language: description.lang,
                  annotation: annotation
                });
              });
            }
          });
        }
    
        // Analyze chemical content
        const analysis = {
          document_id: args.document_id,
          total_chemical_annotations: chemicalAnnotations.length,
          unique_chemicals: [...new Set(chemicalAnnotations.map(a => a.annotation.name))],
          annotation_categories: [...new Set(chemicalAnnotations.map(a => a.annotation.category))],
          chemical_annotations: chemicalAnnotations,
          summary: {
            has_chemical_content: chemicalAnnotations.length > 0,
            languages: [...new Set(chemicalAnnotations.map(a => a.language))],
            sources: [...new Set(chemicalAnnotations.map(a => a.source))]
          }
        };
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(analysis, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to analyze patent chemistry: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
  • src/index.ts:487-497 (registration)
    Registers the tool in the ListTools response, providing name, description, and input schema definition.
    {
      name: 'analyze_patent_chemistry',
      description: 'Analyze chemical content and annotations in a patent document',
      inputSchema: {
        type: 'object',
        properties: {
          document_id: { type: 'string', description: 'Patent document ID to analyze' },
        },
        required: ['document_id'],
      },
    },
  • src/index.ts:569-570 (registration)
    Dispatches tool calls to the specific handler function in the CallToolRequestHandler switch statement.
    case 'analyze_patent_chemistry':
      return await this.handleAnalyzePatentChemistry(args);
  • Defines the input schema requiring a 'document_id' string parameter.
    inputSchema: {
      type: 'object',
      properties: {
        document_id: { type: 'string', description: 'Patent document ID to analyze' },
      },
      required: ['document_id'],
    },
  • Type guard function used in the handler to validate input arguments.
    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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool analyzes chemical content and annotations but does not specify whether this is a read-only operation, what permissions are required, how results are returned, or any rate limits. This is inadequate for a tool that likely involves data processing without structured behavioral hints.

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 unnecessary words. It is front-loaded and wastes no space, making it highly concise and well-structured for quick understanding.

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 lack of annotations and output schema, the description is incomplete. It does not explain what the analysis entails, the format of results, or any behavioral aspects like error handling. For a tool that likely returns complex chemical data, this leaves significant gaps in understanding its functionality and output.

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?

The input schema has 100% description coverage, with the single parameter 'document_id' clearly documented. The description does not add any additional meaning beyond the schema, such as format examples or constraints, but since schema coverage is high, the baseline score of 3 is appropriate as the schema handles the parameter documentation adequately.

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 as analyzing chemical content and annotations in patent documents, specifying both the action ('analyze') and resource ('chemical content and annotations in a patent document'). However, it does not explicitly differentiate from sibling tools like 'get_document_content' or 'search_patents', which might also involve patent document analysis, leaving room for ambiguity.

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. It lacks context on prerequisites, such as needing a specific document ID, and does not mention any sibling tools like 'get_document_content' or 'search_patents' as alternatives, leaving the agent without usage direction.

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