feat: add MCP types and HTTP client methods

This commit is contained in:
Mark IJbema
2026-02-12 11:37:33 +01:00
parent 7606f30e41
commit de20f2c5ce
3 changed files with 67 additions and 0 deletions
@@ -7,6 +7,8 @@ import type {
ProfileData,
ProviderAuthAuthorization,
ProviderListResponse,
McpStatus,
McpConfig,
} from "./types"
/**
@@ -303,4 +305,36 @@ export class HttpClient {
async oauthCallback(providerId: string, method: number, directory: string): Promise<boolean> {
return this.request<boolean>("POST", `/provider/${providerId}/oauth/callback`, { method }, { directory })
}
// ============================================
// MCP Methods
// ============================================
/**
* Get the status of all MCP servers.
*/
async getMcpStatus(): Promise<Record<string, McpStatus>> {
return this.request<Record<string, McpStatus>>("GET", "/mcp")
}
/**
* Add or update an MCP server configuration.
*/
async addMcpServer(name: string, config: McpConfig): Promise<Record<string, McpStatus>> {
return this.request<Record<string, McpStatus>>("POST", "/mcp", { name, config })
}
/**
* Connect an MCP server by name.
*/
async connectMcpServer(name: string): Promise<boolean> {
return this.request<boolean>("POST", `/mcp/${encodeURIComponent(name)}/connect`)
}
/**
* Disconnect an MCP server by name.
*/
async disconnectMcpServer(name: string): Promise<boolean> {
return this.request<boolean>("POST", `/mcp/${encodeURIComponent(name)}/disconnect`)
}
}
@@ -21,6 +21,10 @@ export type {
Provider,
ProviderListResponse,
ModelSelection,
McpStatus,
McpLocalConfig,
McpRemoteConfig,
McpConfig,
} from "./types"
export { ServerManager } from "./server-manager"
@@ -169,3 +169,32 @@ export interface ProfileData {
balance: KilocodeBalance | null
currentOrgId: string | null
}
// MCP server status — discriminated union returned by the backend
export type McpStatus =
| { status: "connected" }
| { status: "disabled" }
| { status: "failed"; error: string }
| { status: "needs_auth" }
| { status: "needs_client_registration"; error: string }
// MCP server configuration for local (stdio) servers
export interface McpLocalConfig {
type: "local"
command: string[]
environment?: Record<string, string>
enabled?: boolean
timeout?: number
}
// MCP server configuration for remote (SSE) servers
export interface McpRemoteConfig {
type: "remote"
url: string
enabled?: boolean
headers?: Record<string, string>
timeout?: number
}
// Union of all MCP server config types
export type McpConfig = McpLocalConfig | McpRemoteConfig