1. Conduid
  2. AI
  3. Django Mcpx
MCP server · AI

Django Mcpx

Compose model context protocol servers in Django using FastMcp

Unclaimed MIT last commit a year ago ai
49Fair

Scored 5 months ago · breakdown

About Django Mcpx

Django Mcpx is an MCP server published by synw in the AI category: compose model context protocol servers in Django using FastMcp.

The repository has 3 stars and 0 forks, with the last commit a year ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.

Install

From source
git clone https://github.com/synw/django-mcpx

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Ask AI

✦

Ask AI about Django Mcpx

Powered by Claude · Grounded in docs

I know everything about Django Mcpx. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

Static checks derived from the repository 5 days ago. Heuristics on the source, not an audit.

  • ✓README presentThe repository ships documentation.
  • ✓License declaredUsable under a stated license.
  • ✓Tests presentA test suite exists in the repository.
  • !Dependencies pinnedNo lockfile. Installs can pull different code over time.
  • ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
  • !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.

README

Django MCPX

Compose MCP servers in Django using FastMcp

Installation

pip install django-mcpx

Usage

1. Configuration

First, you need to add mcpx to your INSTALLED_APPS in your Django settings file (settings.py):

INSTALLED_APPS = [
    # ... other installed apps ...
    'mcpx',
]

Next, configure the MCP settings in your settings.py. Here is an example configuration:

MCP_SERVERS = ["myapp.mcpserver.mcp_server"]

MCP_AUTH = "fefe865fe4856ferqsijjfhe-fre5qxpokjnEEZ5" # your auth token
MCP_PORT = 8397
MCP_HOST = "localhost"

2. Example Implementation

Let's create a simple MCP server using the User model from Django's authentication system.

Create a file named mcpserver.py in your app:

from typing import Any, Dict
from fastmcp import FastMCP
from pydantic import Field
from django.core.exceptions import PermissionDenied
from mcpx.auth import mcp_auth
from django.contrib.auth.models import User

name = "User Mcp Server"
mcp = FastMCP(name=name)


@mcp.tool()
async def get_user_by_username(
    username: str = Field(description="The username of the user to retrieve")
) -> Dict[str, Any]:
    """Retrieve a user by their username"""
    try:
        mcp_auth()
    except PermissionDenied as e:
        print(f"Mcp authentication error: {e}")
        return {"error": "undefined"}
    
    try:
        user = await User.objects.aget(username=username)
        return {"result": {"username": user.username, "email": user.email}}
    except User.DoesNotExist:
        return {"error": "User not found"}


@mcp.tool()
async def list_users(
    limit: int = Field(description="Maximum number of users to retrieve", default=10),
) -> Dict[str, Any]:
    """List all users"""
    try:
        mcp_auth()
    except PermissionDenied as e:
        print(f"Mcp authentication error: {e}")
        return {"error": "undefined"}
    
    results = []
    async for user in User.objects.all()[:limit]:
        results.append({"username": user.username, "email": user.email})
    return {"result": results}


mcp_server = {
    "name": name,
    "mcp": mcp,
}

3. Running the MCP Server

To run the MCP servers listed in settings use the runmcp management command provided by Django MCPX:

python manage.py runmcp --host localhost --port 8397

This will start the MCP servers on localhost at port 8397.

Test it with a client or Mcp inspector:

{
    "My Mcp server": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:8397/mcp",
        "--header",
        "Authorization: Bearer fefe865fe4856ferqsijjfhe-fre5qxpokjnEEZ5"
      ]
    }
}

Warning

Use with caution: you are responsible for what data and what powers you give to which model

README fetched from the repository 5 days ago. The original is authoritative.

Questions

About Django Mcpx

How do I install Django Mcpx?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is Django Mcpx safe to use with an AI agent?

Its trust score is 49 out of 100 (fair). It passes 4 of the 6 static security checks run so far; the failures are listed above. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Django Mcpx still maintained?

The last commit was a year ago. That's long enough that you should check whether the maintainer is responding to issues before depending on it.