Documentation
¶
Overview ¶
Package server serves the NICo REST read surface as MCP tools over streamable-HTTP. Tools are projected 1:1 from the embedded OpenAPI spec's GET operations. The server is stateless and never emits SSE: every tool/call returns a single application/json body.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildServer ¶
BuildServer constructs an *mcp.Server with one tool registered for every GET operation in the supplied OpenAPI spec. Tool names follow the SDD: nico_<snake_case(operationId)>. Each tool handler builds a fresh appcli.Client per call from resolvedConfig.FromCallConfig and forwards the bearer token from the inbound MCP request to NICo REST unchanged.
BuildServer does not start a listener; callers wrap the result with NewHandler to get an *http.Handler ready for ListenAndServe.
func NewHandler ¶
NewHandler wraps an *mcp.Server in a streamable-HTTP handler configured for stateless, request/response-only operation:
- Stateless: true -- the SDK does not validate Mcp-Session-Id and rejects server->client requests. initialize is a no-op.
- JSONResponse: true -- every tool/call response uses Content-Type: application/json; the SDK never opens an SSE stream, so clients and intermediaries that do not speak text/event-stream still receive a single JSON body.
DNS-rebinding (localhost) protection and cross-origin protection are deliberately left at the SDK's secure defaults (go-sdk v1.4.1+): browser cross-origin requests and localhost DNS-rebinding attempts are rejected, while non-browser MCP clients -- which send no Origin or Sec-Fetch-Site header -- pass through unaffected. Do not set DisableLocalhostProtection or a permissive CrossOriginProtection here without understanding the security trade-off.
func Run ¶
Run wires the urfave context into Options, builds the MCP server, and runs an http.Server until SIGINT/SIGTERM. It is the action backing the standalone nico-mcp binary, exported so the binary's main stays a thin wrapper and so tests can drive it directly.
func ServeFlags ¶
ServeFlags returns the full flag set for the standalone nico-mcp server binary. The server-specific flags (listen, path, shutdown-timeout) sit alongside the connection flags (base-url, org, api-name, token, debug). The dynamically-generated CLI exposes the latter as root-level flags, but nico-mcp is a single-purpose binary with no parent command to inherit from, so it declares all of them itself. Each flag also reads its NICO_* environment variable.
Types ¶
type NicoOpenApiHandler ¶
type NicoOpenApiHandler struct {
// contains filtered or unexported fields
}
NicoOpenApiHandler builds the MCP tool input schema for a single OpenAPI GET operation, combining the path-item and operation-level parameters with the common per-call config override fields.
type Options ¶
type Options struct {
// BaseURL is the NICo REST base URL (e.g. https://nico.example.com).
BaseURL string
// Org is the default organisation used in /v2/org/<org>/... paths.
Org string
// APIName is the API path segment between org and resource (default
// "nico", overridable via api.name in config).
APIName string
// Token is the static bearer used when no inbound bearer or tool
// arg token is provided.
Token string
// Debug enables logrus debug-level HTTP request/response logging
// through to the appcli.Client.
Debug bool
// Log is the logrus entry used for client request/response logging.
// If nil, a default entry wrapping the standard logger is used.
Log *logrus.Entry
}
Options carry the server-side defaults that every tool invocation starts from. Individual tool calls override these per request through resolveCallConfig.