mcp

package
v0.0.1-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RPCParseError         = -32700
	RPCInvalidRequest     = -32600
	RPCMethodNotFound     = -32601
	RPCInvalidParams      = -32602
	RPCInternalError      = -32603
	ProtocolVersion       = "2025-11-25"
	DefaultRequestTimeout = 30 * time.Second
	// DefaultReplayLimit bounds in-memory SSE notification replay history per
	// process. Replay state is intentionally ephemeral and not shared across
	// restarts.
	// TODO(mcp): make replay retention configurable (and optionally durable)
	// once runtime auth and multi-process reconnect expectations are finalized.
	DefaultReplayLimit = 256
)

Variables

This section is empty.

Functions

func TextContent

func TextContent(text string) []map[string]any

TextContent creates a standard MCP text content block for tools/call results.

Types

type CompletionsCapability

type CompletionsCapability struct {
}

CompletionsCapability describes the server's completions support.

type HandlerFunc

type HandlerFunc func(ctx context.Context, params json.RawMessage) (any, error)

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string             `json:"protocolVersion"`
	Capabilities    ServerCapabilities `json:"capabilities"`
	ServerInfo      map[string]string  `json:"serverInfo"`
	Instructions    string             `json:"instructions,omitempty"`
}

InitializeResult represents the server's response to initialize.

type LoggingCapability

type LoggingCapability struct {
}

LoggingCapability describes the server's logging support.

type PromptListChangedEmitterProvider

type PromptListChangedEmitterProvider interface {
	SetPromptListChangedEmitter(cb func())
}

PromptListChangedEmitterProvider allows providers to request outbound notifications/prompts/list_changed emissions when prompt inventories change outside MCP prompts/list requests.

type PromptProvider

type PromptProvider interface {
	ListPrompts(ctx context.Context) ([]map[string]any, error)
	GetPrompt(ctx context.Context, name string) ([]map[string]any, bool, error)
}

