From 155630512739f3da992548a1f6f2cacaa74d979a Mon Sep 17 00:00:00 2001 From: Hashrocket Workstation Date: Fri, 31 Oct 2025 09:39:49 -0400 Subject: [PATCH] Fix MCP server mime types Co-authored-by: Vinicius Negrisolo Co-authored-by: Gabriel Reis --- config/config.exs | 4 ++++ lib/tilex_web/router.ex | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config/config.exs b/config/config.exs index fc07b8ce..4e473040 100644 --- a/config/config.exs +++ b/config/config.exs @@ -117,6 +117,10 @@ config :tilex, Tilex.Notifications.Notifiers.Twitter, token: System.get_env("twitter_access_token"), token_secret: System.get_env("twitter_access_token_secret") +config :mime, :types, %{ + "text/event-stream" => ["stream"] +} + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/lib/tilex_web/router.ex b/lib/tilex_web/router.ex index 6c688330..5b6f6983 100644 --- a/lib/tilex_web/router.ex +++ b/lib/tilex_web/router.ex @@ -41,6 +41,18 @@ defmodule TilexWeb.Router do plug Tilex.Plug.RateLimiter end + pipeline :mcp do + plug :accepts, ["json", "stream"] + end + + scope "/mcp" do + pipe_through [:mcp] + + forward "/", + Anubis.Server.Transport.StreamableHTTP.Plug, + server: Tilex.MCP.Server + end + scope "/api", TilexWeb do pipe_through [:api] @@ -113,8 +125,4 @@ defmodule TilexWeb.Router do forward "/mailbox", Plug.Swoosh.MailboxPreview end end - - forward "/mcp", - Anubis.Server.Transport.StreamableHTTP.Plug, - server: Tilex.MCP.Server end