Core utilities for ModelToolbox: logging, telemetry, configuration, and plugin system.
Project description
ModelCore
Core utilities for ModelToolbox: logging, telemetry, configuration, and plugin system.
Features
- Unified Logging: Zero-configuration structured logging with console and file outputs
- Performance Monitoring: Decorators for tracking command execution time and errors
- Health Checks: Dependency checking and version information reporting
- MCP Server Support: Specialized logging and monitoring for MCP servers
- Plugin System: Dynamic plugin loading via entry points
Installation
pip install modeltoolbox-core
For development:
pip install -e "ModelCore[dev]"
Usage
Logging
from modeltoolbox_core.logging import get_logger
logger = get_logger(__name__)
logger.info("Processing started")
logger.error("An error occurred", exc_info=True)
Logs are written to:
- Console:
INFOlevel and above - File:
~/.modeltoolbox/logs/modeltoolbox-YYYY-MM-DD.log(all levels, JSON format) - Errors:
~/.modeltoolbox/logs/errors-YYYY-MM-DD.log(ERROR level only)
Performance Tracking
from modeltoolbox_core.telemetry import track_performance
@track_performance
def expensive_operation():
# Your code here
pass
Health Checks
from modeltoolbox_core.health import health_check
status = health_check()
print(status)
# {
# "status": "healthy",
# "version_info": {"python": "3.11.0", ...},
# "dependencies": {"git": {"available": True, "version": "..."}, ...}
# }
MCP Server Integration
from mcp.server.fastmcp import FastMCP
from modeltoolbox_core.mcp_logging import setup_mcp_logger, log_tool_call
logger = setup_mcp_logger("my_server")
mcp = FastMCP("my_server")
@mcp.tool()
@log_tool_call
def my_tool(param: str) -> dict:
"""My tool with automatic logging."""
return {"result": param}
Testing
pytest ModelCore/tests/
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
modeltoolbox_core-0.2.0.tar.gz
(16.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modeltoolbox_core-0.2.0.tar.gz.
File metadata
- Download URL: modeltoolbox_core-0.2.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
045483ae3eca4b6e88aace7c22fb2b9b4d4ca08282ff07e24dc3b4b2a1cc92eb
|
|
| MD5 |
c3924fb7bdb05100c9b4f6cfa66bb768
|
|
| BLAKE2b-256 |
b99d1fbebbcae4506c63a808a69e7163212f928e815be82b2506bd3ecf592839
|
File details
Details for the file modeltoolbox_core-0.2.0-py3-none-any.whl.
File metadata
- Download URL: modeltoolbox_core-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
585670d9e9dcdea8cabaa5a20e9be2f488b6152617126c8ebe680d09275de927
|
|
| MD5 |
182a10d75e4954b0b4ac8d7667360abb
|
|
| BLAKE2b-256 |
0934c1d8f36d8382153960b861491103b38ab3ac726490b12a3c6274d66d2f94
|