Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ Refer to this [list of clients](https://modelcontextprotocol.io/clients)
- stateless : when set to 'True' the server will not manage sessions

- **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 o use it, as agents do not always have the MCP server glboal instructions incldued in their system prompt.
- **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.

## Roadmap

Expand Down
11 changes: 11 additions & 0 deletions mcp_server/djangomcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ def __init__(self, name=None, instructions=None, stateless=False):
self.stateless = stateless
engine = import_module(settings.SESSION_ENGINE)
self.SessionStore = engine.SessionStore

# Optionally publish a tool that returns the global server instructions
if getattr(settings, "DJANGO_MCP_GET_SERVER_INSTRUCTIONS_TOOL", True):
async def _get_server_instructions():
return self._mcp_server.instructions or ""

self._tool_manager.add_tool(
fn=_get_server_instructions,
name="get_server_instructions",
description="Return MCP server instructions (if any). Always call first."
)

@property
def session_manager(self) -> StreamableHTTPSessionManager:
Expand Down