config

package
v1.39.2 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is the current version of the MCP server. It is set at build time using -ldflags "-X 'github.com/teamwork/mcp/pkg/config.Version=1.0.0'". If not set, it defaults to "dev".

Functions

func NewMCPClient

func NewMCPClient(
	ctx context.Context,
	resources Resources,
	transport mcp.Transport,
	options *mcp.ClientOptions,
) (*mcp.Client, *mcp.ClientSession, error)

NewMCPClient creates a new MCP client.

func NewMCPServer

func NewMCPServer(resources Resources, groups ...*toolsets.ToolsetGroup) *mcp.Server

NewMCPServer creates a new MCP server with the given resources and toolset group.

Types

type Option

type Option func(*options)

Option adjusts what Load builds. A server built on this package uses these to identify itself and to read its own environment, rather than inheriting this server's name and TW_MCP_ variables.

func WithDefaultMCPURL added in v1.30.0

func WithDefaultMCPURL(url string) Option

WithDefaultMCPURL sets the base URL this server reports as its own resource identifier when the environment does not say. It must identify *this* server: it is the "resource" in the RFC 9728 protected-resource metadata and the resource_metadata pointer in every 401 challenge, so a server left on another server's URL sends clients to authorise against the wrong resource.

The environment variable still wins, so a deployment can override it.

func WithEnvPrefix

func WithEnvPrefix(prefix string) Option

WithEnvPrefix sets the prefix every configuration variable is read under. Defaults to "TW_MCP_", so TW_MCP_SERVER_ADDRESS and friends. A second server sharing a deployment needs its own prefix to be configured independently.

func WithProfiles

func WithProfiles(profiles ...string) Option

WithProfiles sets the named toolset profiles this server exposes as URL path prefixes.

func WithServerIdentity

func WithServerIdentity(name, title string) Option

WithServerIdentity sets the name and title the MCP server reports in the initialize handshake. Clients key their connector UI off these, so two servers must not share them.

type Resources

type Resources struct {

	// Info stores environment variables mappings.
	Info struct {
		// Name is the MCP server name reported in the initialize handshake.
		Name string
		// Title is the human-readable MCP server title reported in the initialize
		// handshake.
		Title string
		// Version is the current version of the MCP server.
		Version string
		// ServerAddress is the address of the server. This is useful for the MCP
		// server in HTTP mode.
		ServerAddress string
		// Environment is the environment this app is running in.
		Environment string
		// AWSRegion is the AWS region this app is running in.
		AWSRegion string
		// MCPURL is the base URL of the MCP server. This is useful for the MCP
		// server in HTTP mode.
		MCPURL string
		// MCPProfiles is the list of profiles to be enabled in the MCP server. This
		// is useful for the MCP server in HTTP mode, where different profiles can
		// be accessed via different URL paths (e.g. "/project-manager/endpoint" for
		// the "project-manager" profile).
		MCPProfiles []string
		// APIURL is the base URL of the Teamwork API.
		APIURL string
		// HAProxyURL is the URL of the HAProxy instance. This is useful for the MCP
		// server in HTTP mode.
		HAProxyURL string
		// BearerToken is the bearer token to be used to authenticate with Teamwork
		// API. This is useful for the MCP server in STDIO mode.
		BearerToken string
		// Log contains the logging configuration.
		Log struct {
			// Format is the format of the logs. It can be "json" or "text".
			Format string
			// Level is the log level. It can be "debug", "info", "warn", "error" or
			// "fatal".
			Level string
			// SentryDSN is the Sentry DSN to be used for error reporting.
			SentryDSN string
		}
		// DatadogAPM contains the configuration for Datadog APM. This is useful for
		// the MCP server in HTTP mode.
		DatadogAPM struct {
			// Enabled indicates if Datadog APM is enabled.
			Enabled bool
			// Service is the name of the service to be used in Datadog APM.
			Service string
			// AgentHost is the host of the Datadog Agent.
			AgentHost string
			// AgentPort is the port of the Datadog Agent.
			AgentPort string
			// StatsdPort is the port of the DogStatsD Agent.
			StatsdPort string
			// Environment is the environment to be used in Datadog APM.
			Environment string
			// Version is the version of the service to be used in Datadog APM.
			Version string
		}
	}
	// contains filtered or unexported fields
}

Resources stores all the resources loaded in the startup.

func Load

func Load(logOutput io.Writer, opts ...Option) (Resources, func())

Load loads the configuration for the MCP service. Options let a server built on this package supply its own identity, environment-variable prefix and toolset profiles; without them it loads this server's defaults.

func (*Resources) DeskClient

func (r *Resources) DeskClient() *desksdk.Client

DeskClient returns the Teamwork Desk Client for use.

func (*Resources) Logger

func (r *Resources) Logger() *slog.Logger

Logger returns the logger resource. A Resources that did not come from Load carries none, so callers get the default logger rather than dereferencing nil — a server built on this package may well assemble one by hand.

func (*Resources) TeamworkEngine

func (r *Resources) TeamworkEngine() *twapi.Engine

TeamworkEngine returns the Teamwork Engine instance to be used to make requests to Teamwork API.

func (*Resources) TeamworkHTTPClient

func (r *Resources) TeamworkHTTPClient() *http.Client

TeamworkHTTPClient returns the HTTP client to be used to make requests to Teamwork API.

Jump to

Keyboard shortcuts

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