search_papers
Search a scientific database for papers using keywords, with options to filter by publication date and control result quantity.
Instructions
Search BGPT's database of scientific papers by keyword.
Args: query: Search terms (e.g. "CRISPR gene editing efficiency") Short, concise queries are best. English language only. num_results: Number of results to return (1-100, default 16). First 50 results are free, then billed at $0.01/result for paid users. days_back: Only return papers published within the last N days. api_key: Optional: Your Stripe subscription ID for paid access. Get one at https://bgpt.pro/mcp
Returns: Papers with title, DOI, Raw Data, methods, results, quality scores, and 25+ metadata fields.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| num_results | No | ||
| days_back | No | ||
| api_key | No |
Implementation Reference
- examples/python_example.py:16-54 (handler)The `search_papers` function acts as a wrapper/handler that constructs an MCP JSON-RPC `tools/call` request to the BGPT SSE endpoint to execute the search.
def search_papers(query: str, num_results: int = 5, days_back: int = None, api_key: str = None): """ Search scientific papers via the BGPT MCP API. Args: query: Search terms (e.g. "CRISPR gene editing efficiency") num_results: Number of results to return (1-100, default 5) days_back: Only return papers published within the last N days api_key: Stripe subscription ID for paid access (optional for free tier) Returns: List of paper results with methods, results, quality scores, etc. """ params = {"query": query, "num_results": num_results} if days_back is not None: params["days_back"] = days_back if api_key is not None: params["api_key"] = api_key payload = json.dumps({ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "search_papers", "arguments": params } }).encode("utf-8") req = urllib.request.Request( BGPT_SSE_ENDPOINT.replace("/sse", "/message"), data=payload, method="POST" ) req.add_header("Content-Type", "application/json") ctx = ssl.create_default_context() with urllib.request.urlopen(req, context=ctx, timeout=30) as resp: return json.loads(resp.read().decode("utf-8"))