Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ defmodule ElixirLS.LanguageServer.MCP.RequestHandler do
"id" => id
}

%{"method" => _} ->
# JSON-RPC notification (no "id" field). Per spec, the server must
# not reply to notifications, even for unknown methods.
nil

_ ->
%{
"jsonrpc" => "2.0",
Expand Down
21 changes: 21 additions & 0 deletions apps/language_server/test/mcp/request_handler_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,27 @@ defmodule ElixirLS.LanguageServer.MCP.RequestHandlerTest do

assert response == nil
end

test "initialized notification does not get response" do
# MCP clients (e.g. Codex) send this notification after initialize.
# Per JSON-RPC 2.0 spec, notifications (no "id") must not receive a reply.
request = %{
"jsonrpc" => "2.0",
"method" => "initialized"
}

assert RequestHandler.handle_request(request) == nil
end

test "unknown notification (no id) does not get response" do
request = %{
"jsonrpc" => "2.0",
"method" => "notifications/something_unknown",
"params" => %{}
}

assert RequestHandler.handle_request(request) == nil
end
end

describe "integration with actual modules" do
Expand Down
Loading