mcpserver

package
v0.0.0-...-83bddd0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package mcpserver exposes the instance to an agent over the Model Context Protocol.

This is the surface the project is built around: point Claude at a running instance and ask it what the engines are saying about you. It reads internal/metrics and nothing else, which is what keeps a number identical whether it arrived through the dashboard, the JSON API or a tool call.

Three rules from docs/tools.md are enforced here rather than described.

Same name, same shape. Where a Limelit Cloud tool exists, the name and the required arguments are reproduced, so a conversation or a skill written against this server keeps working after limelit upgrade.

Cloud-only arguments are rejected, never ignored. Silently dropping a segment filter would return a number for the whole property while the caller believed it was scoped, and a wrong number is worse than an error.

No stubs. A tool that exists only in Cloud is not registered, so an agent discovers the boundary by not finding the tool rather than by receiving an approximation.

Index

Constants

View Source
const TokenEnv = "LIMELIT_MCP_TOKEN"

TokenEnv is the environment variable holding the bearer token.

View Source
const Version = "0.1"

Version is reported in the MCP handshake.

Variables

This section is empty.

Functions

func Handler

func Handler(srv *mcp.Server, source TokenSource, log *slog.Logger) http.Handler

Handler serves MCP over streamable HTTP.

A token is REQUIRED. An unauthenticated endpoint here would hand anyone who can reach the port every answer the instance has stored, and a self-hosted tool is frequently put on a box with a more generous firewall than its author assumed. With no token configured the handler refuses every request and says how to set one, which fails closed and explains itself.

func New

func New(deps Deps) (*mcp.Server, error)

New builds the server with every tool registered.

Types

type Deps

type Deps struct {
	DB      *store.DB
	Metrics *metrics.Service
	// Runner triggers an evaluation. Nil leaves the evaluation tools
	// unregistered rather than registering one that fails, because a tool
	// that exists and never works is worse than one that is absent.
	Runner Runner
}

Deps is what the tools need. Nothing here holds a credential: the tools read stored answers, they do not call providers.

type Runner

type Runner interface {
	Start(ctx context.Context, promptID int64) (int, error)
}

Runner is the evaluation entry point, as an interface so this package does not depend on the runner's concrete type.

type TokenSource

type TokenSource func() string

TokenSource returns the bearer token in force right now, or "" when there is none. It is a function rather than a string so a token generated or rotated in Settings takes effect on the next request instead of the next restart; a Rotate button that needed a restart would leave the old token working while the screen said it was gone.

func StaticToken

func StaticToken(token string) TokenSource

StaticToken is a TokenSource for a token fixed at startup.

Jump to

Keyboard shortcuts

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