Skip to main content
Glama
Augmented-Nature

SureChEMBL MCP Server

get_chemical_image

Generate chemical structure images from SMILES or other notations to visualize molecular compounds for research and documentation.

Instructions

Generate chemical structure image from SMILES or other structure notation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
structureYesSMILES string or other structure notation
heightNoImage height in pixels (default: 200)
widthNoImage width in pixels (default: 200)

Implementation Reference

  • The main handler function that validates input arguments, calls the SureChEMBL API endpoint '/service/chemical/image' with structure notation and dimensions, receives image as binary data, encodes it as base64 PNG data URI, and returns structured JSON response.
    private async handleGetChemicalImage(args: any) {
      if (!isValidImageArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid image arguments');
      }
    
      try {
        const height = args.height || 200;
        const width = args.width || 200;
    
        const response = await this.apiClient.get('/service/chemical/image', {
          params: {
            structure: args.structure,
            height: height,
            width: width
          },
          responseType: 'arraybuffer'
        });
    
        // Convert binary data to base64 for JSON response
        const base64Image = Buffer.from(response.data).toString('base64');
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                structure: args.structure,
                image_data: `data:image/png;base64,${base64Image}`,
                dimensions: { width, height },
                message: 'Chemical structure image generated successfully'
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to generate chemical image: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
  • JSON schema defining input parameters for the tool: required 'structure' string (SMILES or notation), optional 'height' and 'width' numbers (50-1000).
    inputSchema: {
      type: 'object',
      properties: {
        structure: { type: 'string', description: 'SMILES string or other structure notation' },
        height: { type: 'number', description: 'Image height in pixels (default: 200)', minimum: 50, maximum: 1000 },
        width: { type: 'number', description: 'Image width in pixels (default: 200)', minimum: 50, maximum: 1000 },
      },
      required: ['structure'],
    },
  • src/index.ts:435-447 (registration)
    Full tool registration entry in the ListToolsRequestSchema handler's tools array, including name, description, and input schema.
    {
      name: 'get_chemical_image',
      description: 'Generate chemical structure image from SMILES or other structure notation',
      inputSchema: {
        type: 'object',
        properties: {
          structure: { type: 'string', description: 'SMILES string or other structure notation' },
          height: { type: 'number', description: 'Image height in pixels (default: 200)', minimum: 50, maximum: 1000 },
          width: { type: 'number', description: 'Image width in pixels (default: 200)', minimum: 50, maximum: 1000 },
        },
        required: ['structure'],
      },
    },
  • src/index.ts:562-563 (registration)
    Switch case in CallToolRequestSchema handler that dispatches execution to the specific tool handler.
    case 'get_chemical_image':
      return await this.handleGetChemicalImage(args);
  • Type guard function validating tool input arguments matching the schema: non-empty structure string, optional height/width in 1-1000 range.
    const isValidImageArgs = (
      args: any
    ): args is { structure: string; height?: number; width?: number } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.structure === 'string' &&
        args.structure.length > 0 &&
        (args.height === undefined || (typeof args.height === 'number' && args.height > 0 && args.height <= 1000)) &&
        (args.width === undefined || (typeof args.width === 'number' && args.width > 0 && args.width <= 1000))
      );
    };
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 the tool generates an image but doesn't describe the output format (e.g., PNG, SVG), potential errors (e.g., invalid SMILES), performance characteristics, or any side effects. For a tool with no annotations and unknown output, this leaves significant gaps in understanding its 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 that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with every element earning its place by specifying the action, output, and input type.

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 no annotations, no output schema, and a tool that generates images (which implies specific output formats and potential errors), the description is incomplete. It doesn't address what the output looks like (e.g., image type, how to handle it), error conditions, or usage constraints, leaving the agent with insufficient context for reliable invocation.

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 three parameters (structure, height, width) with descriptions and constraints. The description adds no additional parameter semantics beyond implying that 'SMILES or other structure notation' maps to the 'structure' parameter. This meets the baseline of 3 when 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 tool's purpose: 'Generate chemical structure image from SMILES or other structure notation.' It specifies the verb (generate), resource (chemical structure image), and input type (SMILES/other notation). However, it doesn't explicitly differentiate from sibling tools like search_by_smiles or search_similar_structures, which might also involve SMILES input but serve different purposes.

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 sibling tools like search_by_smiles (which might retrieve data rather than generate images) or get_chemical_by_id (which might fetch existing records). There's no context about prerequisites, alternatives, or exclusions.

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