Skip to main content

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

Release files for modeltoolbox-core 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modeltoolbox-core 0.2.2
File Size Uploaded
modeltoolbox_core-0.2.2.tar.gz 21.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modeltoolbox-core 0.2.2
File Interpreter ABI Platform
modeltoolbox_core-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 48.2 kB

Release files / modeltoolbox_core-0.2.2.tar.gz

Download URL modeltoolbox_core-0.2.2.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
02176d8d2d5a143e09a5db6b98c9c3053f00114df6927ab86dd7dc2ddc1b808a
BLAKE2b-256 checksum
How to use checksums
877a8cc13466d2ef3a5679b7c7f37cc45d6f31a59a1918a781e878ac5a28dda9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / modeltoolbox_core-0.2.2-py3-none-any.whl

Download URL modeltoolbox_core-0.2.2-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7ff649fbb4e14435478b87ea26a5271344aff8b6d8b924386034d4497dcab99
BLAKE2b-256 checksum
How to use checksums
88ff6a99993a15b1d8508a06086dd078cd4f8a84cabe1d2d0fafcde3fa3ed9a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release history Release notifications | RSS feed

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page