mirror of
https://github.com/andrepimenta/claude-code-chat.git
synced 2025-12-13 05:39:46 +00:00
Showing mcp servers
This commit is contained in:
@@ -1464,7 +1464,7 @@ class ClaudeChatProvider {
|
|||||||
try {
|
try {
|
||||||
const mcpConfigPath = this.getMCPConfigPath();
|
const mcpConfigPath = this.getMCPConfigPath();
|
||||||
if (!mcpConfigPath) {
|
if (!mcpConfigPath) {
|
||||||
this._sendAndSaveMessage({ type: 'mcpServers', data: {} });
|
this._postMessage({ type: 'mcpServers', data: {} });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1474,7 +1474,8 @@ class ClaudeChatProvider {
|
|||||||
try {
|
try {
|
||||||
const content = await vscode.workspace.fs.readFile(mcpConfigUri);
|
const content = await vscode.workspace.fs.readFile(mcpConfigUri);
|
||||||
mcpConfig = JSON.parse(new TextDecoder().decode(content));
|
mcpConfig = JSON.parse(new TextDecoder().decode(content));
|
||||||
} catch {
|
} catch (error) {
|
||||||
|
console.log('MCP config file not found or error reading:', error);
|
||||||
// File doesn't exist, return empty servers
|
// File doesn't exist, return empty servers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
src/ui.ts
22
src/ui.ts
@@ -1716,24 +1716,34 @@ const html = `<!DOCTYPE html>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [name, config] of Object.entries(servers)) {
|
for (const [name, config] of Object.entries(servers)) {
|
||||||
const serverItem = document.createElement('div');
|
const serverItem = document.createElement('div');
|
||||||
serverItem.className = 'mcp-server-item';
|
serverItem.className = 'mcp-server-item';
|
||||||
|
|
||||||
|
// Defensive check for config structure
|
||||||
|
if (!config || typeof config !== 'object') {
|
||||||
|
console.error('Invalid config for server:', name, config);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const serverType = config.type || 'stdio';
|
||||||
let configDisplay = '';
|
let configDisplay = '';
|
||||||
if (config.type === 'stdio') {
|
|
||||||
configDisplay = \`Command: \${config.command}\`;
|
if (serverType === 'stdio') {
|
||||||
if (config.args) {
|
configDisplay = \`Command: \${config.command || 'Not specified'}\`;
|
||||||
|
if (config.args && Array.isArray(config.args)) {
|
||||||
configDisplay += \`<br>Args: \${config.args.join(' ')}\`;
|
configDisplay += \`<br>Args: \${config.args.join(' ')}\`;
|
||||||
}
|
}
|
||||||
|
} else if (serverType === 'http' || serverType === 'sse') {
|
||||||
|
configDisplay = \`URL: \${config.url || 'Not specified'}\`;
|
||||||
} else {
|
} else {
|
||||||
configDisplay = \`URL: \${config.url}\`;
|
configDisplay = \`Type: \${serverType}\`;
|
||||||
}
|
}
|
||||||
|
|
||||||
serverItem.innerHTML = \`
|
serverItem.innerHTML = \`
|
||||||
<div class="server-info">
|
<div class="server-info">
|
||||||
<div class="server-name">\${name}</div>
|
<div class="server-name">\${name}</div>
|
||||||
<div class="server-type">\${config.type.toUpperCase()}</div>
|
<div class="server-type">\${serverType.toUpperCase()}</div>
|
||||||
<div class="server-config">\${configDisplay}</div>
|
<div class="server-config">\${configDisplay}</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn outlined server-delete-btn" onclick="deleteMCPServer('\${name}')">Delete</button>
|
<button class="btn outlined server-delete-btn" onclick="deleteMCPServer('\${name}')">Delete</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user