Repository navigation
WIP: MCP event pipeline + passive status panel #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b2426fd
fef2a7f
946d0ef
f6a19b5
0add323
ca092c7
952a109
720e252
22c0f4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,6 +213,11 @@ defmodule HarnessWeb.HarnessChannel do | |
| end | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_in("mcp.status", _params, socket) do | ||
| {:reply, {:error, %{message: "Missing required param: threadId"}}, socket} | ||
| end | ||
|
Comment on lines
+216
to
+219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These fallback clauses still let JSON The earlier heads on Line 206, Line 222, Line 245, and Line 262 already match Also applies to: 232-276 🤖 Prompt for AI Agents |
||
|
|
||
| @impl true | ||
| def handle_in("mcp.add", %{"threadId" => thread_id, "name" => name, "config" => config}, socket) do | ||
| case SessionManager.mcp_add(thread_id, name, config) do | ||
|
|
@@ -224,6 +229,18 @@ defmodule HarnessWeb.HarnessChannel do | |
| end | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_in("mcp.add", params, socket) do | ||
| missing = | ||
| cond do | ||
| is_nil(Map.get(params, "threadId")) -> "threadId" | ||
| is_nil(Map.get(params, "name")) -> "name" | ||
| true -> "config" | ||
| end | ||
|
|
||
| {:reply, {:error, %{message: "Missing required param: #{missing}"}}, socket} | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_in("mcp.connect", %{"threadId" => thread_id, "name" => name}, socket) do | ||
| case SessionManager.mcp_connect(thread_id, name) do | ||
|
|
@@ -235,6 +252,12 @@ defmodule HarnessWeb.HarnessChannel do | |
| end | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_in("mcp.connect", params, socket) do | ||
| missing = if is_nil(Map.get(params, "threadId")), do: "threadId", else: "name" | ||
| {:reply, {:error, %{message: "Missing required param: #{missing}"}}, socket} | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_in("mcp.disconnect", %{"threadId" => thread_id, "name" => name}, socket) do | ||
| case SessionManager.mcp_disconnect(thread_id, name) do | ||
|
|
@@ -246,6 +269,12 @@ defmodule HarnessWeb.HarnessChannel do | |
| end | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_in("mcp.disconnect", params, socket) do | ||
| missing = if is_nil(Map.get(params, "threadId")), do: "threadId", else: "name" | ||
| {:reply, {:error, %{message: "Missing required param: #{missing}"}}, socket} | ||
| end | ||
|
|
||
| # --- Snapshot --- | ||
|
|
||
| @impl true | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
In Req (Elixir), when a JSON response body is a top-level array, isresponse.bodydecoded into an Elixir list by default?💡 Result:
Yes, in Req (Elixir), when a JSON response body is a top-level array and the Content-Type header indicates application/json, response.body is decoded into an Elixir list by default. Req's decode_body response step automatically detects the format from the content-type header and uses Jason.decode!/2 to parse JSON bodies. Jason decodes JSON arrays to Elixir lists [1,2,3] -> [1,2,3]. This is enabled by default (decode_body: true).
Citations:
🏁 Script executed:
Repository: Ranvier-Technologies/t3code-OTP
Length of output: 495
The new list-response branch is unreachable with the current
http_get/1implementation.Line 1331-1334 checks only for maps; when
Reqdecodes a JSON array from/provider, it returns an Elixir list. Sinceis_map(body)is false for lists, the code callsJason.decode(to_string(body)). Theto_string/1call converts the list to its string representation (e.g.,"[%{...}]"), which is not valid JSON. The subsequentJason.decode/1call will raise an error, preventingfetch_providers/1from ever receiving the decoded list. This breaks provider discovery on any endpoint returning a JSON array.Fix: Update the condition to
if is_map(body) or is_list(body), do: {:ok, body}, else: Jason.decode(to_string(body))to pass through already-decoded lists.🤖 Prompt for AI Agents