Skip to main content

django-silk-mcp

CI codecov PyPI - Python Version PyPI - Django Versions

An MCP server that exposes django-silk profiling data as tools for any MCP-compatible AI coding assistant. Enables query-level investigation and optimization directly from your conversation — N+1 detection, EXPLAIN ANALYZE, over-fetch analysis, and Python profiling without leaving your editor.

Installation

pip install django-silk-mcp
# or
uv add django-silk-mcp

Configuration

1. Add to INSTALLED_APPS

INSTALLED_APPS = [
    ...
    "silk",
    "django_silk_mcp",
]

2. Configure your MCP client

Expose the MCP server as a URL inside your Django app. Works on both WSGI and ASGI with no extra infrastructure.

Add to your root urls.py:

urlpatterns = [
    ...
    path("silk/", include("silk.urls", namespace="silk")),
    path("silk/mcp", include("django_silk_mcp.urls")),
]

This serves the MCP endpoint at /silk/mcp. The MCP server runs as part of your Django app — no separate process needed, it shares the same port as your dev server. Then configure your MCP client:

Claude Code:

claude mcp add silk-mcp --transport http http://localhost:8000/silk/mcp

Cursor: Go to Settings → Toos & MCPs → New MCP Server and add a new server with the following configuration:

{
  "mcpServers": {
    "silk-mcp": {
      "url": "http://localhost:8000/silk/mcp"
    }
  }
}

The same URL works with any MCP-compatible AI tool.

Security

Warning: The MCP endpoint uses AllowAny with no authentication by default, because MCP clients (Claude Code, Cursor, etc.) connect over plain HTTP and do not send credentials. This is intentional for local development but must not be exposed in production.

Silk profiling data includes raw SQL query strings, which can contain business data at runtime (user IDs, emails, search terms, etc.). Anyone who can reach the Django host can read this data through the MCP endpoint.

Recommended: Only mount in DEBUG mode:

# urls.py
from django.conf import settings

if settings.DEBUG:
   urlpatterns = [
     path("silk/", include("silk.urls", namespace="silk")),
     path("silk/mcp", include("django_silk_mcp.urls")),
   ]

Tools

Tool Purpose
get_most_expensive_endpoints Rank all endpoints by average DB time
get_request_time_breakdown DB% vs Python% — confirm where time is spent
get_duplicate_queries Detect N+1 patterns
get_query_sources Which code lines triggered each query
get_overfetched_fields SQL columns vs serializer fields — .only() candidates
explain_slow_queries EXPLAIN (ANALYZE, BUFFERS) on slow SELECTs
get_request_queries All SQL for a specific request
get_slow_queries Slowest individual queries across all requests
get_slow_requests Slowest HTTP requests
compare_requests Before/after comparison with burst deduplication
get_python_profiles @silk_profile decorated block timings
get_cprofile_hotspots cProfile hotspots — no decorators needed

Usage

# Hit an endpoint first so Silk has data
curl http://localhost:8000/api/your-endpoint/

# Then ask your AI assistant
# "What are the slowest endpoints?"
# "Find N+1 queries in /api/your-endpoint/"
# "Run EXPLAIN on the slow queries for /api/your-endpoint/"

Metadata

Release files for django-silk-mcp 0.1.7

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

Source distribution (sdist)

Source distribution for django-silk-mcp 0.1.7
File Size Uploaded Provenance
django_silk_mcp-0.1.7.tar.gz 20.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-silk-mcp 0.1.7
File Interpreter ABI Platform
django_silk_mcp-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 47.2 kB

Release files / django_silk_mcp-0.1.7.tar.gz

Download URL django_silk_mcp-0.1.7.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5290d4496a8662301b4648a5991642a36832bbba9ef2d95511cff8448d4405a9
BLAKE2b-256 checksum
How to use checksums
8e88476c60cd5345bba56ff2770fbadc4956bbb24083a916cd46e2289a7a2fed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.

Transparency log

Release files / django_silk_mcp-0.1.7-py3-none-any.whl

Download URL django_silk_mcp-0.1.7-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
838520c5d3182013e88d11e8daa84e5c6a67a92ed430adad04cd21e0395cec16
BLAKE2b-256 checksum
How to use checksums
b9ee8211a6685ce5cd2864ba5255253a28717fd09360f407cea3db75981d2a29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.

Transparency log

Security for django-silk-mcp 0.1.7

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_silk_mcp-0.1.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 27, 2026.

Transparency log

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.

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