Skip to main content
Glama
Augmented-Nature

SureChEMBL MCP Server

export_chemicals

Export chemical patent data in CSV or XML format using SureChEMBL chemical IDs. Process up to 100 chemical records per request to retrieve structured data from the patent database.

Instructions

Bulk export chemical data in CSV or XML format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chemical_idsYesArray of SureChEMBL chemical IDs (1-100)
output_typeNoExport format (default: csv)
kindNoID type for export (default: cid)

Implementation Reference

  • The handler function for the 'export_chemicals' tool. Validates input arguments using isValidExportArgs, constructs API parameters, calls the SureChEMBL /export/chemistry endpoint to fetch binary export data, encodes it as base64, and returns it embedded in a JSON response.
    private async handleExportChemicals(args: any) {
      if (!isValidExportArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid export arguments');
      }
    
      try {
        const chemIDs = args.chemical_ids.join(',');
        const outputType = args.output_type || 'csv';
        const kind = args.kind || 'cid';
    
        const response = await this.apiClient.get('/export/chemistry', {
          params: {
            chemIDs: chemIDs,
            output_type: outputType,
            kind: kind
          },
          responseType: 'arraybuffer'
        });
    
        // Convert binary data to base64 for JSON response
        const base64Data = Buffer.from(response.data).toString('base64');
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                chemical_ids: args.chemical_ids,
                output_type: outputType,
                kind: kind,
                export_data: `data:application/zip;base64,${base64Data}`,
                message: `Successfully exported ${args.chemical_ids.length} chemicals in ${outputType} format`
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to export chemicals: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
  • The input schema definition for the 'export_chemicals' tool, registered in the ListTools response. Specifies properties for chemical_ids (array 1-100), output_type (csv/xml), and kind (cid/smiles).
    {
      name: 'export_chemicals',
      description: 'Bulk export chemical data in CSV or XML format',
      inputSchema: {
        type: 'object',
        properties: {
          chemical_ids: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of SureChEMBL chemical IDs (1-100)',
            minItems: 1,
            maxItems: 100
          },
          output_type: {
            type: 'string',
            enum: ['csv', 'xml'],
            description: 'Export format (default: csv)'
          },
          kind: {
            type: 'string',
            enum: ['cid', 'smiles'],
            description: 'ID type for export (default: cid)'
          },
        },
        required: ['chemical_ids'],
      },
    },
  • src/index.ts:567-568 (registration)
    The switch case in the CallToolRequestSchema handler that routes 'export_chemicals' calls to the handleExportChemicals method.
    case 'export_chemicals':
      return await this.handleExportChemicals(args);
  • Type guard function used to validate input arguments for the export_chemicals tool before execution.
    const isValidExportArgs = (
      args: any
    ): args is { chemical_ids: string[]; output_type?: string; kind?: string } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        Array.isArray(args.chemical_ids) &&
        args.chemical_ids.length > 0 &&
        args.chemical_ids.length <= 100 &&
        args.chemical_ids.every((id: any) => typeof id === 'string' && id.length > 0) &&
        (args.output_type === undefined || ['csv', 'xml'].includes(args.output_type)) &&
        (args.kind === undefined || ['cid', 'smiles'].includes(args.kind))
      );
    };
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks critical behavioral details. It mentions bulk export and formats but doesn't disclose permissions needed, rate limits, file size constraints, whether it's a synchronous or asynchronous operation, or what the output contains. 'Bulk' hints at scale but without specifics, leaving gaps in understanding the tool's behavior.

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 with zero waste. It front-loads key information ('bulk export chemical data') and specifies formats concisely. Every word earns its place, 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?

For a tool with 3 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., execution mode, limits), output structure, and usage context. While concise, it doesn't compensate for the missing structured data, leaving the agent with insufficient information for optimal use.

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 fully documents all parameters. The description adds no additional parameter semantics beyond implying bulk handling and format options, which are already covered by the schema's descriptions and enums. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('bulk export') and resource ('chemical data'), specifying the output formats (CSV or XML). It distinguishes from siblings by focusing on export functionality rather than search, analysis, or retrieval operations. However, it doesn't explicitly contrast with specific sibling tools like 'get_chemical_properties' or 'search_chemicals_by_name'.

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 doesn't mention prerequisites, ideal scenarios, or contrast with sibling tools like 'get_chemical_by_id' for single records or 'search_chemicals_by_name' for different query types. Usage is implied by the name and purpose but not explicitly stated.

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