BioContext
Python package for use with BioContext MCP servers to enable LLM tool use.
- Github repository: https://github.com/biocypher/biocontext/
- Documentation: https://biocypher.github.io/biocontext/
Installation
pip install biocontext
Development
Install the project using make install. Test code quality using make check.
Run tests using make test. Bump version using ./bump.sh <patch|minor|major>.
Build and deploy docs locally using uv run mkdocs serve.
Basic Functionality
Client
The BioContext client provides an async connection to MCP (Model Context Protocol) servers. It allows you to discover and use tools and resources provided by MCP servers:
from biocontext import MCPConnection
# Initialize connection
async with MCPConnection("my-mcp-server", base_url="http://example.com") as connection:
# Get available tools
tools = await connection.get_tools()
# Get available resources
resources = await connection.get_resources()
# Call a specific tool
result = await connection.call_tool("tool_name", {"param": "value"})
Server
BioContext provides a flexible server implementation for creating and managing MCP (Model Context Protocol) servers. The server supports both core MCP functionality and integration with OpenAPI specifications:
from biocontext import MCPServer
from pathlib import Path
# Initialize server with basic configuration
server = MCPServer(
name="my-mcp-server",
version="1.0.0",
author="Your Name",
config_path=Path("config.yaml")
)
# Setup server with optional core MCP
mcp_app = await server.setup()
# The server now provides:
# - Tools from OpenAPI specifications
# - Resources and resource templates
# - Automatic validation of tools and resources
# - Logging of available tools and resources
The server supports configuration through a YAML file that specifies OpenAPI schemas to integrate:
schemas:
- name: "my-api"
url: "https://example.com/openapi.json"
type: "json" # or "yaml"
base: "https://api.example.com" # optional base URL
Key features of the server implementation:
- Automatic downloading and parsing of OpenAPI specifications
- Support for both JSON and YAML OpenAPI formats
- Validation of tools, resources, and templates
- Custom route mapping for tool endpoints
- Comprehensive logging of server setup and available tools
- Error handling for configuration and schema issues
For more detailed information about server configuration and usage, please refer to the Server Documentation.
Registry
The registry helps you discover and use biological tools and knowledge resources. It maintains metadata about MCP servers, knowledge graphs, and tools, making it easy to find what you need:
from biocontext import Registry
# Initialize registry
registry = Registry()
# Find tools for a specific task
protein_tools = registry.search_resources(
type="tool",
keywords=["protein", "sequence analysis"]
)
# Find knowledge graphs about specific topics
disease_kgs = registry.search_resources(
type="knowledge_graph",
keywords=["disease", "pathway"]
)
# Find MCP servers that provide specific capabilities
servers = registry.search_resources(
type="mcp_server",
capabilities=["protein analysis", "sequence alignment"]
)
# Get detailed information about a specific resource
tool_info = registry.get_resource("protein-analyzer-v1")
print(f"Tool: {tool_info.name}")
print(f"Description: {tool_info.description}")
print(f"Input types: {tool_info.inputData}")
print(f"Output types: {tool_info.outputData}")
print(f"Available at: {tool_info.url}")
The registry uses schema.org and BioSchemas standards to provide rich metadata about each resource, including:
- Detailed descriptions and capabilities
- Input/output data types
- License information
- Version history
- Related tools and knowledge graphs
- Query interfaces and endpoints
Documentation
Please visit our documentation.
License
MIT License - see LICENSE file for details
Metadata
Release files for biocontext 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| biocontext-0.1.3.tar.gz | 84.5 kB | Without provenance | Details for biocontext-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| biocontext-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for biocontext-0.1.3-py3-none-any.whl |
Total release size: 100.0 kB
Release files / biocontext-0.1.3.tar.gz
| Download URL | biocontext-0.1.3.tar.gz |
|---|---|
| Size | 84.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ece140ba6755d7b2be6f1fefb5cd1adc4523bd48ef66c0cb20e526aca6d57a9
|
|
BLAKE2b-256 checksum How to use checksums |
048372d555bcfe763041e2f8a937b381c2d4733a3f3b59254cb68093164b6ffa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.14
|
Release files / biocontext-0.1.3-py3-none-any.whl
| Download URL | biocontext-0.1.3-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cba8bbed51c4ee72bffe1e68ef9612c92cd75c86affbaefb0d1e1bdcb47f5a97
|
|
BLAKE2b-256 checksum How to use checksums |
07039cba995cf9edfc7dd5dbef1d5423a789bba96a6c8f527e138ac7df3c91d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.14
|
Security for biocontext 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.