Skip to main content
Glama

analyze_patent_chemistry

Extract and analyze chemical compounds and annotations from patent documents using the SureChEMBL chemical patent database. Input a patent document ID to identify and evaluate relevant chemical content.

Instructions

Analyze chemical content and annotations in a patent document

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idYesPatent document ID to analyze

Implementation Reference

  • The primary handler function that executes the tool logic: validates input, fetches patent document contents via SureChEMBL API, extracts chemical annotations from abstracts and descriptions, computes analysis statistics (total annotations, unique chemicals, categories, summary), 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)
    Tool registration entry in the ListTools response, including 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)
    Switch case in CallToolRequest handler that routes tool calls to the specific handler method.
    case 'analyze_patent_chemistry': return await this.handleAnalyzePatentChemistry(args);
  • Input schema definition specifying the required 'document_id' parameter as a string.
    inputSchema: { type: 'object', properties: { document_id: { type: 'string', description: 'Patent document ID to analyze' }, }, required: ['document_id'], },
  • Helper function for input validation specific to document arguments, ensuring valid 'document_id' string; 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') ); };

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