Skip to main content
Glama
mcp_message_handler.go1.47 kB
package tui import ( tea "github.com/charmbracelet/bubbletea" ) // MCPMessageHandler handles MCP-related messages type MCPMessageHandler struct{} // NewMCPMessageHandler creates a new MCP message handler func NewMCPMessageHandler() MessageHandler { return &MCPMessageHandler{} } // CanHandle checks if this handler can process the message func (h *MCPMessageHandler) CanHandle(msg tea.Msg) bool { switch msg.(type) { case mcpConnectionMsg, mcpRequestMsg, mcpResponseMsg, mcpErrorMsg: return true default: return false } } // HandleMessage processes MCP-related messages func (h *MCPMessageHandler) HandleMessage(msg tea.Msg, model *Model) (tea.Model, tea.Cmd) { var cmds []tea.Cmd switch m := msg.(type) { case mcpConnectionMsg: // Handle MCP connection status change if model.mcpDebugController != nil { model.mcpDebugController.HandleConnection(m) if model.currentView() == ViewMCPConnections { model.mcpDebugController.UpdateConnectionsList() } } cmds = append(cmds, model.waitForUpdates()) case mcpRequestMsg: // Handle MCP request - placeholder for future implementation cmds = append(cmds, model.waitForUpdates()) case mcpResponseMsg: // Handle MCP response - placeholder for future implementation cmds = append(cmds, model.waitForUpdates()) case mcpErrorMsg: // Handle MCP error - placeholder for future implementation cmds = append(cmds, model.waitForUpdates()) } return model, tea.Batch(cmds...) }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/standardbeagle/brummer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server