[Bug]: CLI MCP generation reports success after HTTP errors and overwrites an existing configuration
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 58/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go
- Área
- backend-api-design, cli
Línea de trabajo
Start with cli/src/internal/mcp/generator.go, especially postJSONRPCWithSession, initializeMCPServer, and the output-writing path identified in the issue. Trace how HTTP errors and JSON-RPC results flow through discovery, and check how bodyless 202 notification responses are handled. Done means failed initialization or discovery returns a nonzero exit and preserves the existing file, while successful discovery still generates the configuration.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
ap gateway mcp generate in WSO2 API Platform CLI ap v0.9.1 can exit successfully after HTTP authentication or service errors when the error body is a JSON object without a JSON-RPC error property. It treats the missing list result as an empty catalogue and overwrites an existing generated-mcp.yaml with empty lists.
This is incorrect error handling and configuration loss. It does not bypass authentication and does not grant access to protected server data.
Steps to Reproduce
-
Download and extract the official CLI release
ap/v0.9.1. -
Download reproduce_mcp.py (Python standard library only).
-
Run:
python reproduce_mcp.py --binary /absolute/path/to/ap --case json --case http_503_tools --case http_401_allOn Windows use
--binary "C:\tools\ap.exe"andpythonorpyas appropriate.
Each error case writes a marker into a temporary generated-mcp.yaml before invoking the CLI, so preservation can be checked without touching a real configuration. Fixture responses:
http_503_tools:initializesucceeds and advertises all capabilities;tools/listresponds with HTTP 503 and{"message":"Service temporarily unavailable"}. Other list methods succeed.http_401_all: every POST includinginitializeresponds with HTTP 401 and{"detail":"Unauthorized"}, representing an upstream authentication layer.
Actual result
| Case | CLI exit | Echo tool in output | Existing config preserved |
|---|---|---|---|
json (control) |
0 | Yes | n/a |
http_503_tools |
0 | No | No |
http_401_all |
0 | No | No |
Both error cases print MCP generated successfully., report zero tools, and replace the previous configuration with tools: [], prompts: [], resources: []. In the 401 case the CLI proceeds through every discovery method even though initialization failed. No error is emitted on stderr.
Expected result
Return a nonzero exit status with the HTTP status and a useful error message. Do not write or overwrite the generated configuration after a failed initialization or any failed discovery request. A bodyless 202 notification response should remain a separate accepted case from JSON-RPC request responses.
Source evidence and suggested direction
postJSONRPCWithSessionreads the response body without checkingresp.StatusCode.initializeMCPServeralso ignores non-successful HTTP status codes and does not require a valid initialize result.- Output writing then writes over the existing file.
Check HTTP status before decoding list results, validate the JSON-RPC envelope/result, and commit generated output only after the whole discovery sequence succeeds.
Environment Details
- Product/component: WSO2 API Platform CLI, official Linux amd64 release
ap/v0.9.1(ap version v0.9.1 (built at 2026-08-07T09:04:19Z)). - Test runtime: Linux 6.18.57 x86_64 with glibc 2.41, Python 3.12.14.
- Source reviewed: api-platform
mainat398d50772b5605ffe0d6d8693aa7b9ce7c84032e; inspected, not compiled or executed. - All fixtures advertise tools, prompts, resources and logging capabilities, so the separately reported optional-capability issue does not apply here.
- Evidence boundary: local mock server only; not tested against a WSO2-hosted product instance. No CVSS score is asserted.
Area / Aspect / Severity
Area: CLI. Aspect: Aspect/AI, Aspect/API and Aspect/Configuration. Severity: Severity/Major (provisional functional assessment for maintainer review).
Screenshot and attachments
- Lenguaje dominante
- Go
- Estrellas
- 85
- Forks
- 137
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 247
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de wso2/api-platform
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
wso2/api-platform#4369 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: host-rewrite policy documentation lists fewer allowed host characters than the policy acceptsAbiertoArea/Policies Aspect/Other Severity/Trivial Type/Bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
wso2/api-platform#4355 ·
Los mantenedores suelen responder en 1 día
-
Area/Gateway Aspect/API Severity/Minor Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
wso2/api-platform#4348 ·
Los mantenedores suelen responder en 1 día
-
Aspect/AI Aspect/API. Severity/Major
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
wso2/api-platform#4343 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: content-length-guardrail policy accepts a non-string streamingJsonPath at API creationAbiertoArea/Policies Aspect/Configuration Severity/Minor Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
wso2/api-platform#4330 ·
Los mantenedores suelen responder en 1 día
Todos los issues de wso2/api-platform
Issues similares
-
benchmark
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
mozilla-ai/cq#601 ·
Los mantenedores suelen responder en 1 día
-
documentation migration
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día