Documentation
¶
Index ¶
- Constants
- Variables
- func BuildHarpoonHTTPEndpoint(healthCfg *runtimeconfig.HealthConfig, svc runtimehealth.Service, ...) string
- func FilterOutboundHeaders(headers map[string]string) (http.Header, int, []string)
- func IsBlockedOutboundHeader(headerName string) bool
- func NewGuardedMux(adminMux *http.ServeMux) httpguard.GuardedMux
- func NewHostBus(p HostBusSubscriberIn) (hostbus.HostRegistrationBus, error)
- func NewRestartableInMemoryTransport(ctx context.Context, server *mcp.Server, logger *slog.Logger) mcp.Transport
- func NewStartupCatalogDigestState() *startupCatalogDigestState
- func NormalizeToken(value string) string
- func RegisterAdditionalTransport(p AdditionalTransportParams) error
- func RegisterHostBundleForConfig(bundle hostbus.URLBundle, cfg runtimeconfig.HarpoonHostClassifierConfig, ...) error
- func ResponseContentTypeForLog(contentType string) string
- func StartCatalogDigestLogging(p startupCatalogDigestLifecycleParams) error
- func StartHostRegistration(p HostRegistrationParams) error
- func TransformHeaders(headers http.Header, rewriter *URLRewriter) (http.Header, bool)
- func TransformJSONBody(body []byte, rewriter *URLRewriter) ([]byte, bool)
- type AdditionalTransportParams
- type CallEvent
- type CallObserver
- type CallTargetRequest
- type CallTargetResponse
- type HostBusSubscriberIn
- type HostBusSubscriberOut
- type HostRegistrationParams
- type ListTargetsRequest
- type ListTargetsResponse
- type MCPServerProvider
- type RedirectMismatchDetails
- type RedirectMismatchKind
- type Registry
- func (r *Registry) AllowsURL(candidate *url.URL) bool
- func (r *Registry) Count() int
- func (r *Registry) ExactURL(label string) (*url.URL, bool)
- func (r *Registry) ExplainBlockedRedirect(candidate *url.URL) *redirectMismatchDetails
- func (r *Registry) Lookup(label string) (Target, bool)
- func (r *Registry) RegisterTarget(target Target) error
- func (r *Registry) Resolve(label string) (*url.URL, error)
- func (r *Registry) SummarizeTargets() []map[string]string
- func (r *Registry) TargetForURL(candidate *url.URL) (Target, bool)
- func (r *Registry) Targets() []Target
- func (r *Registry) WaitForTarget(ctx context.Context, label string) (Target, error)
- type RegistryCounter
- type Server
- type ServerOption
- type ServiceFactory
- type SharedServiceOutputs
- type SharedServiceParams
- type Target
- type TargetInfo
- type TargetRegistrar
- type ToolRegistrar
- type URLRewriter
Constants ¶
const ( RedirectMismatchSchemeHTTPToHTTPS = redirectMismatchSchemeHTTPToHTTPS RedirectMismatchSchemeHTTPSToHTTP = redirectMismatchSchemeHTTPSToHTTP RedirectMismatchPath = redirectMismatchPath RedirectMismatchQuery = redirectMismatchQuery RedirectMismatchHost = redirectMismatchHost RedirectMismatchOther = redirectMismatchOther )
const MaxContentTypeLogBytes = maxContentTypeLogBytes
MaxContentTypeLogBytes is the byte bound used for receipt content types.
Variables ¶
var Module = fx.Module( "harpoon", fx.Provide(newHarpoonService, newRegistryCounter, newHarpoonGuardedMux, NewHostBusSubscriber, NewHostBus, NewStartupCatalogDigestState), fx.Invoke(registerAdditionalTransport, StartHostRegistration, StartCatalogDigestLogging), )
Module wires the harpoon MCP server.
Functions ¶
func BuildHarpoonHTTPEndpoint ¶
func BuildHarpoonHTTPEndpoint(healthCfg *runtimeconfig.HealthConfig, svc runtimehealth.Service, timeout time.Duration) string
BuildHarpoonHTTPEndpoint resolves the operator-facing streamable endpoint.
func FilterOutboundHeaders ¶
FilterOutboundHeaders applies the core outbound-header policy.
func IsBlockedOutboundHeader ¶
IsBlockedOutboundHeader reports whether a caller-supplied header is blocked.
func NewGuardedMux ¶
func NewGuardedMux(adminMux *http.ServeMux) httpguard.GuardedMux
NewGuardedMux creates the loopback-only Harpoon HTTP transport mux.
func NewHostBus ¶
func NewHostBus(p HostBusSubscriberIn) (hostbus.HostRegistrationBus, error)
NewHostBus constructs the canonical host-registration bus.
func NewRestartableInMemoryTransport ¶
func NewRestartableInMemoryTransport(ctx context.Context, server *mcp.Server, logger *slog.Logger) mcp.Transport
NewRestartableInMemoryTransport creates the shared reconnectable in-memory transport used by both runtime and package-owned adapters.
func NewStartupCatalogDigestState ¶ added in v0.0.14
func NewStartupCatalogDigestState() *startupCatalogDigestState
NewStartupCatalogDigestState constructs the internal Fx-shared startup digest holder. It is exported only so the full-client adapter can provide the same runtime-owned state without exposing its contents.
func NormalizeToken ¶
NormalizeToken exposes the canonical metadata-token normalization for full-client extension tools without duplicating it.
func RegisterAdditionalTransport ¶
func RegisterAdditionalTransport(p AdditionalTransportParams) error
RegisterAdditionalTransport owns the common HTTP streamable transport registration for both runtime and full-client Harpoon graphs.
func RegisterHostBundleForConfig ¶
func RegisterHostBundleForConfig(bundle hostbus.URLBundle, cfg runtimeconfig.HarpoonHostClassifierConfig, registry *Registry, logger *slog.Logger) error
RegisterHostBundleForConfig applies one discovered URL bundle using the canonical runtime classifier. It is primarily a compatibility seam for full-client tests and adapters that must not duplicate registration logic.
func ResponseContentTypeForLog ¶
ResponseContentTypeForLog returns the normalized bounded content type used in call receipts.
func StartCatalogDigestLogging ¶ added in v0.0.14
func StartCatalogDigestLogging(p startupCatalogDigestLifecycleParams) error
StartCatalogDigestLogging waits for the stricter startup-only Harpoon catalog barrier, then emits exactly one digest event for this process. It deliberately does not subscribe to later registry mutations.
func StartHostRegistration ¶
func StartHostRegistration(p HostRegistrationParams) error
StartHostRegistration wires canonical OAuth host auto-registration.
func TransformHeaders ¶
TransformHeaders rewrites allowlisted URLs in response headers.
func TransformJSONBody ¶
func TransformJSONBody(body []byte, rewriter *URLRewriter) ([]byte, bool)
TransformJSONBody rewrites allowlisted URLs in a JSON response body.
Types ¶
type AdditionalTransportParams ¶
type AdditionalTransportParams struct {
Lifecycle fx.Lifecycle
GuardedMux httpguard.GuardedMux
Config *runtimeconfig.HarpoonConfig
Server MCPServerProvider
Logger *slog.Logger
}
AdditionalTransportParams contains the shared inputs for registering the optional loopback-only HTTP streamable Harpoon transport.
type CallEvent ¶
type CallEvent struct {
Label string
URL string
Method string
Status int
RequestBody string
RequestBytes int
ResponseBytes int
Error string
StartedAt time.Time
ResponseContentType string
ResponseBody []byte
ResponseBodyTransformed []byte
}
CallEvent is the transport-neutral receipt emitted after a call_target attempt. Optional adapters can observe it without changing core routing.
type CallObserver ¶
type CallObserver func(CallEvent)
CallObserver receives one receipt after a call_target attempt.
type CallTargetRequest ¶
type CallTargetRequest = callTargetRequest
Exported aliases keep the shared core reusable by thin adapters while the runtime entrypoint continues to expose only its approved command surface.
type CallTargetResponse ¶
type CallTargetResponse = callTargetResponse
type HostBusSubscriberIn ¶
type HostBusSubscriberIn struct {
fx.In
Subscriber chan hostbus.URLBundle `name:"harpoon_hostbus_subscriber"`
}
HostBusSubscriberIn consumes the named URL-bundle subscriber.
type HostBusSubscriberOut ¶
type HostBusSubscriberOut struct {
fx.Out
Subscriber chan hostbus.URLBundle `name:"harpoon_hostbus_subscriber"`
}
HostBusSubscriberOut provides the named URL-bundle subscriber used by both runtime and full-client Harpoon Fx graphs.
func NewHostBusSubscriber ¶
func NewHostBusSubscriber() HostBusSubscriberOut
NewHostBusSubscriber creates the bounded named subscriber channel.
type HostRegistrationParams ¶
type HostRegistrationParams struct {
fx.In
Lifecycle fx.Lifecycle
Logger *slog.Logger
Registry *Registry
Config *runtimeconfig.HarpoonConfig
ControlPlane *runtimeconfig.ControlPlaneConfig `optional:"true"`
DigestState *startupCatalogDigestState `optional:"true"`
StartupCatalog *hostbus.StartupCatalogState `optional:"true"`
Bus hostbus.HostRegistrationBus
Subscriber chan hostbus.URLBundle `name:"harpoon_hostbus_subscriber"`
}
HostRegistrationParams contains the shared dependencies for OAuth-discovered Harpoon target registration.
type ListTargetsRequest ¶
type ListTargetsRequest = listTargetsRequest
type ListTargetsResponse ¶
type ListTargetsResponse = listTargetsResponse
type MCPServerProvider ¶
MCPServerProvider is the narrow contract needed by shared Harpoon wiring. Full-client adapters can add tools and call observers without duplicating registry, transport, lifecycle, or route-log behavior.
type RedirectMismatchDetails ¶
type RedirectMismatchDetails = redirectMismatchDetails
Exported aliases let thin adapters preserve their existing package-local names without copying registry behavior.
type RedirectMismatchKind ¶
type RedirectMismatchKind = redirectMismatchKind
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores allowed targets keyed by label.
func NewRegistry ¶
NewRegistry constructs a registry seeded with the provided targets and a default limit.
func NewRegistryWithLimit ¶
func NewRegistryWithLimit(logger *slog.Logger, allowPlaintext bool, targets []Target, limit int) (*Registry, error)
NewRegistryWithLimit constructs a registry with a maximum number of targets.
func (*Registry) AllowsURL ¶
AllowsURL reports whether the URL exactly matches any registered target after normalization.
func (*Registry) ExactURL ¶
ExactURL returns the pre-normalization URL for a registered target. Thin adapters use this for capabilities whose protocol contract requires exact URL spelling rather than the normalized routing form.
func (*Registry) ExplainBlockedRedirect ¶
ExplainBlockedRedirect classifies why a redirect target missed the allow list.
func (*Registry) RegisterTarget ¶
RegisterTarget adds a target to the registry after validation.
func (*Registry) SummarizeTargets ¶
SummarizeTargets returns a stable, log-friendly projection of targets.
func (*Registry) TargetForURL ¶
TargetForURL returns the configured target whose URL exactly matches candidate.
type RegistryCounter ¶
type RegistryCounter interface {
Count() int
}
RegistryCounter is the minimal cross-package contract needed by polling and dispatch code to decide whether the Harpoon channel is routable.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides MCP tools for constrained HTTP access.
func NewServer ¶
func NewServer(cfg *runtimeconfig.HarpoonConfig, registry *Registry, logger *slog.Logger, opts ...ServerOption) (*Server, error)
NewServer constructs a harpoon MCP server.
func (*Server) CallTarget ¶
func (s *Server) CallTarget(ctx context.Context, params CallTargetRequest) (*CallTargetResponse, error)
CallTarget performs one constrained outbound call. It is exported so package-owned adapters can reuse the core without copying request logic.
func (*Server) ListTargets ¶
func (s *Server) ListTargets(params ListTargetsRequest) ListTargetsResponse
ListTargets returns the filtered target inventory.
func (*Server) UnixTransportCount ¶
UnixTransportCount reports the number of cached Unix-socket transports.
type ServerOption ¶
type ServerOption func(*serverOptions)
ServerOption configures optional server behavior.
func WithCallObserver ¶
func WithCallObserver(observer CallObserver) ServerOption
WithCallObserver adds a package-owned call receipt observer. The runtime binary does not install any optional observers.
func WithHTTPTransport ¶
func WithHTTPTransport(rt http.RoundTripper) ServerOption
WithHTTPTransport sets the HTTP transport used for Harpoon outbound calls.
func WithInstructions ¶
func WithInstructions(instructions string) ServerOption
WithInstructions overrides the default MCP server instructions.
func WithMeter ¶
func WithMeter(meter metric.Meter) ServerOption
WithMeter configures the meter used for Harpoon metrics.
func WithToolRegistrar ¶
func WithToolRegistrar(registrar ToolRegistrar) ServerOption
WithToolRegistrar adds a package-owned tool registration hook. The runtime binary does not install any optional hooks.
type ServiceFactory ¶
type ServiceFactory func(*Registry, *slog.Logger, []ServerOption) (MCPServerProvider, error)
ServiceFactory constructs the flavor-specific MCP server over the shared registry and transport options.
type SharedServiceOutputs ¶
type SharedServiceOutputs struct {
}
SharedServiceOutputs contains the common outputs produced for either Harpoon flavor.
func NewSharedService ¶
func NewSharedService(p SharedServiceParams) (SharedServiceOutputs, error)
NewSharedService owns the common Harpoon registry, outbound transport, route logging, lifecycle, and in-memory MCP transport wiring.
type SharedServiceParams ¶
type SharedServiceParams struct {
}
SharedServiceParams contains the runtime-safe dependencies shared by the runtime and full-client Harpoon graphs.
type Target ¶
type Target struct {
Label string
Description string
Category string
Source string
Tags []string
InclusionReason string
BaseURL *url.URL
UnixSocketPath string
// contains filtered or unexported fields
}
Target describes a registered outbound HTTP target.
func ConvertTargets ¶
func ConvertTargets(targets []runtimeconfig.HarpoonTarget) []Target
ConvertTargets projects config targets into registered runtime targets.
type TargetInfo ¶
type TargetInfo = targetInfo
type TargetRegistrar ¶
TargetRegistrar allows programmatic target registration during startup.
func WithTarget ¶
func WithTarget(target Target) TargetRegistrar
WithTarget returns a registrar that registers the provided target.
type ToolRegistrar ¶
ToolRegistrar adds optional tools to a Harpoon MCP server without making the runtime core import the package that owns those tools.
type URLRewriter ¶
type URLRewriter = urlRewriter
URLRewriter is the shared URL transformation helper exposed to thin adapters without duplicating rewrite behavior.
func NewURLRewriter ¶
func NewURLRewriter(targets []Target) *URLRewriter
NewURLRewriter builds a shared URL transformation helper.