Skip to content

feat(agentic chat): add components and types for server management - wip #7577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions lib/shared/src/llm-providers/mcp/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { Tool } from '@anthropic-ai/sdk/resources/beta/tools/messages.mjs'

export interface McpTool extends Tool {
autoApprove?: boolean
}

// Define types for MCP entities
export interface McpServer {
name: string
config: string
status: 'connecting' | 'connected' | 'disconnected'
disabled?: boolean
error?: string
tools?: McpTool[]
resources?: McpResource[]
resourceTemplates?: McpResourceTemplate[]
}

export interface McpResource {
uri: string
mimeType?: string
title?: string
description?: string
}

export interface McpResourceTemplate extends McpResource {
type: 'template'
}

export interface McpResourceResponse {
content: any
}

export interface McpToolCallResponse {
result: any
}
4 changes: 4 additions & 0 deletions lib/shared/src/misc/rpc/webviewAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ChatMessage, UserLocalHistory } from '../../chat/transcript/messag
import type { ContextItem, DefaultContext } from '../../codebase-context/messages'
import type { CodyCommand } from '../../commands/types'
import type { FeatureFlag } from '../../experimentation/FeatureFlagProvider'
import type { McpServer } from '../../llm-providers/mcp/types'
import type { ContextMentionProviderMetadata } from '../../mentions/api'
import type { MentionQuery } from '../../mentions/query'
import type { Model } from '../../models/model'
Expand Down Expand Up @@ -103,6 +104,8 @@ export interface WebviewToExtensionAPI {
* The current user's product subscription information (Cody Free/Pro).
*/
userProductSubscription(): Observable<UserProductSubscription | null>

mcpSettings(): Observable<McpServer[] | null>
}

export function createExtensionAPI(
Expand Down Expand Up @@ -152,6 +155,7 @@ export function createExtensionAPI(
userHistory: proxyExtensionAPI(messageAPI, 'userHistory'),
userProductSubscription: proxyExtensionAPI(messageAPI, 'userProductSubscription'),
repos: proxyExtensionAPI(messageAPI, 'repos'),
mcpSettings: proxyExtensionAPI(messageAPI, 'mcpSettings'),
}
}

Expand Down
7 changes: 7 additions & 0 deletions vscode/src/chat/chat-view/ChatController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ import { getChatPanelTitle, isAgentTesting } from './chat-helpers'
import { OmniboxTelemetry } from './handlers/OmniboxTelemetry'
import { getAgent, getAgentName } from './handlers/registry'
import { getPromptsMigrationInfo, startPromptsMigration } from './prompts-migration'
import { MCPManager } from './tools/mcp'

export interface ChatControllerOptions {
extensionUri: vscode.Uri
Expand Down Expand Up @@ -1672,6 +1673,12 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv
userProductSubscription.pipe(
map(value => (value === pendingOperation ? null : value))
),
// Existing tools endpoint - update to include MCP tools
mcpSettings: () =>
MCPManager.observable.pipe(
startWith(null),
map(servers => servers)
),
}
)
)
Expand Down
Loading
Loading