Skip to main content

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: INFO level 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


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.1.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modeltoolbox_core-0.2.1-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file modeltoolbox_core-0.2.1.tar.gz.

File metadata

  • Download URL: modeltoolbox_core-0.2.1.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for modeltoolbox_core-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8db092dea1885307a17767e0928e00a32ea898e781d8c00bc7eb769830a6bf8d
MD5 369619e2c7604338adf069e328eef00e
BLAKE2b-256 be1636926b26b4b0b32d6670d192c2fd64c89ee58a3cf2f4920ccddb0cc6d9cf

See more details on using hashes here.

File details

Details for the file modeltoolbox_core-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for modeltoolbox_core-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 179d8bc6a0ed34ec287b3a813bc472feb18c87a1f958d9439ddf55bed8ca50b4
MD5 3ebe42af4a29315bf61cda644308463c
BLAKE2b-256 048d5d7410041f6e716466ba7a09a75d272ad04d2ac68ba52177ac59daa57c55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page