mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-07-11 17:15:40 +08:00
chore: remove dead code related to MCP server
This commit is contained in:
@@ -178,171 +178,6 @@ router.get('/mcp', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// POST /api/cursor/mcp/add - Add MCP server to Cursor configuration
|
|
||||||
router.post('/mcp/add', async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { name, type = 'stdio', command, args = [], url, headers = {}, env = {} } = req.body;
|
|
||||||
const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
|
|
||||||
|
|
||||||
console.log(`➕ Adding MCP server to Cursor config: ${name}`);
|
|
||||||
|
|
||||||
// Read existing config or create new
|
|
||||||
let mcpConfig = { mcpServers: {} };
|
|
||||||
|
|
||||||
try {
|
|
||||||
const existing = await fs.readFile(mcpPath, 'utf8');
|
|
||||||
mcpConfig = JSON.parse(existing);
|
|
||||||
if (!mcpConfig.mcpServers) {
|
|
||||||
mcpConfig.mcpServers = {};
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log('Creating new Cursor MCP config');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build server config based on type
|
|
||||||
let serverConfig = {};
|
|
||||||
|
|
||||||
if (type === 'stdio') {
|
|
||||||
serverConfig = {
|
|
||||||
command: command,
|
|
||||||
args: args,
|
|
||||||
env: env
|
|
||||||
};
|
|
||||||
} else if (type === 'http' || type === 'sse') {
|
|
||||||
serverConfig = {
|
|
||||||
url: url,
|
|
||||||
transport: type,
|
|
||||||
headers: headers
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add server to config
|
|
||||||
mcpConfig.mcpServers[name] = serverConfig;
|
|
||||||
|
|
||||||
// Ensure directory exists
|
|
||||||
const mcpDir = path.dirname(mcpPath);
|
|
||||||
await fs.mkdir(mcpDir, { recursive: true });
|
|
||||||
|
|
||||||
// Write updated config
|
|
||||||
await fs.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
|
||||||
|
|
||||||
res.json({
|
|
||||||
success: true,
|
|
||||||
message: `MCP server "${name}" added to Cursor configuration`,
|
|
||||||
config: mcpConfig
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error adding MCP server to Cursor:', error);
|
|
||||||
res.status(500).json({
|
|
||||||
error: 'Failed to add MCP server',
|
|
||||||
details: error.message
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DELETE /api/cursor/mcp/:name - Remove MCP server from Cursor configuration
|
|
||||||
router.delete('/mcp/:name', async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { name } = req.params;
|
|
||||||
const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
|
|
||||||
|
|
||||||
console.log(`🗑️ Removing MCP server from Cursor config: ${name}`);
|
|
||||||
|
|
||||||
// Read existing config
|
|
||||||
let mcpConfig = { mcpServers: {} };
|
|
||||||
|
|
||||||
try {
|
|
||||||
const existing = await fs.readFile(mcpPath, 'utf8');
|
|
||||||
mcpConfig = JSON.parse(existing);
|
|
||||||
} catch (error) {
|
|
||||||
return res.status(404).json({
|
|
||||||
error: 'Cursor MCP configuration not found'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if server exists
|
|
||||||
if (!mcpConfig.mcpServers || !mcpConfig.mcpServers[name]) {
|
|
||||||
return res.status(404).json({
|
|
||||||
error: `MCP server "${name}" not found in Cursor configuration`
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove server from config
|
|
||||||
delete mcpConfig.mcpServers[name];
|
|
||||||
|
|
||||||
// Write updated config
|
|
||||||
await fs.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
|
||||||
|
|
||||||
res.json({
|
|
||||||
success: true,
|
|
||||||
message: `MCP server "${name}" removed from Cursor configuration`,
|
|
||||||
config: mcpConfig
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error removing MCP server from Cursor:', error);
|
|
||||||
res.status(500).json({
|
|
||||||
error: 'Failed to remove MCP server',
|
|
||||||
details: error.message
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// POST /api/cursor/mcp/add-json - Add MCP server using JSON format
|
|
||||||
router.post('/mcp/add-json', async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { name, jsonConfig } = req.body;
|
|
||||||
const mcpPath = path.join(os.homedir(), '.cursor', 'mcp.json');
|
|
||||||
|
|
||||||
console.log(`➕ Adding MCP server to Cursor config via JSON: ${name}`);
|
|
||||||
|
|
||||||
// Validate and parse JSON config
|
|
||||||
let parsedConfig;
|
|
||||||
try {
|
|
||||||
parsedConfig = typeof jsonConfig === 'string' ? JSON.parse(jsonConfig) : jsonConfig;
|
|
||||||
} catch (parseError) {
|
|
||||||
return res.status(400).json({
|
|
||||||
error: 'Invalid JSON configuration',
|
|
||||||
details: parseError.message
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read existing config or create new
|
|
||||||
let mcpConfig = { mcpServers: {} };
|
|
||||||
|
|
||||||
try {
|
|
||||||
const existing = await fs.readFile(mcpPath, 'utf8');
|
|
||||||
mcpConfig = JSON.parse(existing);
|
|
||||||
if (!mcpConfig.mcpServers) {
|
|
||||||
mcpConfig.mcpServers = {};
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log('Creating new Cursor MCP config');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add server to config
|
|
||||||
mcpConfig.mcpServers[name] = parsedConfig;
|
|
||||||
|
|
||||||
// Ensure directory exists
|
|
||||||
const mcpDir = path.dirname(mcpPath);
|
|
||||||
await fs.mkdir(mcpDir, { recursive: true });
|
|
||||||
|
|
||||||
// Write updated config
|
|
||||||
await fs.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
|
||||||
|
|
||||||
res.json({
|
|
||||||
success: true,
|
|
||||||
message: `MCP server "${name}" added to Cursor configuration via JSON`,
|
|
||||||
config: mcpConfig
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error adding MCP server to Cursor via JSON:', error);
|
|
||||||
res.status(500).json({
|
|
||||||
error: 'Failed to add MCP server',
|
|
||||||
details: error.message
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// GET /api/cursor/sessions - Get Cursor sessions from SQLite database
|
// GET /api/cursor/sessions - Get Cursor sessions from SQLite database
|
||||||
router.get('/sessions', async (req, res) => {
|
router.get('/sessions', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import type {
|
|||||||
CodexMcpFormState,
|
CodexMcpFormState,
|
||||||
CodeEditorSettingsState,
|
CodeEditorSettingsState,
|
||||||
CursorPermissionsState,
|
CursorPermissionsState,
|
||||||
McpToolsResult,
|
|
||||||
McpTestResult,
|
|
||||||
ProjectSortOrder,
|
ProjectSortOrder,
|
||||||
SettingsMainTab,
|
SettingsMainTab,
|
||||||
} from '../types/types';
|
} from '../types/types';
|
||||||
@@ -33,20 +31,6 @@ export const DEFAULT_CODE_EDITOR_SETTINGS: CodeEditorSettingsState = {
|
|||||||
fontSize: '14',
|
fontSize: '14',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_MCP_TEST_RESULT: McpTestResult = {
|
|
||||||
success: false,
|
|
||||||
message: '',
|
|
||||||
details: [],
|
|
||||||
loading: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const DEFAULT_MCP_TOOLS_RESULT: McpToolsResult = {
|
|
||||||
success: false,
|
|
||||||
tools: [],
|
|
||||||
resources: [],
|
|
||||||
prompts: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
export const DEFAULT_CLAUDE_MCP_FORM: ClaudeMcpFormState = {
|
export const DEFAULT_CLAUDE_MCP_FORM: ClaudeMcpFormState = {
|
||||||
name: '',
|
name: '',
|
||||||
type: 'stdio',
|
type: 'stdio',
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ import type {
|
|||||||
CursorPermissionsState,
|
CursorPermissionsState,
|
||||||
GeminiPermissionMode,
|
GeminiPermissionMode,
|
||||||
McpServer,
|
McpServer,
|
||||||
McpToolsResult,
|
|
||||||
McpTestResult,
|
|
||||||
NotificationPreferencesState,
|
NotificationPreferencesState,
|
||||||
ProjectSortOrder,
|
ProjectSortOrder,
|
||||||
SettingsMainTab,
|
SettingsMainTab,
|
||||||
@@ -58,16 +56,6 @@ type McpCliReadResponse = {
|
|||||||
servers?: McpCliServer[];
|
servers?: McpCliServer[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type McpTestResponse = {
|
|
||||||
testResult?: McpTestResult;
|
|
||||||
error?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type McpToolsResponse = {
|
|
||||||
toolsResult?: McpToolsResult;
|
|
||||||
error?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type ClaudeSettingsStorage = {
|
type ClaudeSettingsStorage = {
|
||||||
allowedTools?: string[];
|
allowedTools?: string[];
|
||||||
disallowedTools?: string[];
|
disallowedTools?: string[];
|
||||||
@@ -205,9 +193,6 @@ export function useSettingsController({ isOpen, initialTab }: UseSettingsControl
|
|||||||
const [mcpServers, setMcpServers] = useState<McpServer[]>([]);
|
const [mcpServers, setMcpServers] = useState<McpServer[]>([]);
|
||||||
const [cursorMcpServers, setCursorMcpServers] = useState<McpServer[]>([]);
|
const [cursorMcpServers, setCursorMcpServers] = useState<McpServer[]>([]);
|
||||||
const [codexMcpServers, setCodexMcpServers] = useState<McpServer[]>([]);
|
const [codexMcpServers, setCodexMcpServers] = useState<McpServer[]>([]);
|
||||||
const [mcpTestResults, setMcpTestResults] = useState<Record<string, McpTestResult>>({});
|
|
||||||
const [mcpServerTools, setMcpServerTools] = useState<Record<string, McpToolsResult>>({});
|
|
||||||
const [mcpToolsLoading, setMcpToolsLoading] = useState<Record<string, boolean>>({});
|
|
||||||
|
|
||||||
const [showMcpForm, setShowMcpForm] = useState(false);
|
const [showMcpForm, setShowMcpForm] = useState(false);
|
||||||
const [editingMcpServer, setEditingMcpServer] = useState<McpServer | null>(null);
|
const [editingMcpServer, setEditingMcpServer] = useState<McpServer | null>(null);
|
||||||
@@ -285,14 +270,7 @@ export function useSettingsController({ isOpen, initialTab }: UseSettingsControl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fallbackResponse = await authenticatedFetch('/api/mcp/servers?scope=user');
|
console.error('Failed to fetch MCP servers');
|
||||||
if (!fallbackResponse.ok) {
|
|
||||||
console.error('Failed to fetch MCP servers');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fallbackData = await toResponseJson<{ servers?: McpServer[] }>(fallbackResponse);
|
|
||||||
setMcpServers(fallbackData.servers || []);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching MCP servers:', error);
|
console.error('Error fetching MCP servers:', error);
|
||||||
}
|
}
|
||||||
@@ -422,76 +400,6 @@ export function useSettingsController({ isOpen, initialTab }: UseSettingsControl
|
|||||||
[deleteMcpServer, fetchMcpServers],
|
[deleteMcpServer, fetchMcpServers],
|
||||||
);
|
);
|
||||||
|
|
||||||
const testMcpServer = useCallback(async (serverId: string, scope = 'user') => {
|
|
||||||
const response = await authenticatedFetch(`/api/mcp/servers/${serverId}/test?scope=${scope}`, {
|
|
||||||
method: 'POST',
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const error = await toResponseJson<McpTestResponse>(response);
|
|
||||||
throw new Error(error.error || 'Failed to test server');
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await toResponseJson<McpTestResponse>(response);
|
|
||||||
return data.testResult || { success: false, message: 'No test result returned' };
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const discoverMcpTools = useCallback(async (serverId: string, scope = 'user') => {
|
|
||||||
const response = await authenticatedFetch(`/api/mcp/servers/${serverId}/tools?scope=${scope}`, {
|
|
||||||
method: 'POST',
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const error = await toResponseJson<McpToolsResponse>(response);
|
|
||||||
throw new Error(error.error || 'Failed to discover tools');
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await toResponseJson<McpToolsResponse>(response);
|
|
||||||
return data.toolsResult || { success: false, tools: [], resources: [], prompts: [] };
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleMcpTest = useCallback(
|
|
||||||
async (serverId: string, scope = 'user') => {
|
|
||||||
try {
|
|
||||||
setMcpTestResults((prev) => ({
|
|
||||||
...prev,
|
|
||||||
[serverId]: { success: false, message: 'Testing server...', details: [], loading: true },
|
|
||||||
}));
|
|
||||||
|
|
||||||
const result = await testMcpServer(serverId, scope);
|
|
||||||
setMcpTestResults((prev) => ({ ...prev, [serverId]: result }));
|
|
||||||
} catch (error) {
|
|
||||||
setMcpTestResults((prev) => ({
|
|
||||||
...prev,
|
|
||||||
[serverId]: {
|
|
||||||
success: false,
|
|
||||||
message: getErrorMessage(error),
|
|
||||||
details: [],
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[testMcpServer],
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleMcpToolsDiscovery = useCallback(
|
|
||||||
async (serverId: string, scope = 'user') => {
|
|
||||||
try {
|
|
||||||
setMcpToolsLoading((prev) => ({ ...prev, [serverId]: true }));
|
|
||||||
const result = await discoverMcpTools(serverId, scope);
|
|
||||||
setMcpServerTools((prev) => ({ ...prev, [serverId]: result }));
|
|
||||||
} catch {
|
|
||||||
setMcpServerTools((prev) => ({
|
|
||||||
...prev,
|
|
||||||
[serverId]: { success: false, tools: [], resources: [], prompts: [] },
|
|
||||||
}));
|
|
||||||
} finally {
|
|
||||||
setMcpToolsLoading((prev) => ({ ...prev, [serverId]: false }));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[discoverMcpTools],
|
|
||||||
);
|
|
||||||
|
|
||||||
const deleteCodexMcpServer = useCallback(async (serverId: string) => {
|
const deleteCodexMcpServer = useCallback(async (serverId: string) => {
|
||||||
const response = await authenticatedFetch(`/api/codex/mcp/cli/remove/${serverId}`, {
|
const response = await authenticatedFetch(`/api/codex/mcp/cli/remove/${serverId}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
@@ -835,17 +743,12 @@ export function useSettingsController({ isOpen, initialTab }: UseSettingsControl
|
|||||||
mcpServers,
|
mcpServers,
|
||||||
cursorMcpServers,
|
cursorMcpServers,
|
||||||
codexMcpServers,
|
codexMcpServers,
|
||||||
mcpTestResults,
|
|
||||||
mcpServerTools,
|
|
||||||
mcpToolsLoading,
|
|
||||||
showMcpForm,
|
showMcpForm,
|
||||||
editingMcpServer,
|
editingMcpServer,
|
||||||
openMcpForm,
|
openMcpForm,
|
||||||
closeMcpForm,
|
closeMcpForm,
|
||||||
submitMcpForm,
|
submitMcpForm,
|
||||||
handleMcpDelete,
|
handleMcpDelete,
|
||||||
handleMcpTest,
|
|
||||||
handleMcpToolsDiscovery,
|
|
||||||
showCodexMcpForm,
|
showCodexMcpForm,
|
||||||
editingCodexMcpServer,
|
editingCodexMcpServer,
|
||||||
openCodexMcpForm,
|
openCodexMcpForm,
|
||||||
|
|||||||
@@ -77,25 +77,6 @@ export type CodexMcpFormState = {
|
|||||||
config: CodexMcpFormConfig;
|
config: CodexMcpFormConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type McpTestResult = {
|
|
||||||
success: boolean;
|
|
||||||
message: string;
|
|
||||||
details?: string[];
|
|
||||||
loading?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type McpTool = {
|
|
||||||
name: string;
|
|
||||||
[key: string]: unknown;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type McpToolsResult = {
|
|
||||||
success?: boolean;
|
|
||||||
tools?: McpTool[];
|
|
||||||
resources?: unknown[];
|
|
||||||
prompts?: unknown[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ClaudePermissionsState = {
|
export type ClaudePermissionsState = {
|
||||||
allowedTools: string[];
|
allowedTools: string[];
|
||||||
disallowedTools: string[];
|
disallowedTools: string[];
|
||||||
|
|||||||
@@ -39,17 +39,12 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'agents' }: Set
|
|||||||
mcpServers,
|
mcpServers,
|
||||||
cursorMcpServers,
|
cursorMcpServers,
|
||||||
codexMcpServers,
|
codexMcpServers,
|
||||||
mcpTestResults,
|
|
||||||
mcpServerTools,
|
|
||||||
mcpToolsLoading,
|
|
||||||
showMcpForm,
|
showMcpForm,
|
||||||
editingMcpServer,
|
editingMcpServer,
|
||||||
openMcpForm,
|
openMcpForm,
|
||||||
closeMcpForm,
|
closeMcpForm,
|
||||||
submitMcpForm,
|
submitMcpForm,
|
||||||
handleMcpDelete,
|
handleMcpDelete,
|
||||||
handleMcpTest,
|
|
||||||
handleMcpToolsDiscovery,
|
|
||||||
showCodexMcpForm,
|
showCodexMcpForm,
|
||||||
editingCodexMcpServer,
|
editingCodexMcpServer,
|
||||||
openCodexMcpForm,
|
openCodexMcpForm,
|
||||||
@@ -159,13 +154,8 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'agents' }: Set
|
|||||||
mcpServers={mcpServers}
|
mcpServers={mcpServers}
|
||||||
cursorMcpServers={cursorMcpServers}
|
cursorMcpServers={cursorMcpServers}
|
||||||
codexMcpServers={codexMcpServers}
|
codexMcpServers={codexMcpServers}
|
||||||
mcpTestResults={mcpTestResults}
|
|
||||||
mcpServerTools={mcpServerTools}
|
|
||||||
mcpToolsLoading={mcpToolsLoading}
|
|
||||||
onOpenMcpForm={openMcpForm}
|
onOpenMcpForm={openMcpForm}
|
||||||
onDeleteMcpServer={handleMcpDelete}
|
onDeleteMcpServer={handleMcpDelete}
|
||||||
onTestMcpServer={handleMcpTest}
|
|
||||||
onDiscoverMcpTools={handleMcpToolsDiscovery}
|
|
||||||
onOpenCodexMcpForm={openCodexMcpForm}
|
onOpenCodexMcpForm={openCodexMcpForm}
|
||||||
onDeleteCodexMcpServer={handleCodexMcpDelete}
|
onDeleteCodexMcpServer={handleCodexMcpDelete}
|
||||||
deleteError={deleteError}
|
deleteError={deleteError}
|
||||||
|
|||||||
@@ -19,14 +19,9 @@ export default function AgentsSettingsTab({
|
|||||||
mcpServers,
|
mcpServers,
|
||||||
cursorMcpServers,
|
cursorMcpServers,
|
||||||
codexMcpServers,
|
codexMcpServers,
|
||||||
mcpTestResults,
|
|
||||||
mcpServerTools,
|
|
||||||
mcpToolsLoading,
|
|
||||||
deleteError,
|
deleteError,
|
||||||
onOpenMcpForm,
|
onOpenMcpForm,
|
||||||
onDeleteMcpServer,
|
onDeleteMcpServer,
|
||||||
onTestMcpServer,
|
|
||||||
onDiscoverMcpTools,
|
|
||||||
onOpenCodexMcpForm,
|
onOpenCodexMcpForm,
|
||||||
onDeleteCodexMcpServer,
|
onDeleteCodexMcpServer,
|
||||||
}: AgentsSettingsTabProps) {
|
}: AgentsSettingsTabProps) {
|
||||||
@@ -87,14 +82,9 @@ export default function AgentsSettingsTab({
|
|||||||
mcpServers={mcpServers}
|
mcpServers={mcpServers}
|
||||||
cursorMcpServers={cursorMcpServers}
|
cursorMcpServers={cursorMcpServers}
|
||||||
codexMcpServers={codexMcpServers}
|
codexMcpServers={codexMcpServers}
|
||||||
mcpTestResults={mcpTestResults}
|
|
||||||
mcpServerTools={mcpServerTools}
|
|
||||||
mcpToolsLoading={mcpToolsLoading}
|
|
||||||
deleteError={deleteError}
|
deleteError={deleteError}
|
||||||
onOpenMcpForm={onOpenMcpForm}
|
onOpenMcpForm={onOpenMcpForm}
|
||||||
onDeleteMcpServer={onDeleteMcpServer}
|
onDeleteMcpServer={onDeleteMcpServer}
|
||||||
onTestMcpServer={onTestMcpServer}
|
|
||||||
onDiscoverMcpTools={onDiscoverMcpTools}
|
|
||||||
onOpenCodexMcpForm={onOpenCodexMcpForm}
|
onOpenCodexMcpForm={onOpenCodexMcpForm}
|
||||||
onDeleteCodexMcpServer={onDeleteCodexMcpServer}
|
onDeleteCodexMcpServer={onDeleteCodexMcpServer}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -16,14 +16,9 @@ export default function AgentCategoryContentSection({
|
|||||||
mcpServers,
|
mcpServers,
|
||||||
cursorMcpServers,
|
cursorMcpServers,
|
||||||
codexMcpServers,
|
codexMcpServers,
|
||||||
mcpTestResults,
|
|
||||||
mcpServerTools,
|
|
||||||
mcpToolsLoading,
|
|
||||||
deleteError,
|
deleteError,
|
||||||
onOpenMcpForm,
|
onOpenMcpForm,
|
||||||
onDeleteMcpServer,
|
onDeleteMcpServer,
|
||||||
onTestMcpServer,
|
|
||||||
onDiscoverMcpTools,
|
|
||||||
onOpenCodexMcpForm,
|
onOpenCodexMcpForm,
|
||||||
onDeleteCodexMcpServer,
|
onDeleteCodexMcpServer,
|
||||||
}: AgentCategoryContentSectionProps) {
|
}: AgentCategoryContentSectionProps) {
|
||||||
@@ -91,11 +86,6 @@ export default function AgentCategoryContentSection({
|
|||||||
onAdd={() => onOpenMcpForm()}
|
onAdd={() => onOpenMcpForm()}
|
||||||
onEdit={(server) => onOpenMcpForm(server)}
|
onEdit={(server) => onOpenMcpForm(server)}
|
||||||
onDelete={onDeleteMcpServer}
|
onDelete={onDeleteMcpServer}
|
||||||
onTest={onTestMcpServer}
|
|
||||||
onDiscoverTools={onDiscoverMcpTools}
|
|
||||||
testResults={mcpTestResults}
|
|
||||||
serverTools={mcpServerTools}
|
|
||||||
toolsLoading={mcpToolsLoading}
|
|
||||||
deleteError={deleteError}
|
deleteError={deleteError}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { Badge, Button } from '../../../../../../../shared/view/ui';
|
import { Badge, Button } from '../../../../../../../shared/view/ui';
|
||||||
import { IS_PLATFORM } from '../../../../../../../constants/config';
|
import { IS_PLATFORM } from '../../../../../../../constants/config';
|
||||||
import PremiumFeatureCard from '../../../../PremiumFeatureCard';
|
import PremiumFeatureCard from '../../../../PremiumFeatureCard';
|
||||||
import type { McpServer, McpToolsResult, McpTestResult } from '../../../../../types/types';
|
import type { McpServer } from '../../../../../types/types';
|
||||||
|
|
||||||
const getTransportIcon = (type: string | undefined) => {
|
const getTransportIcon = (type: string | undefined) => {
|
||||||
if (type === 'stdio') {
|
if (type === 'stdio') {
|
||||||
@@ -36,11 +36,6 @@ type ClaudeMcpServersProps = {
|
|||||||
onAdd: () => void;
|
onAdd: () => void;
|
||||||
onEdit: (server: McpServer) => void;
|
onEdit: (server: McpServer) => void;
|
||||||
onDelete: (serverId: string, scope?: string) => void;
|
onDelete: (serverId: string, scope?: string) => void;
|
||||||
onTest: (serverId: string, scope?: string) => void;
|
|
||||||
onDiscoverTools: (serverId: string, scope?: string) => void;
|
|
||||||
testResults: Record<string, McpTestResult>;
|
|
||||||
serverTools: Record<string, McpToolsResult>;
|
|
||||||
toolsLoading: Record<string, boolean>;
|
|
||||||
deleteError?: string | null;
|
deleteError?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,10 +44,8 @@ function ClaudeMcpServers({
|
|||||||
onAdd,
|
onAdd,
|
||||||
onEdit,
|
onEdit,
|
||||||
onDelete,
|
onDelete,
|
||||||
testResults,
|
|
||||||
serverTools,
|
|
||||||
deleteError,
|
deleteError,
|
||||||
}: Omit<ClaudeMcpServersProps, 'agent' | 'onTest' | 'onDiscoverTools' | 'toolsLoading'>) {
|
}: Omit<ClaudeMcpServersProps, 'agent'>) {
|
||||||
const { t } = useTranslation('settings');
|
const { t } = useTranslation('settings');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -78,8 +71,6 @@ function ClaudeMcpServers({
|
|||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{servers.map((server) => {
|
{servers.map((server) => {
|
||||||
const serverId = server.id || server.name;
|
const serverId = server.id || server.name;
|
||||||
const testResult = testResults[serverId];
|
|
||||||
const toolsResult = serverTools[serverId];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={serverId} className="rounded-lg border border-border bg-card/50 p-4">
|
<div key={serverId} className="rounded-lg border border-border bg-card/50 p-4">
|
||||||
@@ -121,36 +112,6 @@ function ClaudeMcpServers({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{testResult && (
|
|
||||||
<div className={`mt-2 rounded p-2 text-xs ${
|
|
||||||
testResult.success
|
|
||||||
? 'bg-green-50 text-green-800 dark:bg-green-900/20 dark:text-green-200'
|
|
||||||
: 'bg-red-50 text-red-800 dark:bg-red-900/20 dark:text-red-200'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<div className="font-medium">{testResult.message}</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{toolsResult && toolsResult.tools && toolsResult.tools.length > 0 && (
|
|
||||||
<div className="mt-2 rounded bg-blue-50 p-2 text-xs text-blue-800 dark:bg-blue-900/20 dark:text-blue-200">
|
|
||||||
<div className="font-medium">
|
|
||||||
{t('mcpServers.tools.title')} {t('mcpServers.tools.count', { count: toolsResult.tools.length })}
|
|
||||||
</div>
|
|
||||||
<div className="mt-1 flex flex-wrap gap-1">
|
|
||||||
{toolsResult.tools.slice(0, 5).map((tool, index) => (
|
|
||||||
<code key={`${tool.name}-${index}`} className="rounded bg-blue-100 px-1 dark:bg-blue-800">
|
|
||||||
{tool.name}
|
|
||||||
</code>
|
|
||||||
))}
|
|
||||||
{toolsResult.tools.length > 5 && (
|
|
||||||
<span className="text-xs opacity-75">
|
|
||||||
{t('mcpServers.tools.more', { count: toolsResult.tools.length - 5 })}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="ml-4 flex items-center gap-2">
|
<div className="ml-4 flex items-center gap-2">
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import type {
|
|||||||
CodexPermissionMode,
|
CodexPermissionMode,
|
||||||
GeminiPermissionMode,
|
GeminiPermissionMode,
|
||||||
McpServer,
|
McpServer,
|
||||||
McpToolsResult,
|
|
||||||
McpTestResult,
|
|
||||||
} from '../../../types/types';
|
} from '../../../types/types';
|
||||||
|
|
||||||
export type AgentContext = {
|
export type AgentContext = {
|
||||||
@@ -33,14 +31,9 @@ export type AgentsSettingsTabProps = {
|
|||||||
mcpServers: McpServer[];
|
mcpServers: McpServer[];
|
||||||
cursorMcpServers: McpServer[];
|
cursorMcpServers: McpServer[];
|
||||||
codexMcpServers: McpServer[];
|
codexMcpServers: McpServer[];
|
||||||
mcpTestResults: Record<string, McpTestResult>;
|
|
||||||
mcpServerTools: Record<string, McpToolsResult>;
|
|
||||||
mcpToolsLoading: Record<string, boolean>;
|
|
||||||
deleteError: string | null;
|
deleteError: string | null;
|
||||||
onOpenMcpForm: (server?: McpServer) => void;
|
onOpenMcpForm: (server?: McpServer) => void;
|
||||||
onDeleteMcpServer: (serverId: string, scope?: string) => void;
|
onDeleteMcpServer: (serverId: string, scope?: string) => void;
|
||||||
onTestMcpServer: (serverId: string, scope?: string) => void;
|
|
||||||
onDiscoverMcpTools: (serverId: string, scope?: string) => void;
|
|
||||||
onOpenCodexMcpForm: (server?: McpServer) => void;
|
onOpenCodexMcpForm: (server?: McpServer) => void;
|
||||||
onDeleteCodexMcpServer: (serverId: string) => void;
|
onDeleteCodexMcpServer: (serverId: string) => void;
|
||||||
};
|
};
|
||||||
@@ -71,14 +64,9 @@ export type AgentCategoryContentSectionProps = {
|
|||||||
mcpServers: McpServer[];
|
mcpServers: McpServer[];
|
||||||
cursorMcpServers: McpServer[];
|
cursorMcpServers: McpServer[];
|
||||||
codexMcpServers: McpServer[];
|
codexMcpServers: McpServer[];
|
||||||
mcpTestResults: Record<string, McpTestResult>;
|
|
||||||
mcpServerTools: Record<string, McpToolsResult>;
|
|
||||||
mcpToolsLoading: Record<string, boolean>;
|
|
||||||
deleteError: string | null;
|
deleteError: string | null;
|
||||||
onOpenMcpForm: (server?: McpServer) => void;
|
onOpenMcpForm: (server?: McpServer) => void;
|
||||||
onDeleteMcpServer: (serverId: string, scope?: string) => void;
|
onDeleteMcpServer: (serverId: string, scope?: string) => void;
|
||||||
onTestMcpServer: (serverId: string, scope?: string) => void;
|
|
||||||
onDiscoverMcpTools: (serverId: string, scope?: string) => void;
|
|
||||||
onOpenCodexMcpForm: (server?: McpServer) => void;
|
onOpenCodexMcpForm: (server?: McpServer) => void;
|
||||||
onDeleteCodexMcpServer: (serverId: string) => void;
|
onDeleteCodexMcpServer: (serverId: string) => void;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user