[Developer] add Codex streamable MCP endpoint

This commit is contained in:
devmrko
2026-07-07 17:52:29 +09:00
parent 6921682bcd
commit 9d3e384203
4 changed files with 94 additions and 2 deletions

View File

@@ -29,6 +29,20 @@ public class McpSseController {
this.mcpSseService = mcpSseService;
}
/**
* Streamable HTTP transport for Codex and other current MCP clients.
* The legacy SSE endpoints remain available for existing integrations.
*/
@PostMapping(path = "/mcp", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ObjectNode> streamableMessage(@RequestBody JsonNode request) {
// JSON-RPC notifications never receive a response body. Current MCP
// clients send notifications/initialized immediately after initialize.
if (request != null && !request.has("id")) {
return ResponseEntity.accepted().build();
}
return ResponseEntity.ok(mcpSseService.handle("default", request));
}
@GetMapping(path = "/mcp/sse", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public SseEmitter defaultSse() throws IOException {
return openSse("default");