skillfed

mdc

Mapped Diagnostic Context (MDC) library for python

mdc v1.2.1 118.9K downloads/30d#12,102 on PyPI9
License unclear Abandoned released

What it is and what it does

MDC is a logging enhancement library that integrates with Python's standard logging module to attach diagnostic context to log messages. It provides a context manager and decorator to inject key-value pairs into logs, which are then formatted as structured JSON output by the MDCHandler. The library automatically captures standard logging fields (message, logger name, timestamp, level) and adds MDC-specific context alongside them, making it useful for tracing requests or operations through distributed systems or complex applications.

The package has no runtime dependencies and is designed as a drop-in handler for the logging module. However, it is abandoned—last released in September 2019 with no active maintenance. The repository is archived, and the license terms are undocumented, creating uncertainty about legal use and future compatibility with newer Python versions.

Use it for:

  • Attach request IDs or user context to all log entries within a request handler using the MDC context manager.
  • Decorate functions with @with_mdc to automatically inject operation-specific fields into logs for that function's execution.
  • Emit structured JSON logs that include both standard logging metadata and custom diagnostic fields for log aggregation systems.
  • Trace execution flow across async or threaded code by maintaining context-local diagnostic information.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Adds Mapped Diagnostic Context (MDC) support to Python's standard logging library, allowing you to attach contextual fields to log messages via context managers and decorators.

No. The package is abandoned (last release September 2019, repository archived), license terms are undocumented, and it has high install friction. While it has no known vulnerabilities and no runtime dependencies, the lack of maintenance and unclear licensing make it unsuitable for new projects. Consider modern alternatives with active maintenance for structured logging with context support.

Install

mdc on PyPI

pip

pip install mdc

uv

uv add mdc

poetry

poetry add mdc

Installing mdc

Before you install

High install friction due to source-only distribution. The package is abandoned as of 2019-09-09 with no recent maintenance; the repository is archived and the last commit was 2024-02-08 with no active development.

License in practice

License status is unclear—no SPDX identifier or raw license text is available in the package metadata, making it difficult to assess legal compatibility before use.

Quickstart

pip install mdc

import logging
from mdc import MDCHandler, MDC

logging.basicConfig(level=logging.DEBUG, handlers=[MDCHandler()])
with MDC(foo='bar'):
    logging.warning('test message')

No explicit Python version requirement specified; package declares support for both Python 2 and Python 3 but Python 2 is end-of-life.

Verify before relying

  • Whether the package works reliably with modern Python 3 versions given its age and lack of maintenance.
  • Actual license terms, since license metadata is missing from the package.
  • Whether the JSON output format changes mentioned in version 1.2.0 are stable or if further breaking changes are expected.

Package facts

License not declared (unclear)
Python support not specified
Install friction high — source build required
Runtime dependencies none
Maintenance abandoned — 2,531 days since the last release
Last repo commit (repository archived)
First released
Downloads 118,883/month — #12,102 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mdc-1.2.1.tar.gz

Keywords: logging, mdc, context

Programming Language :: Python :: 2Programming Language :: Python :: 3Topic :: System :: Logging

Tags

mapped diagnostic context loggingmdc python loggingcontextual logging fieldslogging context managerstructured logging contextdiagnostic context decoratoradd context to logs
structured-loggingabandoned

More Logging packages