Documentation
¶
Overview ¶
Package mcpserver implements the Model Context Protocol (MCP) server for HTCondor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsReadOnlyTool ¶
IsReadOnlyTool reports whether the named MCP tool is in the read-only allowlist. Used by both the in-package scope filter on tools/list and the httpserver-side OAuth2 scope check on tools/call. Putting the canonical list in this package keeps the two paths from drifting.
Types ¶
type Config ¶
type Config struct {
ScheddName string // Schedd name
ScheddAddr string // Schedd address (e.g., "127.0.0.1:9618"). If empty, discovered from collector.
// ScheddHost is the SCHEDD_HOST setting: the host (optionally
// "name@host", optionally with a port) whose schedd this server
// should talk to. Consulted when neither ScheddAddr nor ScheddName
// is set, and it selects that host's schedd rather than whichever
// one the collector lists first.
ScheddHost string
Schedd *htcondor.Schedd // Pre-configured Schedd instance (optional, if provided, ScheddName/ScheddAddr are ignored)
SigningKeyPath string // Path to token signing key (optional, for token generation)
TrustDomain string // Trust domain for token issuer (optional)
UIDDomain string // UID domain for generated token username (optional)
HTTPBaseURL string // Base URL for HTTP API (e.g., "http://localhost:8080") for file download links
Collector *htcondor.Collector // Collector for metrics and discovery (optional)
Credd htcondor.CreddClient // Optional credd client for credential management
Instructions string // Server-level instructions provided to all agents in the MCP initialize response
EnableMetrics bool // Enable metrics collection (default: true if Collector is set)
MetricsCacheTTL time.Duration // Metrics cache TTL (default: 10s)
Logger *logging.Logger // Logger instance (optional, creates default if nil)
Stdin io.Reader // Input stream (default: os.Stdin)
Stdout io.Writer // Output stream (default: os.Stdout)
// AdminUsers is the list of authenticated subjects (JWT `sub` /
// authenticated username) who get admin treatment in tool
// dispatch — most importantly, they are exempt from the
// per-tool owner-scope wrapper that otherwise restricts queries
// and mutations to the caller's own jobs. Match must be exact
// against the value returned by
// htcondor.GetAuthenticatedUserFromContext (typically
// "user@uid.domain"). Empty list = no admin users (default).
AdminUsers []string
// HTCondorConfig is the ambient HTCondor configuration. When set (together with a
// Collector), the htcondordb-backed tools are enabled: the server discovers the database
// via the collector and authenticates to it using this config's SEC_* knobs. nil disables
// those tools.
HTCondorConfig *config.Config
// Delegated marks a server that acts on behalf of remote callers
// rather than running as the user, which is the case when webapi
// embeds it behind HTTP. It changes what an unknown caller means:
// a delegated server must refuse an owner-scoped tool it cannot
// confine, while a server run from a user's shell over stdio is
// already confined by being that user's process. Default false, so
// the stdio CLI keeps working exactly as before.
Delegated bool
// htcondordb mirror routing, mirroring the REST handler's config of
// the same name so one daemon routes both surfaces identically. See
// dbmirror.Options.
DBMirrorName string // HTTP_API_DBMIRROR_NAME
DBMirrorAddress string // HTTP_API_DBMIRROR_ADDRESS
DBMirrorRequired bool // HTTP_API_DBMIRROR_REQUIRED
}
Config holds server configuration
type MCPError ¶
type MCPError struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
MCPError represents an MCP error
type MCPMessage ¶
type MCPMessage struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id,omitempty"`
Method string `json:"method,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
Result interface{} `json:"result,omitempty"`
Error *MCPError `json:"error,omitempty"`
}
MCPMessage represents an MCP protocol message
type OutputFile ¶
type OutputFile struct {
Filename string `json:"filename"`
Data string `json:"data"`
IsTruncated bool `json:"is_truncated"`
URL string `json:"url,omitempty"`
IsBase64 bool `json:"is_base64"`
Size int64 `json:"size"`
}
OutputFile represents a file from the job's output sandbox
type Resource ¶
type Resource struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description"`
MimeType string `json:"mimeType,omitempty"`
}
Resource represents an MCP resource
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the MCP server
func (*Server) HandleMessage ¶
func (s *Server) HandleMessage(ctx context.Context, msg *MCPMessage) *MCPMessage
HandleMessage is the public interface for handling MCP messages (used by HTTP handler)