feat: Nexus chat in the DAppNode UI + MCP server#2438
Open
hcastc00 wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nexus chat in the DAppNode UI + MCP server
Summary
Adds a chat panel that talks to a Nexus gateway through this DAppNode, plus an MCP server that exposes the same tool registry to external clients (Claude Desktop, Cursor, etc.).
/nexus/*routes proxy chat completions to a Nexus gateway with the API key held server-side (NEXUS_API_KEYenv), persist chat history, and stream SSE back to the browser. A multi-step tool loop dispatches DAppNode-specific tools (list packages, fetch logs, diagnose, restart/start/stop/update package, search/fetch docs) and surfaces mutating calls to the UI for explicit confirmation before running.POST/GET/DELETE /mcpbehindauth.onlyAdminusing the streamable HTTP transport from@modelcontextprotocol/sdk. External MCP clients can authenticate as admin and call the same tools the embedded chat uses.docs.dappnode.iodriven byllms.txt. The chat is prompted to consult docs over training-data memory for any DAppNode-specific question; pages are pre-warmed on first chat so latency is negligible.ChatPanelrendered both on/ai/nexus(full-page) and as a floating launcher mounted app-wide. Includes model picker (last-used persisted inlocalStorage), confirmation dialog for mutating tool calls, persisted conversation history (server-side via dbCache), markdown rendering with GFM tables, and a smooth-stream pacer so token deltas read at a steady rate. The NexusPage marketing landing is replaced by the chat surface; the existing "About Nexus" link stays in the footer.Notable design choices
llms.txt, (b) this node's installed-package snapshot (60 s in-mem cache), and (c) the current admin-UI page (passed by the browser asdappmanager_page). The model is instructed to consultdappnode_search_docs/dappnode_fetch_docbefore answering DAppNode-specific questions.restart_package,start_package,stop_package, andupdate_packagego throughcreatePendingConfirmation→ SSEconfirm_requiredevent → UI dialog →POST /nexus/chat/confirm. A 5-minute server-side timeout auto-denies abandoned prompts.mcp/tools.tsis consumed by both the chat's in-process dispatcher (mcp/dispatch.ts) and the MCP server (mcp/server.ts), so behaviour is identical whether the caller is the embedded chat or an external MCP client.New environment variables
All three are read by the
dappmanagercontainer (see docker-compose.yml and docker-compose-dev.yml). The chat is disabled untilNEXUS_API_KEYis set.NEXUS_API_KEY/nexus/statusreportsconfigured: falseand the UI shows the "not configured" panel.NEXUS_GATEWAY_URLhttps://nexus-api.dappnode.com/v1NEXUS_DEFAULT_MODELnexus/router/modelslist.Set them on the dappmanager service (
docker-compose.yml→services.dappmanager.environment) and restart the container. There are no other config touchpoints — the key is read fresh fromprocess.envper request, so changing it requires a container restart.How to test
Prerequisites:
NEXUS_API_KEYexported in the dappmanager container's environment; container restarted./ai/nexus→ header shows the model picker populated from/nexus/models. WithNEXUS_API_KEYunset, the page shows the "not configured" panel and the floating bubble's panel does the same.listPackages()output (model calleddappnode_list_packagesunder the hood).dappnode_search_docsthendappnode_fetch_docand cite adocs.dappnode.io/...URL (no trailing.md)._skipped restart_package — …_line. Repeat and Approve → the package is actually restarted, assistant continues./packages, click the bubble, ask "what is this page?" → answer references the packages page. Navigate to/systemwhile the panel stays open, ask again → answer reflects the new path (the panel samples location lazily on each send).POST/GET/DELETE https://<dappnode>/mcp, list tools → matchesdappnodeToolListfrommcp/tools.ts. Callingdappnode_list_packagesreturns the same JSON the embedded chat sees.NEXUS_DEFAULT_MODEL=openai/gpt-4o, restart → header dropdown defaults to that model on fresh visits.NEXUS_GATEWAY_URLat a stub server and confirm requests hit it instead ofnexus-api.dappnode.com.git grep "sk-"against the branch returns no committed API keys.