search_patents
Search patents in the SureChEMBL database using text, keywords, or identifiers to retrieve relevant results quickly and efficiently.
Instructions
Search patents by text, keywords, or identifiers in SureChEMBL database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of results to return (1-1000, default: 25) | |
| offset | No | Number of results to skip (default: 0) | |
| query | Yes | Search query (keywords, patent numbers, or text) |
Implementation Reference
- src/index.ts:599-626 (handler)Implements the core logic for the 'search_patents' tool: validates input using isValidSearchArgs, performs a chemical name search via SureChEMBL API as proxy for patent search, and formats the response.private async handleSearchPatents(args: any) { if (!isValidSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid search arguments'); } try { // SureChEMBL doesn't have a direct patent search endpoint, so we'll search chemicals and return patent context const response = await this.apiClient.get(`/chemical/name/${encodeURIComponent(args.query)}`); return { content: [ { type: 'text', text: JSON.stringify({ query: args.query, message: 'Patent search via chemical name lookup', results: response.data }, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to search patents: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:343-351 (schema)Input schema defining parameters for search_patents tool: query (required string), optional limit (1-1000), offset (>=0).inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (keywords, patent numbers, or text)' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, offset: { type: 'number', description: 'Number of results to skip (default: 0)', minimum: 0 }, }, required: ['query'], },
- src/index.ts:544-545 (registration)Registration in the CallToolRequestSchema switch dispatcher that routes calls to the handleSearchPatents handler.case 'search_patents': return await this.handleSearchPatents(args);
- src/index.ts:341-352 (registration)Tool registration in the ListToolsRequestSchema response, defining name, description, and input schema.name: 'search_patents', description: 'Search patents by text, keywords, or identifiers in SureChEMBL database', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (keywords, patent numbers, or text)' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, offset: { type: 'number', description: 'Number of results to skip (default: 0)', minimum: 0 }, }, required: ['query'], }, },
- src/index.ts:80-91 (helper)Type guard and validation function for search_patents input arguments, used in the handler.const isValidSearchArgs = ( args: any ): args is { query: string; limit?: number; offset?: number } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && args.query.length > 0 && (args.limit === undefined || (typeof args.limit === 'number' && args.limit > 0 && args.limit <= 1000)) && (args.offset === undefined || (typeof args.offset === 'number' && args.offset >= 0)) ); };