File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ import { RateLimiter } from "effect/unstable/persistence";
1313import { RateLimitMiddleware } from "./helpers" ;
1414import { McpLive } from "./mcp" ;
1515
16+ const methodNotAllowed = HttpServerResponse . empty ( {
17+ headers : { allow : "POST, OPTIONS" } ,
18+ status : 405 ,
19+ } ) ;
20+
1621export const startStdioServer = ( ) =>
1722 Layer . launch (
1823 McpLive . pipe (
@@ -28,6 +33,7 @@ export const startStdioServer = () =>
2833 ) ;
2934
3035const 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" ||
You can’t perform that action at this time.
0 commit comments