{"record":{"id":"89f4292dc3086ad6","repo":"upstash/context7","slug":"not-found","errorCode":"not_found","errorMessage":"Endpoint not found.","messagePattern":"Endpoint not found\\.","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"packages/mcp/src/index.ts","lineNumber":597,"sourceCode":"            });\n          }\n          res.json(upstream.metadata);\n        } catch (error) {\n          console.error(\"[OAuth] Error fetching OAuth metadata:\", error);\n          res.status(502).json({\n            error: \"proxy_error\",\n            message: \"Failed to proxy authorization server metadata\",\n          });\n        }\n      }\n    );\n\n    // OpenAI Apps SDK domain verification challenge\n    app.get(\n      \"/.well-known/openai-apps-challenge\",\n      (_req: express.Request, res: express.Response) => {\n        if (!OPENAI_APPS_CHALLENGE_TOKEN) {\n          return res.status(404).json({\n            error: \"not_found\",\n            message: \"Endpoint not found.\",\n          });\n        }\n        res.type(\"text/plain\").send(OPENAI_APPS_CHALLENGE_TOKEN);\n      }\n    );\n\n    // Catch-all 404 handler - must be after all other routes\n    app.use((_req: express.Request, res: express.Response) => {\n      res.status(404).json({\n        error: \"not_found\",\n        message: \"Endpoint not found. Use /mcp for MCP protocol communication.\",\n      });\n    });\n\n    let activeHttpServer: ReturnType<typeof app.listen> | undefined;\n    installProcessShutdown(","sourceCodeStart":579,"sourceCodeEnd":615,"githubUrl":"https://github.com/upstash/context7/blob/4416fb855b8f752be735e34f943b5d0762701aad/packages/mcp/src/index.ts#L579-L615","documentation":"The /.well-known/openai-apps-challenge endpoint returns 404 (error code \"not_found\") when the OPENAI_APPS_CHALLENGE_TOKEN environment variable is not set. The route exists but has nothing to serve, so it reports the endpoint as not found instead of returning an empty challenge.","triggerScenarios":"GET /.well-known/openai-apps-challenge on an MCP server started without OPENAI_APPS_CHALLENGE_TOKEN in its environment (undefined or empty).","commonSituations":"OpenAI Apps SDK domain verification fails because the operator forgot to set the challenge token env var, or the server was restarted without the env loaded (e.g. missing in Docker/compose/systemd config).","solutions":["Set the OPENAI_APPS_CHALLENGE_TOKEN env var to the token value provided by OpenAI's domain verification and restart the server.","Confirm the env var reaches the process (docker compose env_file, --env-file, systemd Environment=).","Re-run the domain verification challenge after the server is up."],"exampleFix":"// before\n// (no env var set) -> 404 not_found\n// after\n# .env / shell\nOPENAI_APPS_CHALLENGE_TOKEN=abc123-challenge-token\nnpm start","handlingStrategy":"validation","validationCode":"if (!process.env.OPENAI_APPS_CHALLENGE_TOKEN) {\n  console.warn('OPENAI_APPS_CHALLENGE_TOKEN not set; challenge endpoint will 404');\n}","typeGuard":null,"tryCatchPattern":"const res = await fetch(`${serverUrl}/.well-known/openai-apps-challenge`);\nif (res.status === 404) {\n  console.error('Challenge token missing on server: set OPENAI_APPS_CHALLENGE_TOKEN');\n}","preventionTips":["Add OPENAI_APPS_CHALLENGE_TOKEN to your .env / deployment secrets checklist","Fail fast at server startup (log a warning) when the token is absent","Verify env vars reach containerized processes (env_file, secrets mounting)","Re-check the token after every server redeploy before running domain verification"],"tags":["env-var","not-found","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"4416fb855b8f752be735e34f943b5d0762701aad","analyzedAt":"2026-09-16T20:28:07.148Z","contentChangedAt":"2026-09-16T20:28:07.148Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}