Skip to main content

MCP server exposing django-silk profiling data as AI assistant tools

Project description

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/"

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

django_silk_mcp-0.1.6.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

django_silk_mcp-0.1.6-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file django_silk_mcp-0.1.6.tar.gz.

File metadata

  • Download URL: django_silk_mcp-0.1.6.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_silk_mcp-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c388a4f063f0d13bb89afe36c4aaf5f90e76acb668622ad150be8b0b611bca44
MD5 78d0b7729abaf55fcad7c07d12fbec81
BLAKE2b-256 26cf7e74b19f0798c7bbce9c0f652df59ae5ffa025485ea4f6c1b78c459d35ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_silk_mcp-0.1.6.tar.gz:

Publisher: publish.yml on vintasoftware/django-silk-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_silk_mcp-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: django_silk_mcp-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_silk_mcp-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e4e44927613d3ad8ec6d477f3bbc3f48291472fbad2aa80f8710d8ce6148a055
MD5 cd57d71d13f7533601ad82cfc869528c
BLAKE2b-256 f72b2915e00252bd8268e208caa9d98001a63f42df20617d00c0679c3a623895

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_silk_mcp-0.1.6-py3-none-any.whl:

Publisher: publish.yml on vintasoftware/django-silk-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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