bc_get_string_interactions
Retrieve protein-protein interactions for a specified protein with customizable score thresholds to analyze molecular relationships in biological research.
Instructions
Retrieve protein-protein interactions for a given protein with scores above threshold. Always provide species parameter.
Returns: list or dict: Protein interactions array with stringId_A, stringId_B, preferredName_A/B, score, evidence channels or error message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| protein_symbol | Yes | Protein name to search for (e.g., 'TP53') | |
| species | Yes | Species taxonomy ID (e.g., '10090' for mouse) | |
| min_score | No | Minimum combined score threshold (0-1000) |
Implementation Reference
- The main handler function for the 'bc_get_string_interactions' tool (registered under 'BC' namespace as 'bc_get_string_interactions'). Resolves protein STRING ID using helper and queries STRING API for interactions.@core_mcp.tool() def get_string_interactions( protein_symbol: Annotated[str, Field(description="Protein name to search for (e.g., 'TP53')")], species: Annotated[str, Field(description="Species taxonomy ID (e.g., '10090' for mouse)")], min_score: Annotated[int, Field(description="Minimum combined score threshold (0-1000)", ge=0, le=1000)] = 700, ) -> Union[List[Dict[str, Any]], dict]: """Retrieve protein-protein interactions for a given protein with scores above threshold. Always provide species parameter. Returns: list or dict: Protein interactions array with stringId_A, stringId_B, preferredName_A/B, score, evidence channels or error message. """ # First resolve the protein name to a STRING ID try: string_id = get_string_id.fn(protein_symbol=protein_symbol, species=species) if not string_id or not isinstance(string_id, str): return {"error": f"No STRING ID found for protein: {protein_symbol}"} url = f"https://string-db.org/api/json/interaction_partners?identifiers={string_id}&species={species}&required_score={min_score}&format=json" response = requests.get(url) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: return {"error": f"Failed to fetch interactions: {e!s}"} except Exception as e: return {"error": f"An error occurred: {e!s}"}
- Input schema defined via Pydantic Annotated types and Field descriptions for protein_symbol (str), species (str), min_score (int, default 700). Output is list of interaction dicts or error dict.def get_string_interactions( protein_symbol: Annotated[str, Field(description="Protein name to search for (e.g., 'TP53')")], species: Annotated[str, Field(description="Species taxonomy ID (e.g., '10090' for mouse)")], min_score: Annotated[int, Field(description="Minimum combined score threshold (0-1000)", ge=0, le=1000)] = 700, ) -> Union[List[Dict[str, Any]], dict]:
- src/biocontext_kb/app.py:35-39 (registration)Imports the core_mcp server (containing this tool) into the main MCP app with prefix 'bc' (from slugify('BC')), effectively registering the tool as 'bc_get_string_interactions'.for mcp in [core_mcp, *(await get_openapi_mcps())]: await mcp_app.import_server( mcp, slugify(mcp.name), )
- Imports and uses get_string_id helper function to resolve protein_symbol to STRING ID before querying interactions.from biocontext_kb.core.stringdb._get_string_id import get_string_id
- Calls the get_string_id helper to obtain the STRING ID for the given protein and species.string_id = get_string_id.fn(protein_symbol=protein_symbol, species=species)