Skip to content

Commit 0f73b3c

Browse files
fix: change http mode to be stateless (#6)
* fix: make http mode stateless * chore(ci): update pipeline version
1 parent b2b25c4 commit 0f73b3c

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

.github/settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ repository:
2525
# description: ""
2626

2727
# Use a comma-separated list of topics to set on the repo (ensure not to use any caps in the topic string).
28-
topics: terraform, ibm-cloud, terraform-module
28+
topics: terraform, ibm-cloud, terraform-module, mcp

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ on:
88

99
jobs:
1010
call-terraform-ci-pipeline:
11-
uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/[email protected].1
11+
uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/[email protected].2
1212
secrets: inherit

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ tim-mcp --log-level DEBUG
107107

108108
### HTTP Mode
109109

110-
HTTP mode runs the server as a web service, ideal for network deployments and multiple concurrent clients.
110+
HTTP mode runs the server as a stateless web service, ideal for network deployments and multiple concurrent clients. The server runs in stateless mode, which means no session IDs are required and each request is handled independently.
111111

112112
```bash
113113
# HTTP mode with defaults (127.0.0.1:8000)
@@ -127,6 +127,12 @@ tim-mcp --http --log-level DEBUG
127127
- Server runs at: `http://host:port/`
128128
- MCP endpoint: `http://host:port/mcp`
129129

130+
**Stateless Operation:**
131+
- No session IDs required for HTTP requests
132+
- Each request is processed independently
133+
- Ideal for load balancing and horizontal scaling
134+
- Simplified client implementation
135+
130136
**Production HTTPS:**
131137
For production deployments requiring HTTPS, use nginx as a reverse proxy:
132138

examples/http_deployment.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ This guide covers deploying TIM-MCP server using HTTP transport for network acce
44

55
## Overview
66

7-
HTTP transport mode enables TIM-MCP to run as a web service, allowing:
7+
HTTP transport mode enables TIM-MCP to run as a stateless web service, allowing:
88
- Network access from remote clients
99
- Multiple concurrent client connections
1010
- Integration with existing web infrastructure
1111
- Load balancing and reverse proxy configurations
12+
- No session ID requirements (stateless operation)
13+
- Horizontal scaling without session affinity
1214

1315
## Basic HTTP Deployment
1416

@@ -34,6 +36,8 @@ The server will be available at:
3436
- Server: `http://127.0.0.1:8000/`
3537
- MCP endpoint: `http://127.0.0.1:8000/mcp`
3638

39+
**Note:** The server runs in stateless mode, so no session IDs are required. Each request is handled independently, making it perfect for load balancing and scaling.
40+
3741
### Environment Variables
3842

3943
Set environment variables for production:

tim_mcp/server.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,12 +604,15 @@ def main(transport_config=None):
604604
# Explicit STDIO mode
605605
mcp.run()
606606
elif transport_config.mode == "http":
607-
# HTTP mode with specified host and port
607+
# HTTP mode with specified host and port (always stateless)
608608
logger.info(
609-
f"Starting HTTP server on {transport_config.host}:{transport_config.port}"
609+
f"Starting stateless HTTP server on {transport_config.host}:{transport_config.port}"
610610
)
611611
mcp.run(
612-
transport="http", host=transport_config.host, port=transport_config.port
612+
transport="http",
613+
host=transport_config.host,
614+
port=transport_config.port,
615+
stateless_http=True,
613616
)
614617
else:
615618
raise ValueError(f"Unsupported transport mode: {transport_config.mode}")

0 commit comments

Comments
 (0)