Documentation
¶
Overview ¶
Direct codegraph MCP tools.
Before this file existed, the MCP bridge to celeste's codegraph went through the celeste chat tool: the caller sent a natural-language prompt, a chat LLM decided to call code_review (or code_search, ...) as a function-call, the tool ran against the graph, and the chat LLM summarized the result back to the caller — with all the usual LLM costs: latency, token spend, and an output ceiling that truncated large findings mid-response.
The tools here skip the chat LLM entirely. Each MCP tool is a direct handler that pulls the per-workspace Indexer from the Server cache, invokes the underlying celeste codegraph tool, and returns the tool result verbatim as an MCP ContentBlock. No model in the middle, no output ceiling — the client receives exactly what celeste computed.
Indexing is explicit: none of these tools auto-reindex. If the caller's workspace has changed and the cached graph is stale, the caller must first call celeste_index with operation="update" (or "rebuild" for a full re-scan). This matches the user's mental model — "index once, serve the graph for many queries" — and avoids the silent-reindex latency spike that plagued the old chat-routed path.
Progress notification plumbing for the MCP server. Tool handlers that need to stream status back to the client (long reindex runs, expensive codegraph queries, etc.) pull a Notifier out of the request context and call it with JSON-RPC method + params.
The transport layer binds a concrete Notifier implementation to the context before dispatching the request — stdio writes notifications as single-line JSON to the same stdout the response will later use; SSE pushes them to the per-connection event stream. Handlers never talk to the transport directly.
Handlers that don't need progress simply don't pull the notifier. The zero-cost path is a nil lookup.
Package server implements a Model Context Protocol (MCP) server that exposes Celeste's capabilities to external clients such as Claude Code, Codex, or any MCP-compatible tool orchestrator.
Index ¶
- func ProgressTokenFromContext(ctx context.Context) progressToken
- func RegisterHandlers(s *Server)
- func SendProgress(ctx context.Context, message string, percent float64)
- func WithNotifier(ctx context.Context, n Notifier) context.Context
- func WithProgressToken(ctx context.Context, token progressToken) context.Context
- type Config
- type ContentBlock
- type Notifier
- type Server
- type ToolHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProgressTokenFromContext ¶ added in v1.9.0
ProgressTokenFromContext returns the client-supplied progress token, or nil if the client didn't request progress.
func RegisterHandlers ¶
func RegisterHandlers(s *Server)
RegisterHandlers registers all MCP tool handlers on the server. Persona tools (celeste / celeste_content / celeste_status) route through a chat LLM and are kept for the "ask Celeste a question" use case. Direct codegraph tools (celeste_index + celeste_code_* family) skip the LLM and serve queries straight from the cached graph — use those for tool-driven workflows that need verbatim results.
func SendProgress ¶ added in v1.9.0
SendProgress is a convenience for tool handlers: if a notifier + token are both present, it dispatches a notifications/progress event with the given payload. Otherwise it's a no-op. Callers never need to branch on notifier presence themselves.
func WithNotifier ¶ added in v1.9.0
WithNotifier attaches a Notifier to the context so downstream tool handlers can stream progress back to the client.
Types ¶
type Config ¶
type Config struct {
// Transport mode: "stdio" or "sse"
Transport string
// SSE-specific settings
Port int
BindAddr string // default "127.0.0.1"
Remote bool // if true, bind to BindAddr (possibly 0.0.0.0)
CertFile string // TLS certificate for mTLS
KeyFile string // TLS private key for mTLS
TokenFile string // path to bearer token file (default ~/.celeste/server.token)
RateLimit int // requests per minute (default 60)
// Celeste config for creating LLM clients
CelesteConfig *config.Config
Workspace string
}
Config holds MCP server configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type ContentBlock ¶
type ContentBlock = mcp.ContentBlock
ContentBlock is a content item in a tool call response. Re-exported from the mcp package for handler convenience.
type Notifier ¶ added in v1.9.0
Notifier sends a single JSON-RPC notification back to the MCP client. Used by tool handlers for progress updates and interim status.
func NotifierFromContext ¶ added in v1.9.0
NotifierFromContext returns the Notifier attached to ctx, or nil if none is present. Handlers MUST nil-check the return value.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the MCP server that exposes Celeste tools to external clients.
func (*Server) Close ¶ added in v1.9.0
Close releases resources held by the server. Must be called on shutdown — the indexer cache holds SQLite connections that won't flush otherwise. Safe to call multiple times; second and subsequent calls are no-ops.
func (*Server) RegisterTool ¶
func (s *Server) RegisterTool(def mcp.MCPToolDef, handler ToolHandler)
RegisterTool adds a tool definition and its handler to the server.
type ToolHandler ¶
ToolHandler processes a tool call and returns content blocks.