File tree Expand file tree Collapse file tree 3 files changed +360
-204
lines changed Expand file tree Collapse file tree 3 files changed +360
-204
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ uv sync --all-extras --dev
79
79
# For development
80
80
uv run ruff check .
81
81
uv run pyright
82
- uv run pytest
82
+ uv run pytest # coverage report will be in htmlcov/index.html
83
83
```
84
84
85
85
### Build the Typescript package
@@ -96,7 +96,7 @@ npm run build
96
96
npm link
97
97
98
98
# For development
99
- npm test ( coverage report will be in coverage/index.html)
99
+ npm test # coverage report will be in coverage/index.html
100
100
npm run lint
101
101
```
102
102
Original file line number Diff line number Diff line change @@ -187,7 +187,8 @@ def process_http_request(
187
187
)
188
188
189
189
# Handle both single messages and batches according to MCP spec
190
- if isinstance (parsed_body , list ):
190
+ is_batch_request = isinstance (parsed_body , list )
191
+ if is_batch_request :
191
192
messages = parsed_body
192
193
else :
193
194
messages = [parsed_body ]
@@ -268,12 +269,21 @@ def process_http_request(
268
269
}
269
270
270
271
# Return the response(s)
271
- if len ( responses ) == 1 :
272
- response_body = responses [ 0 ]. model_dump ( by_alias = True , exclude_none = True )
273
- else :
272
+ # For batch requests, always return an array even if there's only one response
273
+ # For single requests, return a single object
274
+ if is_batch_request :
274
275
response_body = [
275
276
r .model_dump (by_alias = True , exclude_none = True ) for r in responses
276
277
]
278
+ else :
279
+ # Single request - return single response object
280
+ if len (responses ) == 1 :
281
+ response_body = responses [0 ].model_dump (by_alias = True , exclude_none = True )
282
+ else :
283
+ # This shouldn't happen for single requests, but handle gracefully
284
+ response_body = [
285
+ r .model_dump (by_alias = True , exclude_none = True ) for r in responses
286
+ ]
277
287
278
288
return HttpResponse (
279
289
status_code = 200 , headers = response_headers , body = json .dumps (response_body )
You can’t perform that action at this time.
0 commit comments