mcp

package
v0.0.0-...-8acab51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package mcp implements a Model Context Protocol (MCP) server. It exposes Blue's tools and skills to external agents via JSON-RPC over SSE transport.

Index

Constants

View Source
const (
	ProtocolVersion = "2024-11-05"
	ServerName      = "blue-mcp"
	ServerVersion   = buildinfo.Version
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler provides HTTP endpoints for the MCP server.

func NewHandler

func NewHandler(server *Server) *Handler

NewHandler creates a new MCP HTTP handler.

func (*Handler) Message

func (h *Handler) Message(c echo.Context) error

Message handles POST /api/v1/mcp/message — JSON-RPC from client→server.

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(g *echo.Group)

RegisterRoutes registers MCP routes.

func (*Handler) SSE

func (h *Handler) SSE(c echo.Context) error

SSE handles GET /api/v1/mcp/sse — SSE stream for server→client messages.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the MCP protocol server.

func NewServer

func NewServer(registry *tools.Registry, executor *tools.Executor) *Server

NewServer creates a new MCP server.

func (*Server) Close

func (s *Server) Close()

Close gracefully shuts down the server, closing all active sessions.

func (*Server) CreateSession

func (s *Server) CreateSession() *Session

CreateSession creates a new client session.

func (*Server) HandleMessage

func (s *Server) HandleMessage(ctx context.Context, sessionID string, raw []byte) ([]byte, error)

HandleMessage processes a JSON-RPC message from a client.

func (*Server) RemoveSession

func (s *Server) RemoveSession(id string)

RemoveSession removes a client session.

func (*Server) SendToSession

func (s *Server) SendToSession(sessionID string, data []byte)

SendToSession sends a message to a specific session's SSE stream.

func (*Server) SetGenerativeRunner

func (s *Server) SetGenerativeRunner(fn func(ctx context.Context, prompt string, maxTokens int) (string, error))

SetGenerativeRunner sets the optional LLM subtask runner used by orchestrator.run.

func (*Server) SetToolCallTimeout

func (s *Server) SetToolCallTimeout(d time.Duration)

SetToolCallTimeout overrides the default tool call timeout.

func (*Server) SetWorkspace

func (s *Server) SetWorkspace(w WorkspaceReader)

SetWorkspace sets the workspace reader for MCP resource access.

func (*Server) SetWorkspaceRoot

func (s *Server) SetWorkspaceRoot(dir string)

SetWorkspaceRoot sets the root directory used by built-in workspace coding tools. Relative paths are resolved against the current process working directory.

type Session

type Session struct {
	ID       string
	Messages chan []byte // outbound messages (server → client)
	// contains filtered or unexported fields
}

Session represents an MCP client session.

func (*Session) Close

func (s *Session) Close()

type WorkspaceReader

type WorkspaceReader interface {
	LoadContextFiles() map[string]string
}

WorkspaceReader provides read access to workspace files for MCP resources.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL