alibaba/nacos · warning · NacosApiException

PARAMETER_VALIDATE_ERROR

PARAMETER_VALIDATE_ERROR

Error message

parameter `type` should be %s or %s, but was %s

What it means

Thrown by the default branch of the type switch in McpServerEndpointRequestHandler.doHandler() when request.getType() is neither REGISTER_ENDPOINT ('registerEndpoint') nor DE_REGISTER_ENDPOINT ('deregisterEndpoint'). Mapped to PARAMETER_VALIDATE_ERROR with an INVALID_PARAM top-level code; caught and placed into the response error info.

Source

Thrown at ai/src/main/java/com/alibaba/nacos/ai/remote/handler/McpServerEndpointRequestHandler.java:147

        Service service = Service.newService(request.getNamespaceId(), serviceRef.getGroupName(),
            serviceRef.getServiceName(), true);
        switch (request.getType()) {
            case AiRemoteConstants.REGISTER_ENDPOINT:
                LOGGER.info("[{}] register endpoint {}:{} version {} for mcp server: {}",
                    meta.getConnectionId(),
                    request.getAddress(), request.getPort(), request.getVersion(),
                    request.getMcpName());
                doRegister(service, instance, meta);
                break;
            case AiRemoteConstants.DE_REGISTER_ENDPOINT:
                LOGGER.info("[{}] de-register endpoint {}:{} version {} for mcp server: {}",
                    meta.getConnectionId(),
                    request.getAddress(), request.getPort(), request.getVersion(),
                    request.getMcpName());
                doDeregister(service, instance, meta);
                break;
            default:
                throw new NacosApiException(NacosException.INVALID_PARAM,
                    ErrorCode.PARAMETER_VALIDATE_ERROR,
                    String.format("parameter `type` should be %s or %s, but was %s",
                        AiRemoteConstants.REGISTER_ENDPOINT, AiRemoteConstants.DE_REGISTER_ENDPOINT,
                        request.getType()));
        }
        McpServerEndpointResponse response = new McpServerEndpointResponse();
        response.setType(request.getType());
        return response;
    }
    
    private Instance buildInstance(McpServerEndpointRequest request) throws NacosApiException {
        Instance instance = new Instance();
        instance.setIp(request.getAddress());
        instance.setPort(request.getPort());
        instance.validate();
        if (StringUtils.isNotBlank(request.getVersion())) {
            instance.getMetadata().put(VERSION_TAG, request.getVersion());
        }

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Set request.setType to AiRemoteConstants.REGISTER_ENDPOINT or AiRemoteConstants.DE_REGISTER_ENDPOINT.
  2. Use the SDK's typed enum/constants rather than hand-coded strings.
  3. Confirm you are calling the right handler (single register/deregister, not batch).

Example fix

// before
req.setType("register"); // wrong literal

// after
req.setType(AiRemoteConstants.REGISTER_ENDPOINT); // "registerEndpoint"
Defensive patterns

Strategy: validation

Validate before calling

String t = request.getType();
if (!AiRemoteConstants.REGISTER_ENDPOINT.equals(t)
    && !AiRemoteConstants.DE_REGISTER_ENDPOINT.equals(t)) {
    throw new IllegalArgumentException(
        "type must be registerEndpoint or deregisterEndpoint, was: " + t);
}

Try / catch

McpServerEndpointResponse resp = handler.handle(request, meta);
if (ErrorCode.PARAMETER_VALIDATE_ERROR.getCode() == resp.getDetailErrCode()
    && resp.getErrMsg().contains("type should")) {
    // fix the type constant and retry
}

Prevention

When it happens

Trigger: A gRPC McpServerEndpointRequest whose type field is unset, null, or any string other than the two recognized constants. The message reports the actual value received.

Common situations: Client sets type via a raw string and mistypes it; client leaves type null expecting a default; version skew where the client uses a constant that was renamed; a BATCH_REGISTER_ENDPOINT value mistakenly sent to the single-endpoint handler.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/5960df2cd6da0226. Report an issue: GitHub.