PromptProvider allows a provider to back MCP prompts/* methods.

type PromptsCapability

type PromptsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

PromptsCapability describes the server's prompts support.

type RepoProvider

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

func NewRepoProvider

func NewRepoProvider(workspaceRoot string) *RepoProvider

func (*RepoProvider) Handler

func (p *RepoProvider) Handler(name string) (HandlerFunc, bool)

func (*RepoProvider) Tools

func (p *RepoProvider) Tools() []Tool

type ResourceCapability

type ResourceCapability struct {
	Subscribe   bool `json:"subscribe,omitempty"`
	ListChanged bool `json:"listChanged,omitempty"`
}

ResourceCapability describes the server's resources support.

type ResourceListChangedEmitterProvider

type ResourceListChangedEmitterProvider interface {
	SetResourceListChangedEmitter(cb func())
}

ResourceListChangedEmitterProvider allows providers to request outbound notifications/resources/list_changed emissions when they detect mutations that occur outside MCP tools/call execution.

type ResourceProvider

type ResourceProvider interface {
	ListResources(ctx context.Context) ([]map[string]any, error)
	ReadResource(ctx context.Context, uri string) ([]map[string]any, error)
	ListResourceTemplates(ctx context.Context) ([]map[string]any, error)
}

ResourceProvider allows a provider to back MCP resources/* methods. When absent, the server keeps returning empty baseline responses.

type ResourceUpdatedEmitterProvider

type ResourceUpdatedEmitterProvider interface {
	SetResourceUpdatedEmitter(cb func(uri string))
}

ResourceUpdatedEmitterProvider allows providers to request outbound notifications/resources/updated emissions for concrete resource URIs.

type RuntimeProvider

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

RuntimeProvider exposes live-instance tools and resources to MCP clients connecting directly to a running Overcast instance at /_mcp.

The runtime MCP is currently local-only (protected by Origin validation in the shared server) and does not require authentication. This posture is temporary and must be revisited before any remote/production exposure.

func NewRuntimeProvider

func NewRuntimeProvider(cfg *config.Config, store state.Store) *RuntimeProvider

NewRuntimeProvider creates a RuntimeProvider backed by the given config and state store. Both may be nil (in which case affected tools return empty data).

func (*RuntimeProvider) AttachEventBus

func (p *RuntimeProvider) AttachEventBus(bus *events.Bus)

AttachEventBus subscribes the runtime provider to the shared event bus so runtime_get_recent_events can return a bounded in-memory history.

func (*RuntimeProvider) Handler

func (p *RuntimeProvider) Handler(name string) (HandlerFunc, bool)

func (*RuntimeProvider) ListResourceTemplates

func (p *RuntimeProvider) ListResourceTemplates(_ context.Context) ([]map[string]any, error)

func (*RuntimeProvider) ListResources

func (p *RuntimeProvider) ListResources(ctx context.Context) ([]map[string]any, error)

func (*RuntimeProvider) ReadResource

func (p *RuntimeProvider) ReadResource(ctx context.Context, uri string) ([]map[string]any, error)

func (*RuntimeProvider) SetResourceListChangedEmitter

func (p *RuntimeProvider) SetResourceListChangedEmitter(cb func())

SetResourceListChangedEmitter configures a callback used to emit notifications/resources/list_changed when runtime service events indicate resource inventory changes that happened outside MCP tool calls.

func (*RuntimeProvider) SetResourceUpdatedEmitter

func (p *RuntimeProvider) SetResourceUpdatedEmitter(cb func(uri string))

SetResourceUpdatedEmitter configures a callback used to emit notifications/resources/updated for concrete resource URIs when runtime service events provide enough identity information.

func (*RuntimeProvider) Tools

func (p *RuntimeProvider) Tools() []Tool

type SSESource

type SSESource interface {
	RegisterSSEClient(ch chan []byte)
	UnregisterSSEClient(ch chan []byte)
}

type Server

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

func NewServer

func NewServer(sseSource SSESource, logger *slog.Logger, providers ...ToolProvider) *Server

func (*Server) Handler

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

func (*Server) RootHandler

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

RootHandler serves MCP routes at handler root ("/") without path rewriting. Callers that mount under a prefix should wrap it with http.StripPrefix.

func (*Server) ServeStdio

func (s *Server) ServeStdio(ctx context.Context, in io.Reader, out io.Writer) error

ServeStdio runs the MCP server over a newline-delimited JSON stdio transport. This is compatible with the stdio transport defined in MCP spec §1.3.1. It exits cleanly when the input stream closes (EOF) or ctx is cancelled. Notifications (id-less messages) are processed synchronously so that lifecycle state (e.g. notifications/initialized → ready) is visible to subsequent requests. Requests are dispatched concurrently to allow parallel tool calls.

func (*Server) SetBearerAuthToken

func (s *Server) SetBearerAuthToken(token string)

SetBearerAuthToken enables bearer-token HTTP auth checks when token is non-empty. Empty token disables auth checks.

func (*Server) SetNotificationReplayLimit

func (s *Server) SetNotificationReplayLimit(limit int)

SetNotificationReplayLimit sets the in-memory notification replay history size. A value of 0 disables replay retention entirely.

type ServerCapabilities

type ServerCapabilities struct {
	Tools       *ToolCapability        `json:"tools,omitempty"`
	Resources   *ResourceCapability    `json:"resources,omitempty"`
	Prompts     *PromptsCapability     `json:"prompts,omitempty"`
	Completions *CompletionsCapability `json:"completions,omitempty"`
	Logging     *LoggingCapability     `json:"logging,omitempty"`
	Tasks       *TasksCapability       `json:"tasks,omitempty"`
}

ServerCapabilities represents what the server supports.

type SymbolFindResult

type SymbolFindResult struct {
	Backend     string      `json:"backend"`
	Symbol      string      `json:"symbol"`
	PathPrefix  string      `json:"path_prefix"`
	Definitions []SymbolHit `json:"definitions"`
	References  []SymbolHit `json:"references"`
	Truncated   bool        `json:"truncated"`
	MaxResults  int         `json:"max_results"`
}

type SymbolFinder

type SymbolFinder interface {
	FindSymbol(ctx context.Context, query SymbolQuery) (SymbolFindResult, error)
}

type SymbolHit

type SymbolHit struct {
	Path string `json:"path"`
	Line int    `json:"line"`
	Text string `json:"text"`
}

type SymbolQuery

type SymbolQuery struct {
	Symbol     string
	PathPrefix string
	MaxResults int
}

type TasksCapability

type TasksCapability struct {
	List     bool                   `json:"list,omitempty"`
	Cancel   bool                   `json:"cancel,omitempty"`
	Requests map[string]interface{} `json:"requests,omitempty"`
}

TasksCapability describes the server's tasks support.

type Tool

type Tool struct {
	Name         string           `json:"name"`
	Title        string           `json:"title,omitempty"`
	Description  string           `json:"description"`
	Annotations  map[string]any   `json:"annotations,omitempty"`
	Execution    map[string]any   `json:"execution,omitempty"`
	InputSchema  json.RawMessage  `json:"inputSchema"`
	OutputSchema json.RawMessage  `json:"outputSchema,omitempty"`
	Icons        []map[string]any `json:"icons,omitempty"`
}

type ToolCapability

type ToolCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

ToolCapability describes the server's tools support.

type ToolProvider

type ToolProvider interface {
	Tools() []Tool
	Handler(name string) (HandlerFunc, bool)
}

type ToolResult

type ToolResult struct {
	Content           []map[string]any `json:"content,omitempty"`
	StructuredContent any              `json:"structuredContent,omitempty"`
	IsError           bool             `json:"isError,omitempty"`
}

ToolResult is a first-class tools/call result envelope. Providers can return this directly when they need explicit control over the human-readable content alongside machine-readable structuredContent.

Jump to

Keyboard shortcuts

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