search_by_smiles
Search the SureChEMBL chemical patent database by entering a SMILES string to identify relevant chemical structures and retrieve related patent data.
Instructions
Search for chemicals by SMILES structure notation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of results to return (1-1000, default: 25) | |
| smiles | Yes | SMILES string of the chemical structure |
Implementation Reference
- src/index.ts:748-773 (handler)The handler function that implements the core logic for the 'search_by_smiles' tool. It validates the input SMILES string and returns a response indicating that direct SMILES search is not supported by the SureChEMBL API, with suggestions for alternatives.private async handleSearchBySmiles(args: any) { if (!args || typeof args.smiles !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid SMILES string'); } try { // SureChEMBL doesn't have direct SMILES search, so we'll return a helpful message return { content: [ { type: 'text', text: JSON.stringify({ message: 'SMILES search not directly supported by SureChEMBL API', smiles: args.smiles, suggestion: 'Try converting SMILES to chemical name or use structure-based search tools' }, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to search by SMILES: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:413-420 (schema)Input schema definition for the 'search_by_smiles' tool, specifying the required 'smiles' parameter and optional 'limit'.inputSchema: { type: 'object', properties: { smiles: { type: 'string', description: 'SMILES string of the chemical structure' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, }, required: ['smiles'], },
- src/index.ts:410-421 (registration)The tool registration object in the tools array passed to server.setTools(), defining the tool's name, description, and input schema.{ name: 'search_by_smiles', description: 'Search for chemicals by SMILES structure notation', inputSchema: { type: 'object', properties: { smiles: { type: 'string', description: 'SMILES string of the chemical structure' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, }, required: ['smiles'], }, },
- src/index.ts:557-558 (registration)Dispatch case in the MCP request handler (setRequestHandler) that routes 'search_by_smiles' tool calls to the handleSearchBySmiles method.case 'search_by_smiles': return await this.handleSearchBySmiles(args);