Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_string_similarity_scores

Calculate protein similarity scores using STRING database Smith-Waterman bit scores to assess homology between protein pairs for biomedical research.

Instructions

Retrieve protein homology similarity scores from STRING database based on Smith-Waterman bit scores. Only scores above 50 reported.

Returns: list or dict: Similarity scores array with stringId_A, stringId_B, bitscore or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
protein_symbolYesFirst protein symbol (e.g., 'TP53')
protein_symbol_comparisonYesSecond protein symbol (e.g., 'MKI67')
speciesNoSpecies taxonomy ID (e.g., '9606' for human)

Implementation Reference

  • The handler function for the tool (likely 'bc_get_string_similarity_scores' under 'BC' MCP server). Includes schema via Pydantic Annotated fields, registration via @core_mcp.tool(), and core logic: resolves symbols to STRING IDs using get_string_id tool, queries STRING homology API for bitscores.
    @core_mcp.tool()
    def get_string_similarity_scores(
        protein_symbol: Annotated[str, Field(description="First protein symbol (e.g., 'TP53')")],
        protein_symbol_comparison: Annotated[str, Field(description="Second protein symbol (e.g., 'MKI67')")],
        species: Annotated[str, Field(description="Species taxonomy ID (e.g., '9606' for human)")] = "",
    ) -> Union[List[Dict[str, Any]], dict]:
        """Retrieve protein homology similarity scores from STRING database based on Smith-Waterman bit scores. Only scores above 50 reported.
    
        Returns:
            list or dict: Similarity scores array with stringId_A, stringId_B, bitscore or error message.
        """
        # Resolve both protein symbols to STRING IDs
        try:
            string_id1 = get_string_id.fn(protein_symbol=protein_symbol, species=species)
            string_id2 = get_string_id.fn(protein_symbol=protein_symbol_comparison, species=species)
    
            if not all(isinstance(string_id, str) for string_id in [string_id1, string_id2]):
                return {"error": "Could not extract STRING IDs"}
    
            identifiers = f"{string_id1}%0d{string_id2}"
    
            url = f"https://string-db.org/api/json/homology?identifiers={identifiers}"
            if species:
                url += f"&species={species}"
    
            response = requests.get(url)
            response.raise_for_status()
    
            return response.json()
        except requests.exceptions.RequestException as e:
            return {"error": f"Failed to fetch similarity scores: {e!s}"}
        except Exception as e:
            return {"error": f"An error occurred: {e!s}"}
  • Import statement that loads the stringdb module, executing the @tool decorators to register get_string_similarity_scores to core_mcp.
    from .stringdb import *
  • Definition of the core_mcp FastMCP server instance (named 'BC') where all tools including get_string_similarity_scores are registered.
    core_mcp = FastMCP(  # type: ignore
        "BC",
        instructions="Provides access to biomedical knowledge bases.",
    )
  • Module __init__.py that re-exports the get_string_similarity_scores function (and others) for convenient import.
    from ._get_string_id import get_string_id
    from ._get_string_interactions import get_string_interactions
    from ._get_string_network_image import get_string_network_image
    from ._get_string_similarity_scores import get_string_similarity_scores
    
    __all__ = [
        "get_string_id",
        "get_string_interactions",
        "get_string_network_image",
        "get_string_similarity_scores",
    ]

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