Documentation
¶
Overview ¶
Package server runs an MCP server the way every katbyte MCP tool serves one: over stdio for a client that starts it, or over Streamable HTTP for an always-on deployment, behind a bearer token and with a health probe a container can ask.
Index ¶
Constants ¶
const ( // Path is where the MCP endpoint is served over HTTP. Path = "/mcp" // HealthPath answers "ok" to a GET, with no token asked for: a container // with a token configured would otherwise never be healthy. HealthPath = "/healthz" )
const DefaultInstructions = `` /* 646-byte string literal not displayed */
DefaultInstructions is what every server tells a client that connects, before anything of its own: what holds for every tool, because the registry and the tools' own conventions make it so, said once so that no tool's description has to.
Variables ¶
This section is empty.
Functions ¶
func CheckAuth ¶
CheckAuth is what stands between an address to listen on and an open port: with no bearer token it is an error, unless the operator said that no auth is wanted. A blank token in a copied .env used to come up serving every tool to the whole network with one line of warning.
func Handler ¶
Handler is the HTTP routes: the MCP endpoint at Path behind the bearer check, and the health probe at HealthPath outside it. It is apart from Run so the routes and the check can be tested, or mounted in a server of the caller's own, without binding a port.
func Instructions ¶ added in v0.6.1
Instructions is what a server tells a client that connects, for mcp.ServerOptions: DefaultInstructions and then the server's own, each a paragraph. A server that wants other words altogether gives those to the options itself and leaves this alone.
Types ¶
type Options ¶
type Options struct {
// Listen is the address to serve Streamable HTTP on, ":8080" say. Empty
// serves stdio.
Listen string
// AuthToken is the bearer token an HTTP client must send. Empty asks for
// none, which Run refuses without AllowNoAuth.
AuthToken string
// AllowNoAuth is the operator saying, in so many words, that anyone who
// can reach the port may use every tool.
AllowNoAuth bool
// Name is the tool's own name, "abs-mcp" say: the realm a client sent
// away is told.
Name string
// EnvPrefix is what the tool's environment variables begin with, "ABS"
// for ABS_AUTH_TOKEN, so what the operator is told names the variable
// to set.
EnvPrefix string
}
Options says how to serve.