mcp

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcp exposes lectern over the Model Context Protocol on stdio, so any MCP client — Claude Code, an mcpo bridge, a chat bot — can file and steer tasks.

It is a client of lectern's own HTTP API rather than of the database, so it works against a control plane running anywhere and can never bypass a validation the API enforces.

Index

Constants

View Source
const MaxRequestBytes = 16 << 20

MaxRequestBytes bounds a single JSON-RPC frame. A start_session/ send_to_session call can carry inline_files content, so this is generous rather than a typical API default.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	API   string
	Token string
	HTTP  *http.Client

	// Remote is true only for a Server built for the HTTP web-connector
	// transport (cmd/lectern's `lectern mcp --http`), never for the stdio
	// path. Tools that would read an arbitrary path on the machine this
	// process runs on — the local `files` parameter to start_session/
	// send_to_session, and active_work's repo_path — check this and refuse,
	// because a web-connector caller supplies no local filesystem of its
	// own: "local" here means the machine running THIS process, which for a
	// remote caller is not under its control.
	Remote bool

	// InboundToken is a static bearer accepted by the HTTP transport
	// (LECTERN_MCP_TOKEN), independent of OAuth. Unset means no static
	// bearer is configured; see http.go's checkAuth.
	InboundToken string

	// OAuth, when set, is the authorization server backing the HTTP
	// transport's bearer tokens — see internal/oauth and
	// cmd/lectern/mcp_http.go. Nil means the HTTP transport (if used at all)
	// accepts only InboundToken.
	OAuth *oauth.Handler
}

Server speaks JSON-RPC — over stdio, or (see http.go) over the Streamable HTTP web-connector transport — and forwards to an lectern API.

func New

func New(api, token string) *Server

New builds a server pointed at an lectern instance.

func (*Server) HTTPHandler added in v2.4.0

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

HTTPHandler serves JSON-RPC over POST at /mcp, plus — when Server.OAuth is configured — the public half of the OAuth surface (discovery metadata, registration, token issuance, revocation) on the same mux. The private half, /oauth/authorize, is never mounted here; see internal/oauth.Handler. RegisterPrivate and cmd/lectern/mcp_http.go, which serves it on a second listener.

func (*Server) ListenAndServe added in v2.4.0

func (s *Server) ListenAndServe(addr string) error

ListenAndServe runs the HTTP transport until the process is stopped. Deliberately not named ServeHTTP: this type is not an http.Handler, and a method with that name and a different signature reads like a broken one.

func (*Server) ReportWebEndpoint added in v2.4.0

func (s *Server) ReportWebEndpoint(url string) error

ReportWebEndpoint records this web connector's public MCP URL with the control plane (POST /api/mcp-clients/web-endpoint).

func (*Server) Serve

func (s *Server) Serve(in io.Reader, out io.Writer) error

Serve runs the stdio loop until the client closes the connection.

Jump to

Keyboard shortcuts

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