import { VSCodeButton, VSCodeLink, VSCodePanels, VSCodePanelTab, VSCodePanelView, } from "@vscode/webview-ui-toolkit/react" import { useState } from "react" import { vscode } from "../../utils/vscode" import { useExtensionState } from "../../context/ExtensionStateContext" import { McpServer } from "../../../../src/shared/mcp" import McpToolRow from "./McpToolRow" import McpResourceRow from "./McpResourceRow" import McpEnabledToggle from "./McpEnabledToggle" type McpViewProps = { onDone: () => void } const McpView = ({ onDone }: McpViewProps) => { const { mcpServers: servers, alwaysAllowMcp, mcpEnabled } = useExtensionState() // const [servers, setServers] = useState([ // // Add some mock servers for testing // { // name: "local-tools", // config: JSON.stringify({ // mcpServers: { // "local-tools": { // command: "npx", // args: ["-y", "@modelcontextprotocol/server-tools"], // }, // }, // }), // status: "connected", // tools: [ // { // name: "execute_command", // description: "Run a shell command on the local system", // }, // { // name: "read_file", // description: "Read contents of a file from the filesystem", // }, // ], // }, // { // name: "postgres-db", // config: JSON.stringify({ // mcpServers: { // "postgres-db": { // command: "npx", // args: ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"], // }, // }, // }), // status: "disconnected", // error: "Failed to connect to database: Connection refused", // }, // { // name: "github-tools", // config: JSON.stringify({ // mcpServers: { // "github-tools": { // command: "npx", // args: ["-y", "@modelcontextprotocol/server-github"], // }, // }, // }), // status: "connecting", // resources: [ // { // uri: "github://repo/issues", // name: "Repository Issues", // }, // { // uri: "github://repo/pulls", // name: "Pull Requests", // }, // ], // }, // ]) return (

MCP Servers

Done
The{" "} Model Context Protocol {" "} enables communication with locally running MCP servers that provide additional tools and resources to extend Cline's capabilities. You can use{" "} community-made servers {" "} or ask Cline to create new tools specific to your workflow (e.g., "add a tool that gets the latest npm docs").
{mcpEnabled && ( <> {/* Server List */} {servers.length > 0 && (
{servers.map((server) => ( ))}
)} {/* Edit Settings Button */}
{ vscode.postMessage({ type: "openMcpSettings" }) }}> Edit MCP Settings
)} {/* Bottom padding */}
) } // Server Row Component const ServerRow = ({ server, alwaysAllowMcp }: { server: McpServer, alwaysAllowMcp?: boolean }) => { const [isExpanded, setIsExpanded] = useState(false) const getStatusColor = () => { switch (server.status) { case "connected": return "var(--vscode-testing-iconPassed)" case "connecting": return "var(--vscode-charts-yellow)" case "disconnected": return "var(--vscode-testing-iconFailed)" } } const handleRowClick = () => { if (!server.error) { setIsExpanded(!isExpanded) } } const handleRestart = () => { vscode.postMessage({ type: "restartMcpServer", text: server.name, }) } return (
{!server.error && ( )} {server.name}
e.stopPropagation()}>
{ vscode.postMessage({ type: "toggleMcpServer", serverName: server.name, disabled: !server.disabled }); }} onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); vscode.postMessage({ type: "toggleMcpServer", serverName: server.name, disabled: !server.disabled }); } }} >
{server.error ? (
{server.error}
{server.status === "connecting" ? "Retrying..." : "Retry Connection"}
) : ( isExpanded && (
Tools ({server.tools?.length || 0}) Resources ( {[...(server.resourceTemplates || []), ...(server.resources || [])].length || 0}) {server.tools && server.tools.length > 0 ? (
{server.tools.map((tool) => ( ))}
) : (
No tools found
)}
{(server.resources && server.resources.length > 0) || (server.resourceTemplates && server.resourceTemplates.length > 0) ? (
{[...(server.resourceTemplates || []), ...(server.resources || [])].map( (item) => ( ), )}
) : (
No resources found
)}
{server.status === "connecting" ? "Restarting..." : "Restart Server"}
) )}
) } export default McpView