search_by_smiles
Find chemical compounds in the SureChEMBL patent database using SMILES structure notation to identify related patents and substances.
Instructions
Search for chemicals by SMILES structure notation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| smiles | Yes | SMILES string of the chemical structure | |
| limit | No | Number of results to return (1-1000, default: 25) |
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 SMILES input and returns a structured response indicating that direct SMILES search is not supported by the SureChEMBL API, providing 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:410-421 (registration)Registration of the 'search_by_smiles' tool in the ListToolsRequestSchema response, including name, description, and input schema definition.
{ 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 CallToolRequestSchema handler that routes calls to the search_by_smiles handler function.
case 'search_by_smiles': return await this.handleSearchBySmiles(args); - src/index.ts:413-420 (schema)Input schema defining the parameters for the search_by_smiles tool: required SMILES string 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'], },