Create a secondary MCP endpoint
mainYou can host multiple independent MCP servers by creating new DjangoMCP instances and mounting them to different URL paths.
Security Warning: When mounting a secondary MCP server via MCPServerStreamableHttpView.as_view(mcp_server=second_mcp), the DJANGO_MCP_AUTHENTICATION_CLASSES setting is ignored. You MUST manually provide permission_classes and authentication_classes to the view to secure the endpoint.
# In mcp.py
from mcp_server.djangomcp import DjangoMCP
second_mcp = DjangoMCP(name="altserver")
@second_mcp.tool()
async def my_tool():
...
# In urls.py
from rest_framework.permissions import IsAuthenticated
from rest_framework.authentication import TokenAuthentication
from mcp_server.djangomcp import MCPServerStreamableHttpView
from yourapp.mcp import second_mcp
urlpatterns = [
path(
"altmcp",
MCPServerStreamableHttpView.as_view(
mcp_server=second_mcp,
permission_classes=[IsAuthenticated],
authentication_classes=[TokenAuthentication]
)
),
]