bc_get_open_targets_query_examples
Access example GraphQL queries for the Open Targets API to retrieve data on targets, diseases, drugs, and their associations. Simplifies data retrieval for biomedical research.
Instructions
Get example GraphQL queries for the Open Targets API.
Returns a dictionary of named example queries that can be used with the query_open_targets_graphql tool. These examples demonstrate common use cases for retrieving data about targets, diseases, drugs, and their associations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The core handler function for the 'get_open_targets_query_examples' tool (registered as 'bc_get_open_targets_query_examples' via server prefix), decorated with @core_mcp.tool(). It returns a predefined dictionary of example GraphQL queries for Open Targets API.@core_mcp.tool() def get_open_targets_query_examples() -> dict: """Retrieve example GraphQL queries for the Open Targets API. Examples demonstrate common use cases. Returns: dict: Example queries mapped by category (informationForTarget, drugsForTarget, associatedDiseases, etc.) with GraphQL query strings. """ return EXAMPLE_QUERIES
- src/biocontext_kb/core/__init__.py:14-14 (registration)Import statement in core/__init__.py that loads the opentargets module, triggering registration of the tool on the core_mcp FastMCP instance via the decorator.from .opentargets import *
- src/biocontext_kb/app.py:35-39 (registration)Import of the 'BC' (core_mcp) server into the main 'BioContextAI' MCP app using slugify('BC')='bc', which prefixes all tools from core_mcp with 'bc_', making the tool available as 'bc_get_open_targets_query_examples'.for mcp in [core_mcp, *(await get_openapi_mcps())]: await mcp_app.import_server( mcp, slugify(mcp.name), )
- Predefined dictionary of example GraphQL queries for various Open Targets use cases (target info, diseases, drugs, etc.), directly returned by the handler.EXAMPLE_QUERIES = { "informationForTargetByEnsemblId": """ query informationForTargetByEnsemblId { target(ensemblId: "ENSG00000169083") { id approvedSymbol tractability { modality label value } safetyLiabilities { event eventId biosamples { cellFormat cellLabel tissueLabel tissueId } effects { dosing direction } studies { name type description } datasource literature } } } """, "drugsForTargetByEnsemblId": """ query geneAssociatedDrugs { target(ensemblId: "ENSG00000159640") { id pharmacogenomics { isDirectTarget target { approvedName } drugs { drug { id name mechanismsOfAction { rows { targets { approvedName } } uniqueTargetTypes uniqueActionTypes } isApproved } } } } } """, "associatedDiseasesForTargetByEnsemblId": """ query associatedDiseasesForTargetByEnsemblId { target(ensemblId: "ENSG00000127318") { id approvedSymbol associatedDiseases { count rows { disease { id name } datasourceScores { id score } } } } } """, "informationForDiseaseByEFOId": """ query informationForDiseaseByEFOId { disease(efoId: "EFO_0000222") { id name phenotypes { rows { phenotypeHPO { id name description namespace } phenotypeEFO { id name } evidence { aspect bioCuration diseaseFromSourceId diseaseFromSource evidenceType frequency frequencyHPO { name id } qualifierNot onset { name id } modifiers { name id } references sex resource } } } } } """, "knownDrugsForDiseaseByEFOId": """ query knownDrugsForDiseaseByEFOId { disease(efoId: "EFO_0004705") { id name knownDrugs { count uniqueTargets uniqueDrugs rows { drugId drugType prefName targetId targetClass approvedSymbol mechanismOfAction phase status diseaseId drug { id name maximumClinicalTrialPhase description synonyms } target { id approvedSymbol approvedName } } } } } """, "associatedTargetsForDiseaseByEFOId": """ query associatedTargets { disease(efoId: "EFO_0000349") { id name associatedTargets { count rows { target { id approvedSymbol } score } } } } """, "informationForDrugByChemblId": """ query informationForDrugByChemblId { drug(chemblId: "CHEMBL25") { name id yearOfFirstApproval tradeNames isApproved hasBeenWithdrawn blackBoxWarning drugType approvedIndications mechanismsOfAction { uniqueTargetTypes uniqueActionTypes } linkedTargets { rows { id approvedName pathways { pathwayId pathway topLevelTerm } } } } } """, }
- src/biocontext_kb/core/opentargets/__init__.py:2-2 (registration)Import of the tool handler into opentargets __init__.py, part of the import chain leading to registration.from ._get_open_targets_query_examples import get_open_targets_query_examples