runtime

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package runtime holds the shared production wiring for the one-user Clockify MCP server. cmd/clockify-mcp/main.go and the live test harness both build their *mcp.Server through BuildServer so there is exactly one place that decides the toolset filter, advertised-tool enforcement, audit logging, rate limits, and resource/notifier wiring. Keeping that wiring in one function means tests exercise the same server the binary serves, not a hand-rolled approximation.

This package may import internal/{clockify,config,mcp,tools,safety,logging}. It must never pull in controlplane/oidc/grpc/vault/policy/postgres/auth dependencies: cmd/clockify-mcp depends on it, and that command's dependency purity is a release gate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendRawDescriptors

func AppendRawDescriptors(advertised, full []mcp.ToolDescriptor) []mcp.ToolDescriptor

AppendRawDescriptors adds the raw API fallback descriptors (clockify_api_get, clockify_api_request) to the advertised surface when raw tools are enabled outside toolset=all. It preserves registry order and never duplicates a descriptor already present.

func NewClockifyClient

func NewClockifyClient(cfg config.OneUserConfig, maxRetries int) *clockify.Client

NewClockifyClient builds the Clockify HTTP client from the one-user config. maxRetries is configurable so the doctor path can opt out of retries while the server path retries transient failures.

Types

type BuiltServer

type BuiltServer struct {
	// Server is the wired MCP stdio server, ready for Server.Run.
	Server *mcp.Server
	// Service is the underlying tools.Service, exposed so callers (notably
	// the live test harness) can make direct, out-of-band Clockify calls
	// for setup, cleanup, and orthogonal assertions.
	Service *tools.Service
	// contains filtered or unexported fields
}

BuiltServer bundles a fully-wired one-user MCP server with the underlying service and the resources that must be released when the process (or test) is done with it. Callers must invoke Close exactly once, typically via defer, after Server.Run returns.

func BuildServer

func BuildServer(cfg config.OneUserConfig, version string) (*BuiltServer, error)

BuildServer constructs the production one-user MCP server from a loaded config and a resolved version string. It is the single source of truth for the server wiring previously inlined in cmd/clockify-mcp/main.go: client construction, the toolset filter, advertised-tool enforcement, the confirmation store, risk rate limits, audit logging, size limits, and the resource/notifier hookup.

On success the caller owns the returned *BuiltServer and must call Close when done. On error nothing is leaked: any partially-opened client is closed before returning.

func (*BuiltServer) Close

func (b *BuiltServer) Close() error

Close releases the Clockify client and, if configured, the audit logger. It is safe to call once; an error closing the audit logger is returned so callers can decide whether to surface it.

Jump to

Keyboard shortcuts

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