Skip to content

Commit 4ad0ac6

Browse files
committed
fix: return 202 on non auth lookup
1 parent 3488fac commit 4ad0ac6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

apps/server/src/app.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import { RateLimiter } from "effect/unstable/persistence";
1313
import { RateLimitMiddleware } from "./helpers";
1414
import { McpLive } from "./mcp";
1515

16+
const methodNotAllowed = HttpServerResponse.empty({
17+
headers: { allow: "POST, OPTIONS" },
18+
status: 405,
19+
});
20+
1621
export const startStdioServer = () =>
1722
Layer.launch(
1823
McpLive.pipe(
@@ -28,6 +33,7 @@ export const startStdioServer = () =>
2833
);
2934

3035
const McpRouter = McpLive.pipe(
36+
Layer.provideMerge(HttpRouter.add("GET", "/mcp", methodNotAllowed)),
3137
Layer.provideMerge(
3238
McpServer.layerHttp({
3339
name: "ENS MCP Server",
@@ -41,14 +47,16 @@ const McpRouter = McpLive.pipe(
4147
Effect.gen(function* () {
4248
const request = yield* HttpServerRequest.HttpServerRequest;
4349
const response = yield* httpEffect;
50+
const isMcpEndpoint = request.url.split("?")[0] === "/mcp";
51+
4452
const body = response.body as {
4553
_tag: string;
4654
contentLength?: number;
4755
};
4856

4957
if (
5058
request.method === "POST" &&
51-
request.url === "/mcp" &&
59+
isMcpEndpoint &&
5260
response.status === 200 &&
5361
(body._tag === "Empty" ||
5462
body._tag === "Stream" ||

0 commit comments

Comments
 (0)