Merge pull request #286 from mzubair481/feature/mcp-server-support

feat: add MCP server support
This commit is contained in:
Web Dev Cody
2025-12-28 22:42:12 -05:00
committed by GitHub
45 changed files with 3628 additions and 44 deletions

View File

@@ -13,6 +13,10 @@ export type {
InstallationStatus,
ValidationResult,
ModelDefinition,
McpServerConfig,
McpStdioServerConfig,
McpSSEServerConfig,
McpHttpServerConfig,
} from './provider.js';
// Feature types
@@ -54,6 +58,8 @@ export type {
ModelProvider,
KeyboardShortcuts,
AIProfile,
MCPToolInfo,
MCPServerConfig,
ProjectRef,
TrashedProjectRef,
ChatSessionRef,

View File

@@ -28,6 +28,38 @@ export interface SystemPromptPreset {
append?: string;
}
/**
* MCP server configuration types for SDK options
* Matches the Claude Agent SDK's McpServerConfig types
*/
export type McpServerConfig = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig;
/**
* Stdio-based MCP server (subprocess)
* Note: `type` is optional and defaults to 'stdio' to match SDK behavior
* and allow simpler configs like { command: "node", args: ["server.js"] }
*/
export interface McpStdioServerConfig {
type?: 'stdio';
command: string;
args?: string[];
env?: Record<string, string>;
}
/** SSE-based MCP server */
export interface McpSSEServerConfig {
type: 'sse';
url: string;
headers?: Record<string, string>;
}
/** HTTP-based MCP server */
export interface McpHttpServerConfig {
type: 'http';
url: string;
headers?: Record<string, string>;
}
/**
* Options for executing a query via a provider
*/
@@ -38,7 +70,9 @@ export interface ExecuteOptions {
systemPrompt?: string | SystemPromptPreset;
maxTurns?: number;
allowedTools?: string[];
mcpServers?: Record<string, unknown>;
mcpServers?: Record<string, McpServerConfig>;
mcpAutoApproveTools?: boolean; // Auto-approve MCP tool calls without permission prompts
mcpUnrestrictedTools?: boolean; // Allow unrestricted tools when MCP servers are enabled
abortController?: AbortController;
conversationHistory?: ConversationMessage[]; // Previous messages for context
sdkSessionId?: string; // Claude SDK session ID for resuming conversations

View File

@@ -163,6 +163,55 @@ export interface AIProfile {
icon?: string;
}
/**
* MCPToolInfo - Information about a tool provided by an MCP server
*
* Contains the tool's name, description, and whether it's enabled for use.
*/
export interface MCPToolInfo {
/** Tool name as exposed by the MCP server */
name: string;
/** Description of what the tool does */
description?: string;
/** JSON Schema for the tool's input parameters */
inputSchema?: Record<string, unknown>;
/** Whether this tool is enabled for use (defaults to true) */
enabled: boolean;
}
/**
* MCPServerConfig - Configuration for an MCP (Model Context Protocol) server
*
* MCP servers provide additional tools and capabilities to AI agents.
* Supports stdio (subprocess), SSE, and HTTP transport types.
*/
export interface MCPServerConfig {
/** Unique identifier for the server config */
id: string;
/** Display name for the server */
name: string;
/** User-friendly description of what this server provides */
description?: string;
/** Transport type: stdio (default), sse, or http */
type?: 'stdio' | 'sse' | 'http';
/** For stdio: command to execute (e.g., 'node', 'python', 'npx') */
command?: string;
/** For stdio: arguments to pass to the command */
args?: string[];
/** For stdio: environment variables to set */
env?: Record<string, string>;
/** For sse/http: URL endpoint */
url?: string;
/** For sse/http: headers to include in requests */
headers?: Record<string, string>;
/** Whether this server is enabled */
enabled?: boolean;
/** Tools discovered from this server with their enabled states */
tools?: MCPToolInfo[];
/** Timestamp when tools were last fetched */
toolsLastFetched?: string;
}
/**
* ProjectRef - Minimal reference to a project stored in global settings
*
@@ -303,6 +352,14 @@ export interface GlobalSettings {
autoLoadClaudeMd?: boolean;
/** Enable sandbox mode for bash commands (default: true, disable if issues occur) */
enableSandboxMode?: boolean;
// MCP Server Configuration
/** List of configured MCP servers for agent use */
mcpServers: MCPServerConfig[];
/** Auto-approve MCP tool calls without permission prompts (uses bypassPermissions mode) */
mcpAutoApproveTools?: boolean;
/** Allow unrestricted tools when MCP servers are enabled (don't filter allowedTools) */
mcpUnrestrictedTools?: boolean;
}
/**
@@ -462,6 +519,11 @@ export const DEFAULT_GLOBAL_SETTINGS: GlobalSettings = {
lastSelectedSessionByProject: {},
autoLoadClaudeMd: false,
enableSandboxMode: true,
mcpServers: [],
// Default to true for autonomous workflow. Security is enforced when adding servers
// via the security warning dialog that explains the risks.
mcpAutoApproveTools: true,
mcpUnrestrictedTools: true,
};
/** Default credentials (empty strings - user must provide API keys) */