{"record":{"id":"1084bea7b521dd9f","repo":"serverless/serverless","slug":"api-gateway-external-event-route-collision","errorCode":"API_GATEWAY_EXTERNAL_EVENT_ROUTE_COLLISION","errorMessage":"The route \"${declaredRoutes[0]}\" defined in this service uses the same API Gateway resource as \"${contributedRoute}\", which the mcp server \"${externalEvent.functionName}\" needs. Routes under an MCP server's path segment are reserved for that server. Rename the mcp server, or remove the conflicting http event.","messagePattern":"The route \"(.+?)\" defined in this service uses the same API Gateway resource as \"(.+?)\", which the mcp server \"(.+?)\" needs\\. Routes under an MCP server's path segment are reserved for that server\\. Rename the mcp server, or remove the conflicting http event\\.","errorType":"validation","errorClass":"ServerlessError","httpStatus":null,"severity":"error","filePath":"packages/serverless/lib/plugins/aws/package/compile/events/api-gateway/lib/validate.js","lineNumber":339,"sourceCode":"        } else {\n          declaredRoutesByResourceId.set(resourceId, [routeOf(event.http)])\n        }\n      }\n      const contributedByResourceId = new Map()\n      for (const externalEvent of this.externalHttpEvents) {\n        if (!Object.hasOwn(serviceFunctions, externalEvent.functionName)) {\n          throw new ServerlessError(\n            `An internally contributed http event references the function \"${externalEvent.functionName}\", which is not defined in this service`,\n            'API_GATEWAY_EXTERNAL_EVENT_UNKNOWN_FUNCTION',\n            { stack: false },\n          )\n        }\n\n        const resourceId = resourceIdOf(externalEvent.http)\n        const contributedRoute = routeOf(externalEvent.http)\n        const declaredRoutes = declaredRoutesByResourceId.get(resourceId)\n        if (declaredRoutes) {\n          throw new ServerlessError(\n            `The route \"${declaredRoutes[0]}\" defined in this service uses the same API Gateway resource as \"${contributedRoute}\", which the mcp server \"${externalEvent.functionName}\" needs. Routes under an MCP server's path segment are reserved for that server. Rename the mcp server, or remove the conflicting http event.`,\n            'API_GATEWAY_EXTERNAL_EVENT_ROUTE_COLLISION',\n            { stack: false },\n          )\n        }\n\n        const contributedMethod = this.getHttpMethod(externalEvent.http)\n        const contributed = contributedByResourceId.get(resourceId)\n        const conflicting = contributed?.find(\n          (entry) =>\n            entry.method === contributedMethod ||\n            entry.method === 'any' ||\n            contributedMethod === 'any',\n        )\n        if (conflicting) {\n          throw new ServerlessError(\n            `The mcp servers \"${conflicting.functionName}\" and \"${externalEvent.functionName}\" both need the API Gateway resource behind \"${contributedRoute}\" (their paths resolve to the same resource). Rename one of the mcp servers.`,\n            'API_GATEWAY_EXTERNAL_EVENT_ROUTE_COLLISION',","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/serverless/serverless/blob/b9d7ea51c8cce57cff1207964b9b71123673081f/packages/serverless/lib/plugins/aws/package/compile/events/api-gateway/lib/validate.js#L321-L357","documentation":"Error \"The route \"${declaredRoutes[0]}\" defined in this service uses the same API Gateway resource as \"${contributedRoute}\", which the mcp server \"${externalEvent.functionName}\" needs. Routes under an MCP server's path segment are reserved for that server. Rename the mcp server, or remove the conflicting http event.\" thrown in serverless/serverless.","triggerScenarios":"Thrown at packages/serverless/lib/plugins/aws/package/compile/events/api-gateway/lib/validate.js:339 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the MCP server so its path segment no longer collides, or remove the conflicting http event route from your functions."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b9d7ea51c8cce57cff1207964b9b71123673081f","analyzedAt":"2026-08-13T04:14:40.386Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}