django-mcp-server  by gts360

Django extension for AI agent interaction via Model Context Protocol

Created 8 months ago
251 stars

Top 99.8% on SourcePulse

GitHubView on GitHub
Project Summary

Django MCP Server provides a Django extension to seamlessly expose application models and logic as tools for AI agents and MCP clients. It targets Django developers seeking to integrate AI capabilities, offering a simple way to make Django data and functions accessible via the Model Context Protocol (MCP) over both WSGI and ASGI. This enables robust interaction with AI platforms like Claude AI and Google ADK.

How It Works

The project implements the Model Context Protocol (MCP) for Django, allowing developers to define tools by subclassing ModelQueryToolset for model access or MCPToolset for custom methods. Django Rest Framework APIs can be exposed as MCP tools with single annotations. The server runs within a Django application, acting as an MCP endpoint accessible via HTTP, supporting both WSGI and ASGI without requiring infrastructure changes.

Quick Start & Requirements

  • Install: pip install django-mcp-server
  • Configure: Add 'mcp_server' to INSTALLED_APPS and include 'mcp_server.urls' in your project's urls.py.
  • Define Tools: Create Python classes inheriting from ModelQueryToolset or MCPToolset in your Django app's mcp.py file.
  • Prerequisites: A Django project.
  • Dependencies: Django Rest Framework is recommended for API integration. django-oauth-toolkit is needed for OAuth2 integration with services like Claude AI.
  • Verification: Use the python manage.py mcp_inspect command.
  • Docs: GitHub Repository

Highlighted Details

  • Exposes Django models and logic as MCP tools with minimal code.
  • Converts Django Rest Framework APIs to MCP tools via annotations.
  • Operates on both WSGI and ASGI without infrastructure changes.
  • Validated for remote integration with Claude AI.
  • Supports output serialization using Django Rest Framework serializers.

Maintenance & Community

Maintained by Smart GTS software engineering. The project accepts issues on GitHub for bugs and feature requests. The roadmap indicates future development for STDIO transport, stateful streamable HTTP, and SSE endpoint integration.

Licensing & Compatibility

  • License: MIT License.
  • Compatibility: Permissive MIT license allows for commercial use and integration into closed-source projects. Requires Django and potentially django-oauth-toolkit for advanced AI integrations.

Limitations & Caveats

Production deployments require explicit authorization configuration. Claude AI integration necessitates OAuth2 setup, including potential third-party add-ons for Dynamic Client Registration. Claude Desktop's local MCP server support relies on STDIO transport, requiring specific configuration. The official Google ADK may require a fork for StreamableHTTP transport compatibility.

Health Check
Last Commit

3 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
13 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.