diff --git a/README.md b/README.md index a604557..cf40b17 100644 --- a/README.md +++ b/README.md @@ -471,6 +471,7 @@ Refer to this [list of clients](https://modelcontextprotocol.io/clients) - **DJANGO_MCP_AUTHENTICATION_CLASSES** (default to no authentication) a list of reference to Django Rest Framework authentication classes to enfors in the main MCP view. - **DJANGO_MCP_GET_SERVER_INSTRUCTIONS_TOOL** (default=True) if true a tool will be offered to obtain global instruction and tools will instruct the agent to use it, as agents do not always have the MCP server global instructions included in their system prompt. +- **DJANGO_MCP_ENDPOINT** (default="mcp") a string indicating the url endpoint used by the server. If you want it to have a trailing slash, for example, set it to "mcp/" ## Roadmap diff --git a/mcp_server/urls.py b/mcp_server/urls.py index 7eea456..32d2923 100644 --- a/mcp_server/urls.py +++ b/mcp_server/urls.py @@ -24,8 +24,10 @@ # Register MCP Server View and bypass default DRF default permission / authentication classes +base_url = getattr(settings, "DJANGO_MCP_ENDPOINT", "mcp") + urlpatterns = [ - path("mcp", MCPServerStreamableHttpView.as_view( + path(base_url, MCPServerStreamableHttpView.as_view( permission_classes=[IsAuthenticated] if getattr(settings, 'DJANGO_MCP_AUTHENTICATION_CLASSES', None) else [], authentication_classes=[import_string(cls) for cls in getattr(settings, 'DJANGO_MCP_AUTHENTICATION_CLASSES', [])] ), name="mcp_server_streamable_http_endpoint"),