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 ¶
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 (*Server) HTTPHandler ¶ added in v2.4.0
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
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
ReportWebEndpoint records this web connector's public MCP URL with the control plane (POST /api/mcp-clients/web-endpoint).