Documentation
¶
Index ¶
- Constants
- func AgentFromContext(ctx context.Context) (mcpagents.Agent, bool)
- func EnvBoolValue(value string) bool
- func FirstNonEmpty(values ...string) string
- func IsLoopbackListenAddr(addr string) bool
- func JSONResult(value any) *mcp.CallToolResult
- func NewHTTPServer(addr string, handler http.Handler) *http.Server
- func ParseModes(raw string) map[string]bool
- func RequireMCPCredential(token string, agents *mcpagents.Store, next http.Handler) http.Handler
- func RequireMCPToken(token string, next http.Handler) http.Handler
- func ResolveAgentCredential() (string, error)
- func ResolveMCPToken(flagValue string) (string, error)
- func ShellQuote(value string) string
- func SiblingStackkitBinary() (string, error)
- func StringMapValue(values map[string]any, key string) string
- func TextResult(text string) *mcp.CallToolResult
- type App
- func (a *App) OpenMCP() map[string]any
- func (a *App) OpenMCPJSON() []byte
- func (a *App) OpenMCPJSONFor(r *http.Request) []byte
- func (a *App) OpenMCPPublic() map[string]any
- func (a *App) ProtectedStreamableHTTPHandler() http.Handler
- func (a *App) Server() *mcp.Server
- func (a *App) StreamableHTTPHandler() http.Handler
- type Options
Constants ¶
const ( MCPTokenEnv = "STACKKIT_MCP_TOKEN" MCPTokenFileEnv = "STACKKIT_MCP_TOKEN_FILE" // AgentCredentialEnv and AgentCredentialFileEnv carry the per-agent // credential of a directly attached (stdio) agent. AgentCredentialEnv = "STACKKIT_MCP_AGENT_CREDENTIAL" AgentCredentialFileEnv = "STACKKIT_MCP_AGENT_CREDENTIAL_FILE" )
Dedicated MCP credential sources. The token file lets an installer mint the credential without placing it on a command line or in a process listing.
const DefaultLocalServerURL = "http://localhost:8082"
DefaultLocalServerURL is the loopback-only default for a local stackkit-server when STACKKITS_SERVER_URL and --server-url are unset. Standard Mode binds MCP and the API to the developer machine; it is not a hosted production origin.
Variables ¶
This section is empty.
Functions ¶
func AgentFromContext ¶ added in v0.53.10
AgentFromContext returns the per-agent credential that authenticated the request. A request admitted by the shared legacy token has none.
func EnvBoolValue ¶
EnvBoolValue parses common truthy environment values.
func FirstNonEmpty ¶
FirstNonEmpty returns the first non-empty value after trimming whitespace.
func IsLoopbackListenAddr ¶
IsLoopbackListenAddr reports whether an HTTP listen address is loopback-only.
func JSONResult ¶
func JSONResult(value any) *mcp.CallToolResult
func NewHTTPServer ¶
NewHTTPServer creates a hardened Streamable HTTP server. WriteTimeout stays disabled because MCP Streamable HTTP may keep responses open.
func ParseModes ¶
ParseModes parses a comma-separated MCP mode list.
func RequireMCPCredential ¶ added in v0.53.10
RequireMCPCredential admits requests that present the shared MCP token or an active per-agent credential from the store, and it fails closed: with neither configured every request is denied with configuration guidance. An agent credential is re-checked on every request, so revoking it denies the next call.
func RequireMCPToken ¶
RequireMCPToken admits only requests that present the configured MCP token as a bearer credential or X-StackKit-MCP-Token value.
func ResolveAgentCredential ¶ added in v0.53.13
ResolveAgentCredential returns the per-agent credential of a directly attached agent from STACKKIT_MCP_AGENT_CREDENTIAL or the file named by STACKKIT_MCP_AGENT_CREDENTIAL_FILE. An empty result means none is configured; an unreadable or empty file is an error.
func ResolveMCPToken ¶ added in v0.45.0
ResolveMCPToken returns the dedicated MCP token from the explicit flag value, STACKKIT_MCP_TOKEN, or the file named by STACKKIT_MCP_TOKEN_FILE, in that order. An empty result means no token is configured. A configured token file that cannot be read or is empty is an error, never a silent fallback.
func ShellQuote ¶
func SiblingStackkitBinary ¶
SiblingStackkitBinary returns the packaged CLI beside stackkit-server or stackkit-mcp, through the shared exact-build local process binding.
func TextResult ¶
func TextResult(text string) *mcp.CallToolResult
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App owns the StackKits MCP registration shared by stackkit-mcp and stackkit-server.
func (*App) OpenMCPJSON ¶
OpenMCPJSON returns pretty JSON discovery metadata.
func (*App) OpenMCPJSONFor ¶ added in v0.53.10
OpenMCPJSONFor serves the full discovery document only to a request that presents the configured MCP token; every other request gets OpenMCPPublic.
func (*App) OpenMCPPublic ¶ added in v0.53.10
OpenMCPPublic is what an unauthenticated GET /openmcp.json may learn: the connector identity, transport and credential model, never the tool, resource or prompt inventory of an installation.
func (*App) ProtectedStreamableHTTPHandler ¶
ProtectedStreamableHTTPHandler requires the dedicated MCP token on every request. Without a configured token it denies every request; it never falls back to an open endpoint or to another credential.
func (*App) StreamableHTTPHandler ¶
StreamableHTTPHandler returns the stateless MCP 2026-07-28 Streamable HTTP handler. Each POST is served from that request alone: the SDK issues no Mcp-Session-Id, ignores one a client sends, and answers GET and DELETE with 405. Clients on older protocol versions are still served, one request at a time, with SDK-synthesized initialization defaults.
type Options ¶
type Options struct {
Modes map[string]bool
ServerURL string
// OwnerStepUpOrigin is the server's local Owner approval origin. When
// set, the State Console links to its device-enroll page and an agent's
// write denial links to its agent-approval page; the pairing code and the
// Owner's answer never pass through a tool result.
OwnerStepUpOrigin string
APIKey string
Transport string
MCPToken string
AllowWrite bool
// Agents holds per-agent MCP credentials. When set, a request that
// authenticates with an agent credential may call mutating tools only
// after the owner approves that exact call; AllowWrite no longer applies
// to it and stays the switch for the shared token and an anonymous stdio
// attachment.
Agents *mcpagents.Store
// AgentToken identifies a directly attached (stdio) agent by its per-agent
// credential. The credential is re-checked against Agents on every
// mutating call, so every write of that agent needs per-call owner
// approval and a revoke takes effect on its next call.
AgentToken string
BaseDir string
// PinBaseDir confines every tool to BaseDir. A remote caller then cannot
// point base_dir at other paths of the host or container.
PinBaseDir bool
// JSONResponse answers Streamable HTTP calls with application/json instead
// of an event stream; stackkit-server sets it because its tools never stream.
JSONResponse bool
Binary string
Version string
GitCommit string
}
Options configures the StackKits MCP server surface.