Wazobia MCP Library
A reusable library for implementing Model Context Protocol (MCP) servers in Python services with project-based authentication.
Overview
This library provides a standardized way to add MCP functionality to Python services, with common tools like health checks, authentication, and utility functions that can be extended with service-specific tools. It includes specialized MCP project authentication for secure service-to-service communication.
Features
- Standardized MCP server implementation
- Built-in health checks (system, database, Redis, Kafka)
- MCP-specific project authentication with JWT verification
- FastAPI integration with automatic auth dependency injection
- Migration utilities for legacy systems
- Error handling and logging setup
- Redis caching for JWKS and token validation
Usage
Basic MCP Server with Project Authentication
from mcp_server_lib import mcp_project_auth
from fastapi import APIRouter, Depends
# Create router for MCP endpoints
router = APIRouter(prefix="/mcp", tags=["mcp"])
@router.get("/metrics")
async def get_metrics(
authenticated_project = Depends(mcp_project_auth),
page: int = 1,
per_page: int = 50
):
"""Get analytics metrics for authenticated project"""
project_uuid = authenticated_project.project_uuid
# Your logic here using the authenticated project
return {"project": project_uuid, "metrics": "..."}
@router.get("/health")
async def check_health():
"""Health check endpoint (no auth required)"""
return {"status": "healthy"}
Advanced Usage with MCP Server Class
from mcp_server_lib.core.mcp_service import MCPServer
from mcp_server_lib.models.config import MCPConfig
from mcp_server_lib.auth import JWTAuthenticator, mcp_project_auth
from mcp_server_lib.health.base_checks import SystemHealthCheck
# Create configuration
config = MCPConfig(
service_name="My Service",
service_description="A service with MCP support",
jwt_secret_key="your-secret-key"
)
# Create MCP server
mcp_server = MCPServer(config)
# Setup authentication
authenticator = JWTAuthenticator(secret_key=config.jwt_secret_key)
mcp_server.set_authenticator(authenticator)
# Register health checks
mcp_server.register_health_check(SystemHealthCheck())
# Get the FastAPI app to run
app = mcp_server.get_app()
Installation
pip install wazobia-mcp-lib
Environment Variables
For MCP project authentication, configure these environment variables:
MERCURY_BASE_URL=https://your-mercury-instance.com
SIGNATURE_SHARED_SECRET=your-shared-secret
SERVICE_ID=your-service-id
REDIS_URL=redis://localhost:6379
License
MIT
Metadata
Release files for wazobia-mcp-lib 1.0.2
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 | |
|---|---|---|---|---|
| wazobia_mcp_lib-1.0.2.tar.gz | 20.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wazobia_mcp_lib-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.0 kB
Release files / wazobia_mcp_lib-1.0.2.tar.gz
| Download URL | wazobia_mcp_lib-1.0.2.tar.gz |
|---|---|
| Size | 20.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3abd1a6cf1414daba179807383a5baa2aca94c4c48300fd351eea7bc86cd38a0
|
|
BLAKE2b-256 checksum How to use checksums |
d574fa320d0f43f940dad17cbae5a8824c4e449847d8a0ccbe306a0b1a9eb5af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / wazobia_mcp_lib-1.0.2-py3-none-any.whl
| Download URL | wazobia_mcp_lib-1.0.2-py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
949e45bc704639459f823f518d1bf2f79703b69107eace2804612b64c270f50f
|
|
BLAKE2b-256 checksum How to use checksums |
09e58cd634437228bb31f649756466b6617a8dda95ecd2cc851d0176b989a4a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for wazobia-mcp-lib 1.0.2
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.