Documentation
¶
Overview ¶
Package mcp implements the Model Context Protocol server for Cortex.
This exposes memory tools via MCP stdio transport so agents can use Cortex as a persistent memory server.
Tool profiles allow agents to load only the tools they need:
cortex mcp -> all tools (default) cortex mcp --tools=agent -> Engram-compatible memory tools cortex mcp --tools=admin -> delete, stats, timeline
Package mcp provides MCP (Model Context Protocol) server implementation for Cortex, exposing all memory system capabilities as MCP tools.
This package implements the MCP server with tool profiles, error handling, and domain logic delegation to the appropriate services.
Index ¶
- Variables
- func NewServer(stores *Stores) *server.MCPServer
- func NewServerWithTools(stores *Stores, allowlist map[string]bool) *server.MCPServer
- func ResolveTools(input string) map[string]bool
- type Stores
- type TemporalToolsHandler
- func (h *TemporalToolsHandler) CreateTemporalEdge(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
- func (h *TemporalToolsHandler) CreateTemporalSnapshot(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
- func (h *TemporalToolsHandler) EvaluateMemoryQuality(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
- func (h *TemporalToolsHandler) GetCurrentFactState(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
- func (h *TemporalToolsHandler) GetHealthCheck(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
- func (h *TemporalToolsHandler) GetSystemMetrics(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
- func (h *TemporalToolsHandler) GetTemporalEdges(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
- func (h *TemporalToolsHandler) GetTemporalEvolutionPath(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
- func (h *TemporalToolsHandler) GetTemporalRelevant(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
- func (h *TemporalToolsHandler) RecordOperation(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
Constants ¶
This section is empty.
Variables ¶
var ProfileAdmin = map[string]bool{ "mem_delete": true, "mem_stats": true, "mem_timeline": true, "mem_revision_history": true, "mem_archive": true, "mem_merge_projects": true, }
ProfileAdmin contains tools for manual curation (TUI, CLI, dashboards).
var ProfileAgent = map[string]bool{ "mem_save": true, "mem_search": true, "mem_context": true, "mem_session_summary": true, "mem_session_start": true, "mem_session_end": true, "mem_get_observation": true, "mem_suggest_topic_key": true, "mem_capture_passive": true, "mem_save_prompt": true, "mem_update": true, "mem_relate": true, "mem_graph": true, "mem_score": true, "mem_search_hybrid": true, "mem_revision_history": true, }
ProfileAgent contains 11 Engram-compatible memory tools for AI agent workflows plus Cortex-exclusive tools (graph, scoring, hybrid search).
var Profiles = map[string]map[string]bool{ "agent": ProfileAgent, "admin": ProfileAdmin, }
Profiles maps profile names to their tool sets.
Functions ¶
func NewServerWithTools ¶
NewServerWithTools creates an MCP server registering only the tools in the allowlist. If allowlist is nil, all tools are registered.
func ResolveTools ¶
ResolveTools takes a comma-separated string of profile names and/or individual tool names and returns the set of tool names to register. An empty input or "all" means register everything.
Types ¶
type TemporalToolsHandler ¶
type TemporalToolsHandler struct {
// contains filtered or unexported fields
}
TemporalToolsHandler handles temporal graph and observability MCP tools.
func NewTemporalToolsHandler ¶
func NewTemporalToolsHandler( temporalService *temporal.TemporalService, observabilityService *observability.ObservabilityService, ) *TemporalToolsHandler
NewTemporalToolsHandler creates a new handler for temporal and observability tools.
func (*TemporalToolsHandler) CreateTemporalEdge ¶
func (h *TemporalToolsHandler) CreateTemporalEdge(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
CreateTemporalEdge creates an edge with temporal validity and evolution tracking.
func (*TemporalToolsHandler) CreateTemporalSnapshot ¶
func (h *TemporalToolsHandler) CreateTemporalSnapshot(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
CreateTemporalSnapshot creates a point-in-time snapshot of the knowledge graph.
func (*TemporalToolsHandler) EvaluateMemoryQuality ¶
func (h *TemporalToolsHandler) EvaluateMemoryQuality(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
EvaluateMemoryQuality evaluates the quality of the memory system.
func (*TemporalToolsHandler) GetCurrentFactState ¶
func (h *TemporalToolsHandler) GetCurrentFactState(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
GetCurrentFactState determines the current state of facts related to an observation.
func (*TemporalToolsHandler) GetHealthCheck ¶
func (h *TemporalToolsHandler) GetHealthCheck(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
GetHealthCheck provides system health status.
func (*TemporalToolsHandler) GetSystemMetrics ¶
func (h *TemporalToolsHandler) GetSystemMetrics(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
GetSystemMetrics retrieves system-wide performance metrics.
func (*TemporalToolsHandler) GetTemporalEdges ¶
func (h *TemporalToolsHandler) GetTemporalEdges(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
GetTemporalEdges retrieves edges valid at a specific time point.
func (*TemporalToolsHandler) GetTemporalEvolutionPath ¶
func (h *TemporalToolsHandler) GetTemporalEvolutionPath(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
GetTemporalEvolutionPath retrieves the evolution history of an edge.
func (*TemporalToolsHandler) GetTemporalRelevant ¶
func (h *TemporalToolsHandler) GetTemporalRelevant(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
GetTemporalRelevant retrieves observations relevant at a specific time.
func (*TemporalToolsHandler) RecordOperation ¶
func (h *TemporalToolsHandler) RecordOperation(ctx context.Context, req *protocol.CallToolRequest) (*protocol.CallToolResult, error)
RecordOperation records an operation with performance metrics.