feat: add MCP server support with global library and per-project toggles
All checks were successful
Build App / build-macos (push) Successful in 2m20s
Build App / build-windows (push) Successful in 3m21s
Build App / build-linux (push) Successful in 5m8s
Build Container / build-container (push) Successful in 1m4s
Sync Release to GitHub / sync-release (release) Successful in 2s
All checks were successful
Build App / build-macos (push) Successful in 2m20s
Build App / build-windows (push) Successful in 3m21s
Build App / build-linux (push) Successful in 5m8s
Build Container / build-container (push) Successful in 1m4s
Sync Release to GitHub / sync-release (release) Successful in 2s
Add Model Context Protocol (MCP) server configuration support. Users can define MCP servers globally (new sidebar tab) and enable them per-project. Enabled servers are injected into containers as MCP_SERVERS_JSON env var and merged into ~/.claude.json by the entrypoint. Backend: McpServer model, McpStore (JSON + atomic writes), 4 CRUD commands, container injection with fingerprint-based recreation detection. Frontend: MCP sidebar tab, McpPanel/McpServerCard components, useMcpServers hook, per-project MCP checkboxes in ProjectCard config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
55
app/src/hooks/useMcpServers.ts
Normal file
55
app/src/hooks/useMcpServers.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { useCallback } from "react";
|
||||
import { useShallow } from "zustand/react/shallow";
|
||||
import { useAppState } from "../store/appState";
|
||||
import * as commands from "../lib/tauri-commands";
|
||||
import type { McpServer } from "../lib/types";
|
||||
|
||||
export function useMcpServers() {
|
||||
const {
|
||||
mcpServers,
|
||||
setMcpServers,
|
||||
updateMcpServerInList,
|
||||
removeMcpServerFromList,
|
||||
} = useAppState(
|
||||
useShallow(s => ({
|
||||
mcpServers: s.mcpServers,
|
||||
setMcpServers: s.setMcpServers,
|
||||
updateMcpServerInList: s.updateMcpServerInList,
|
||||
removeMcpServerFromList: s.removeMcpServerFromList,
|
||||
}))
|
||||
);
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
const list = await commands.listMcpServers();
|
||||
setMcpServers(list);
|
||||
}, [setMcpServers]);
|
||||
|
||||
const add = useCallback(
|
||||
async (name: string) => {
|
||||
const server = await commands.addMcpServer(name);
|
||||
const list = await commands.listMcpServers();
|
||||
setMcpServers(list);
|
||||
return server;
|
||||
},
|
||||
[setMcpServers],
|
||||
);
|
||||
|
||||
const update = useCallback(
|
||||
async (server: McpServer) => {
|
||||
const updated = await commands.updateMcpServer(server);
|
||||
updateMcpServerInList(updated);
|
||||
return updated;
|
||||
},
|
||||
[updateMcpServerInList],
|
||||
);
|
||||
|
||||
const remove = useCallback(
|
||||
async (id: string) => {
|
||||
await commands.removeMcpServer(id);
|
||||
removeMcpServerFromList(id);
|
||||
},
|
||||
[removeMcpServerFromList],
|
||||
);
|
||||
|
||||
return { mcpServers, refresh, add, update, remove };
|
||||
}
|
||||
Reference in New Issue
Block a user