mcp

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package mcp provides an MCP (Model Context Protocol) server for the Tapes system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// SpanSearcher and Embedder optionally retain the legacy core search tool
	// while search moves to a cassette. They must be supplied together.
	SpanSearcher SpanSearcher
	Embedder     embeddings.Embedder

	// Cassettes is the live registry whose advertised tools are exposed.
	Cassettes *cassetterunner.Registry

	// Client invokes admitted cassette operations. Nil uses a redirect-refusing client.
	Client *http.Client

	Logger *slog.Logger
}

type SearchInput

type SearchInput struct {
	Query string `json:"query" jsonschema:"the search query text to find relevant spans"`
	TopK  int    `json:"top_k,omitempty" jsonschema:"number of results to return (default: 5)"`
}

SearchInput represents the input arguments for the MCP search tool. It uses jsonschema tags specific to the MCP protocol.

type SearchOutput added in v0.16.0

type SearchOutput struct {
	Query   string         `json:"query"`
	Results []SearchResult `json:"results"`
	Count   int            `json:"count"`
}

SearchOutput is the MCP search response. It mirrors the HTTP /v1/search/spans response shape (api.SpanSearchOutput).

type SearchResult added in v0.16.0

type SearchResult struct {
	SessionID string  `json:"session_id,omitempty" jsonschema:"session the span belongs to"`
	TraceID   string  `json:"trace_id" jsonschema:"trace (turn) the span belongs to"`
	SpanID    string  `json:"span_id" jsonschema:"the matched span"`
	Score     float32 `json:"score" jsonschema:"vector similarity score"`
	// UserPrompt is the prompt of the turn (trace) the span belongs to.
	UserPrompt string `json:"user_prompt,omitempty" jsonschema:"prompt of the turn the span belongs to"`
	// Snippet previews the matched span's delta-only text.
	Snippet   string    `json:"snippet,omitempty" jsonschema:"preview of the matched span's text"`
	Model     string    `json:"model,omitempty" jsonschema:"model that produced the span"`
	StartedAt time.Time `json:"started_at" jsonschema:"when the span started"`
}

SearchResult is one span hit with its trace/turn context. It mirrors the HTTP /v1/search/spans response shape (api.SpanSearchResult).

type Server

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

func NewServer

func NewServer(config Config) (*Server, error)

NewServer creates a stateless MCP server over the current cassette registry.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the HTTP handler for the MCP server.

type SpanSearcher added in v0.16.0

type SpanSearcher interface {
	Search(ctx context.Context, orgID string, embedding []float32, topK int) ([]spanembed.Hit, error)
}

SpanSearcher performs vector-similarity search over span embeddings.

Jump to

Keyboard shortcuts

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