Skip to content

Commit 54394d1

Browse files
update readme
1 parent acd5fd1 commit 54394d1

File tree

1 file changed

+63
-26
lines changed

1 file changed

+63
-26
lines changed

README.md

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,83 +76,120 @@ Run the MCP server directly from your Django project directory:
7676
```bash
7777
python -m mcp_django
7878

79-
# With explicit settings module
80-
python -m mcp_django --settings myproject.settings
81-
82-
# With debug logging
83-
python -m mcp_django --debug
79+
# Or with uv
80+
uv run -m mcp_django
8481
```
8582

86-
Or using uv:
83+
The server automatically detects `DJANGO_SETTINGS_MODULE` from your environment. You can override it with `--settings` or add to your Python path with `--pythonpath`:
8784

8885
```bash
89-
uv run -m mcp_django
86+
python -m mcp_django --settings myproject.settings --debug
9087
```
9188

92-
The server automatically detects `DJANGO_SETTINGS_MODULE` from your environment. You can override it with `--settings` or add to your Python path with `--pythonpath`.
93-
94-
There's also a Django management command if you prefer, but that requires adding mcp-django to `INSTALLED_APPS`:
89+
**Using the management command** (requires adding `mcp_django` to `INSTALLED_APPS`):
9590

9691
```bash
9792
python manage.py mcp
9893
```
9994

100-
### Transport
95+
### Docker
96+
97+
If you're using Docker and Docker Compose, you can run mcp-django as a separate compose service using HTTP transport. This makes it easier to connect your MCP client (running on your host) to the Django project (running in a container):
98+
99+
```yaml
100+
# compose.yml
101+
services:
102+
app:
103+
# your existing Django app service
104+
105+
mcp:
106+
build: .
107+
command: python -m mcp_django --transport http --host 0.0.0.0 --port 8000
108+
environment:
109+
DJANGO_SETTINGS_MODULE: myproject.settings
110+
ports:
111+
- "8001:8000"
112+
```
113+
114+
Then configure your MCP client to connect to `http://localhost:8001/mcp` (see [Client Configuration](#client-configuration) below).
115+
116+
### Transport Options
101117

102118
The server supports multiple transport protocols:
103119

104120
```bash
105-
# Default: STDIO
121+
# STDIO (default, for local development)
106122
python -m mcp_django
107123
108-
# HTTP
124+
# HTTP (for Docker or remote access)
109125
python -m mcp_django --transport http --host 127.0.0.1 --port 8000
110126
111-
# SSE
127+
# SSE (for Docker or remote access)
112128
python -m mcp_django --transport sse --host 127.0.0.1 --port 8000
113129
```
114130

115131
### Client Configuration
116132

117-
Configure your MCP client using one of the examples below. The command is the same for all clients, just expressed in annoyingly different JSON soup.
133+
Configure your MCP client to connect to the server.
118134

119135
Don't see your client? [Submit a PR](CONTRIBUTING.md) with setup instructions.
120136

121-
### Claude Code
137+
#### Opencode
138+
139+
For **local development**, use `type: local` with the command:
122140

123141
```json
124142
{
125-
"mcpServers": {
143+
"$schema": "https://opencode.ai/config.json",
144+
"mcp": {
126145
"django": {
127-
"command": "python",
128-
"args": ["-m", "mcp_django"],
129-
"cwd": "/path/to/your/django/project",
130-
"env": {
146+
"type": "local",
147+
"command": ["python", "-m", "mcp_django"],
148+
"enabled": true,
149+
"environment": {
131150
"DJANGO_SETTINGS_MODULE": "myproject.settings"
132151
}
133152
}
134153
}
135154
}
136155
```
137156

138-
### Opencode
157+
For **Docker development**, use `type: remote` with the URL:
139158

140159
```json
141160
{
142161
"$schema": "https://opencode.ai/config.json",
143162
"mcp": {
144163
"django": {
145-
"type": "local",
146-
"command": ["python", "-m", "mcp_django"],
147-
"enabled": true,
148-
"environment": {
164+
"type": "remote",
165+
"url": "http://localhost:8001/mcp",
166+
"enabled": true
167+
}
168+
}
169+
}
170+
```
171+
172+
#### Claude Code
173+
174+
For **local development**, use the command configuration:
175+
176+
```json
177+
{
178+
"mcpServers": {
179+
"django": {
180+
"command": "python",
181+
"args": ["-m", "mcp_django"],
182+
"cwd": "/path/to/your/django/project",
183+
"env": {
149184
"DJANGO_SETTINGS_MODULE": "myproject.settings"
150185
}
151186
}
152187
}
153188
}
154189
```
155190

191+
For **Docker development** with HTTP/SSE transport, configuration varies by Claude Code version - consult the MCP client documentation for remote server setup.
192+
156193
## Features
157194

158195
mcp-django provides an MCP server with Django project exploration resources and tools for LLM assistants.

0 commit comments

Comments
 (0)