@@ -38,6 +38,20 @@ type Store interface {
3838 UpdateMessage (ctx context.Context , chatID string , message models.Message ) error
3939}
4040
41+ // MCPClient defines the interface for interacting with an MCP server.
42+ // This allows for mocking in tests.
43+ type MCPClient interface {
44+ ServerInfo () mcp.Info
45+ ToolServerSupported () bool
46+ ResourceServerSupported () bool
47+ PromptServerSupported () bool
48+ ListTools (ctx context.Context , params mcp.ListToolsParams ) (mcp.ListToolsResult , error )
49+ ListResources (ctx context.Context , params mcp.ListResourcesParams ) (mcp.ListResourcesResult , error )
50+ ListPrompts (ctx context.Context , params mcp.ListPromptsParams ) (mcp.ListPromptResult , error )
51+ GetPrompt (ctx context.Context , params mcp.GetPromptParams ) (mcp.GetPromptResult , error )
52+ CallTool (ctx context.Context , params mcp.CallToolParams ) (mcp.CallToolResult , error )
53+ }
54+
4155// Main handles the core functionality of the chat application, managing server-sent events,
4256// HTML templates, and interactions between the LLM and Store components.
4357type Main struct {
@@ -48,7 +62,7 @@ type Main struct {
4862 titleGenerator TitleGenerator
4963 store Store
5064
51- mcpClients []* mcp. Client
65+ mcpClients []MCPClient
5266
5367 servers []mcp.Info
5468 tools []mcp.Tool
@@ -73,7 +87,7 @@ func NewMain(
7387 llm LLM ,
7488 titleGen TitleGenerator ,
7589 store Store ,
76- mcpClients []* mcp. Client ,
90+ mcpClients []MCPClient ,
7791 logger * slog.Logger ,
7892) (Main , error ) {
7993 // We parse templates from three distinct directories to separate layout, pages, and partial views
0 commit comments