Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_query_open_targets_graphql

Execute GraphQL queries to retrieve data on targets, diseases, drugs, variants, and studies from the Open Targets platform.

Instructions

Execute GraphQL queries against the Open Targets API. Use get_open_targets_query_examples() or get_open_targets_graphql_schema() first.

Returns: dict: GraphQL response with data field containing targets, diseases, drugs, variants, studies or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
query_stringYesGraphQL query string starting with 'query' keyword
variablesNoOptional variables for the GraphQL query

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the tool 'query_open_targets_graphql'. It accepts a GraphQL query string and optional variables, then executes the query against the Open Targets API endpoint using the execute_graphql_query helper.
    @core_mcp.tool()
    def query_open_targets_graphql(
        query_string: Annotated[str, Field(description="GraphQL query string starting with 'query' keyword")],
        variables: Annotated[Optional[dict], Field(description="Optional variables for the GraphQL query")] = None,
    ) -> dict:
        """Execute GraphQL queries against the Open Targets API. Use get_open_targets_query_examples() or get_open_targets_graphql_schema() first.
    
        Returns:
            dict: GraphQL response with data field containing targets, diseases, drugs, variants, studies or error message.
        """
        base_url = "https://api.platform.opentargets.org/api/v4/graphql"
        try:
            response = execute_graphql_query(base_url, query_string, variables)
            return response
        except Exception as e:
            return {"error": f"Failed to execute GraphQL query: {e!s}"}
  • Input schema using Pydantic/Annotated types: 'query_string' is a required string, 'variables' is an optional dict.
    query_string: Annotated[str, Field(description="GraphQL query string starting with 'query' keyword")],
    variables: Annotated[Optional[dict], Field(description="Optional variables for the GraphQL query")] = None,
  • Registration of the tool via the @core_mcp.tool() decorator on the core_mcp FastMCP server instance.
    @core_mcp.tool()
    def query_open_targets_graphql(
  • Package-level re-export of the query_open_targets_graphql function from the opentargets module.
    from ._query_open_targets_graphql import query_open_targets_graphql
    
    __all__ = [
        "get_open_targets_graphql_schema",
  • Helper utility that performs the actual GraphQL query execution via the gql library. Used by the tool handler to make the API call.
    def execute_graphql_query(endpoint_url, query_string, variables=None, headers=None) -> dict:
        """Make a generic GraphQL API call.
    
        Args:
            endpoint_url (str): The GraphQL endpoint URL
            query_string (str): The GraphQL query or mutation as a string
            variables (dict, optional): Variables for the GraphQL query
            headers (dict, optional): HTTP headers to include
    
        Returns:
            dict: The response data from the GraphQL API
        """
        # Set default headers if none provided
        if headers is None:
            headers = {
                "Content-Type": "application/json",
            }
    
        # Prepare the transport
        transport = RequestsHTTPTransport(
            url=endpoint_url,
            headers=headers,
            use_json=True,
        )
    
        # Create a client
        client = Client(transport=transport)
    
        # Parse the query string
        try:
            query = gql(query_string)
        except Exception as e:
            return {"status": "error", "message": f"Failed to parse query: {e!s}"}
    
        try:
            result = client.execute(query, variable_values=variables)
            return {"status": "success", "data": result}
        except Exception as e:
            return {"status": "error", "message": str(e)}
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, placing burden on the description. It states the tool queries an API and returns a dict, implying read-only operation, but does not explicitly mention side effects, authentication, or rate limits. Acceptable but minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences plus a return note, front-loaded with purpose. No redundant or missing information for the described functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists (not shown but indicated), the description covers the essential return format. The tool is straightforward, and the description, while minimal, is complete enough for the intended use case.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and both parameters have adequate descriptions. The description does not add additional semantic information beyond what the schema provides, so baseline score applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Execute GraphQL queries against the Open Targets API' with a clear verb and resource. It also directs to helper tools, but does not explicitly differentiate from sibling tools, which are more specialized.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description advises using helper functions first, giving a prerequisite order. However, it lacks explicit guidance on when to use this tool versus sibling tools (e.g., for ad-hoc queries vs. dedicated get/search functions).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/biocontext-ai/knowledgebase-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server