mcp

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package mcp exposes Litescope as a Model Context Protocol server over stdio, so an LLM agent (Claude Desktop, Claude Code, or any MCP client) can call Litescope operations as tools. All tools are read-only by default.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(in io.Reader, out io.Writer, version string, allowWrites bool, defaultSource string) error

Serve runs the MCP server over newline-delimited JSON-RPC on the given streams until in reaches EOF. stdout carries only protocol messages. When allowWrites is true, write-capable tools (litescope_query_write, litescope_migrate_apply, litescope_d1_create, litescope_d1_delete) are included; otherwise only read-only tools are exposed. defaultSource, when non-empty, is exposed as concrete schema/dictionary resources.

func ServeHTTP added in v0.6.4

func ServeHTTP(addr, path, version string, allowWrites bool, defaultSource string, opts HTTPOptions) error

initialize creates a session and returns its id in the Mcp-Session-Id response header; every later request must echo that header. allowWrites and defaultSource apply to every session, exactly as for the stdio transport.

Types

type HTTPOptions added in v0.6.4

type HTTPOptions struct {
	// Token, when non-empty, is required as "Authorization: Bearer <token>" on
	// every request. Empty means no token is enforced (open endpoint).
	Token string
	// AllowedOrigins is the set of browser Origins permitted, for DNS-rebinding
	// protection. localhost / 127.0.0.1 origins are always allowed; non-browser
	// clients (no Origin header) are always allowed. Empty list means only those
	// defaults are accepted.
	AllowedOrigins []string
}

ServeHTTP runs the MCP server over the Streamable HTTP transport (MCP 2025-06-18) on addr. A single endpoint (default "/mcp") accepts:

  • POST — one JSON-RPC message. A request returns its response as the body (application/json); a notification/response returns 202 with no body.
  • GET — opens a Server-Sent Events stream that carries server-initiated notifications (logging, resource updates) for the session.
  • DELETE — terminates the session.

HTTPOptions configures the Streamable HTTP transport's auth layer.

type Prompt added in v0.6.0

type Prompt struct {
	Name        string
	Description string
	Arguments   []PromptArg
	// Render builds the user-facing message text from the supplied arguments.
	Render func(args map[string]string) string
}

Prompt is a canned, parameterized workflow exposed over MCP's prompts capability. Clients list these and present them to the user as ready-made actions ("diagnose my locked database"), then the server fills in a guiding message that tells the agent exactly which Litescope tools to chain.

func Prompts added in v0.6.0

func Prompts() []Prompt

Prompts returns the canned workflows. They reference Litescope's own tools so an agent gets a concrete, safe plan rather than improvising.

type PromptArg added in v0.6.0

type PromptArg struct {
	Name        string
	Description string
	Required    bool
}

PromptArg describes one argument a prompt accepts.

type Tool

type Tool struct {
	Name         string
	Description  string
	InputSchema  map[string]interface{} // JSON Schema for the arguments
	OutputSchema map[string]interface{} // optional JSON Schema for structuredContent (MCP 2025-06-18)
	Handler      func(args map[string]interface{}) (string, error)
}

Tool is one callable operation exposed to an AI agent. The same registry backs both the MCP server and (in future) a built-in BYOK agent.

func Registry

func Registry(allowWrites bool) []Tool

Registry returns all MCP tools. When allowWrites is true, write-capable tools are appended: litescope_query_write, litescope_migrate_apply, litescope_write_undo, litescope_salvage, litescope_d1_create, litescope_d1_delete.

Jump to

Keyboard shortcuts

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