Skip to content

Commit 1db4d98

Browse files
committed
extending the use of stdio transport for mcp clients that do not support http
1 parent 72b43d0 commit 1db4d98

File tree

3 files changed

+69
-7
lines changed

3 files changed

+69
-7
lines changed

CLAUDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ uv run pre-commit install
1717
```
1818

1919
### Running the Server
20+
21+
The server can be run in different modes using the `--transport` argument. The default transport is `stdio`.
22+
23+
When using Docker, the transport can be controlled with the `MCP_MODE` environment variable, which defaults to `stdio`.
24+
2025
```bash
2126
# STDIO mode (for AI clients like Claude Desktop)
2227
uv run python -m gx_mcp_server

Dockerfile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ COPY --chown=app:app . .
1111
ARG WITH_DEV=false
1212
RUN if [ "$WITH_DEV" = "true" ]; then uv pip install -e ".[dev]"; else uv pip install -e .; fi
1313
EXPOSE 8000
14+
15+
# Set default mode to stdio, but allow override
16+
ENV MCP_MODE=stdio
17+
18+
# Conditional healthcheck only for HTTP mode
1419
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
15-
CMD python -c "import urllib.request, sys; urllib.request.urlopen('http://localhost:8000/mcp/health').read() or sys.exit(1)"
16-
CMD ["uv", "run", "python", "-m", "gx_mcp_server", "--http", "--host", "0.0.0.0"]
20+
CMD if [ "$MCP_MODE" = "http" ]; then \
21+
python -c "import urllib.request, sys; urllib.request.urlopen('http://localhost:8000/mcp/health').read() or sys.exit(1)"; \
22+
else \
23+
echo "STDIO mode - no healthcheck needed"; \
24+
fi
25+
26+
# Use shell form to allow environment variable expansion
27+
CMD if [ "$MCP_MODE" = "http" ]; then \
28+
uv run python -m gx_mcp_server --http --host 0.0.0.0; \
29+
else \
30+
uv run python -m gx_mcp_server; \
31+
fi

README.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,16 @@ Large Language Model (LLM) agents often need to interact with and validate data.
3636

3737
**Docker (Recommended):**
3838
```bash
39-
docker run -d -p 8000:8000 --name gx-mcp-server davidf9999/gx-mcp-server:latest
39+
# Run in default stdio mode
40+
docker run --rm -i davidf9999/gx-mcp-server:latest
41+
42+
# Run in http mode
43+
docker run -d -p 8000:8000 --name gx-mcp-server -e MCP_MODE=http davidf9999/gx-mcp-server:latest
4044
claude mcp add gx-mcp-server --transport http http://localhost:8000/mcp/
41-
claude "Load CSV data id,age\n1,25\n2,19\n3,45 and validate ages 21-65, show failed records"
45+
claude "Load CSV data id,age
46+
1,25
47+
2,19
48+
3,45 and validate ages 21-65, show failed records"
4249
```
4350

4451
**Local Development:**
@@ -97,7 +104,37 @@ Configure any MCP-compatible client (Claude Desktop, Claude CLI, custom applicat
97104
claude mcp add gx-mcp-server-local -- uv run python -m gx_mcp_server
98105
```
99106

107+
**Claude CLI with Docker (stdio)**
108+
```bash
109+
claude mcp add gx-stdio \
110+
-- docker run --rm -i \
111+
-e MCP_MODE=stdio \
112+
-e PYTHONUNBUFFERED=1 \
113+
gx-mcp-server
114+
```
115+
116+
**cline with Docker (stdio)**
117+
```json
118+
{
119+
"mcpServers": {
120+
"gx": {
121+
"command": "docker",
122+
"args": [
123+
"run","--rm","-i",
124+
"--network","none", // optional isolation
125+
"-e","MCP_MODE=stdio", // your new switch
126+
"-e","PYTHONUNBUFFERED=1", // avoid buffering
127+
"davidf9999/gx-mcp-server:latest"
128+
],
129+
"alwaysAllow": ["*"],
130+
"timeout": 60
131+
}
132+
}
133+
}
134+
```
135+
100136
**Docker without Authentication:**
137+
```
101138
```bash
102139
docker run -d -p 8000:8000 --name gx-mcp-server davidf9999/gx-mcp-server:latest
103140
claude mcp add gx-mcp-server --transport http http://localhost:8000/mcp/
@@ -294,20 +331,25 @@ load_dataset("bigquery://project/dataset/table")
294331

295332
### Using Pre-built Images (Recommended)
296333

297-
The easiest way to run `gx-mcp-server` is using the official Docker image:
334+
The easiest way to run `gx-mcp-server` is using the official Docker image. By default, the container runs in `stdio` mode. You can switch to `http` mode by setting the `MCP_MODE` environment variable to `http`.
298335

299336
```bash
300-
# Run latest stable version
301-
docker run -d -p 8000:8000 --name gx-mcp-server davidf9999/gx-mcp-server:latest
337+
# Run latest stable version in stdio mode
338+
docker run --rm -i davidf9999/gx-mcp-server:latest
339+
340+
# Run latest stable version in http mode
341+
docker run -d -p 8000:8000 --name gx-mcp-server -e MCP_MODE=http davidf9999/gx-mcp-server:latest
302342

303343
# Run with authentication
304344
docker run -d -p 8000:8000 --name gx-mcp-server \
345+
-e MCP_MODE=http \
305346
-e MCP_SERVER_USER=myuser \
306347
-e MCP_SERVER_PASSWORD=mypass \
307348
davidf9999/gx-mcp-server:latest
308349

309350
# Run with file access (for loading local CSV files)
310351
docker run -d -p 8000:8000 --name gx-mcp-server \
352+
-e MCP_MODE=http \
311353
-v "$(pwd)/data:/app/data" \
312354
davidf9999/gx-mcp-server:latest
313355
```

0 commit comments

Comments
 (0)