Documentation
¶
Overview ¶
Package mcp implements the Model Context Protocol JSON-RPC 2.0 server for BubbleFish Nexus. It exposes three tools -- nexus_write, nexus_search, and nexus_status -- to MCP clients (Claude Desktop, Cursor, etc.) via an HTTP server bound exclusively to 127.0.0.1.
All tool calls route through the internal Pipeline interface, which applies the same auth, policy, WAL, and queue semantics as the HTTP handlers. MCP calls NEVER go through HTTP round-trips.
Reference: Tech Spec Section 14.3.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerRegistrar ¶
HandlerRegistrar registers additional HTTP handlers on the MCP mux. Satisfied by *oauth.OAuthServer.
type JWTValidator ¶
JWTValidator validates JWT access tokens. When non-nil on the Server, authenticate() will accept valid JWTs in addition to static bfn_mcp_ keys.
type Pipeline ¶
type Pipeline interface {
// Write persists content through the WAL -> queue -> destination pipeline.
// Returns a WriteResult containing the assigned payload_id on success.
Write(ctx context.Context, params WriteParams) (WriteResult, error)
// Search executes the 6-stage retrieval cascade and returns matching records.
Search(ctx context.Context, params SearchParams) (SearchResult, error)
// Status returns the current daemon health and queue state.
Status(ctx context.Context) (StatusResult, error)
}
Pipeline is the internal interface the MCP server uses to route tool calls through the daemon write/query pipeline. Implementations MUST apply the same WAL, queue, policy, and idempotency semantics as the HTTP handlers.
Reference: Tech Spec Section 14.3 -- "Internal pipeline -- not HTTP round-trip."
type SearchParams ¶
type SearchParams struct {
// Source is the source name resolved from MCPConfig.SourceName.
Source string
// Q is a free-text content filter (optional).
Q string
// Destination is the target destination name (optional).
Destination string
// Subject is a subject filter (optional; empty means all subjects).
Subject string
// Limit is the maximum number of results to return (optional; 0 -> default 20).
Limit int
// Profile is the retrieval profile: "fast", "balanced", or "deep" (optional).
Profile string
}
SearchParams are the input parameters for the nexus_search tool.
type SearchResult ¶
type SearchResult struct {
Records []destination.TranslatedPayload `json:"records"`
HasMore bool `json:"has_more"`
NextCursor string `json:"next_cursor,omitempty"`
RetrievalStage int `json:"retrieval_stage"`
}
SearchResult is the output of the nexus_search tool.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) SetOAuthHandlers ¶
func (s *Server) SetOAuthHandlers(reg HandlerRegistrar)
SetOAuthHandlers configures an optional handler registrar for OAuth HTTP endpoints. Must be called before Start(). The registrar's RegisterHandlers method will be called on the MCP server's HTTP mux.
func (*Server) SetOAuthIssuerURL ¶
SetOAuthIssuerURL sets the OAuth issuer URL used in WWW-Authenticate headers on 401 responses. Must be called before Start() when OAuth is enabled.
func (*Server) SetOAuthServer ¶
func (s *Server) SetOAuthServer(v JWTValidator)
SetOAuthServer configures an optional JWT validator for OAuth access tokens. When set, authenticate() accepts valid JWTs in addition to static bfn_mcp_ keys. Pass nil to disable JWT authentication.
type StatusResult ¶
type StatusResult struct {
Status string `json:"status"`
Version string `json:"version"`
QueueDepth int `json:"queue_depth"`
}
StatusResult is the output of the nexus_status tool.
type TestPipeline ¶
type TestPipeline struct{}
TestPipeline is a no-op Pipeline implementation that returns canned responses. Used by `bubblefish mcp test` and unit tests that need a Pipeline without a running daemon.
func (*TestPipeline) Search ¶
func (p *TestPipeline) Search(_ context.Context, _ SearchParams) (SearchResult, error)
Search returns an empty result set without touching any storage.
func (*TestPipeline) Status ¶
func (p *TestPipeline) Status(_ context.Context) (StatusResult, error)
Status returns a canned "ok" status without querying the daemon.
func (*TestPipeline) Write ¶
func (p *TestPipeline) Write(_ context.Context, _ WriteParams) (WriteResult, error)
Write returns a canned acceptance response without touching any storage.
type WriteParams ¶
type WriteParams struct {
// Source is the source name resolved from MCPConfig.SourceName. Set by the
// server before calling pipeline.Write -- never supplied by the MCP client.
Source string
// Content is the memory text to persist (required).
Content string
// Subject is the subject namespace for the memory (optional).
Subject string
// Collection is the destination collection (optional).
Collection string
// Destination is the target destination name (optional; pipeline may use source default).
Destination string
// ActorType is "user", "agent", or "system" (optional).
ActorType string
// ActorID is the identity of the actor writing the memory (optional).
ActorID string
}
WriteParams are the input parameters for the nexus_write tool.
type WriteResult ¶
WriteResult is the output of the nexus_write tool.