config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config loads and validates runtime configuration for the ado-mcp server from environment variables.

All configuration is supplied via the environment so the server can run as a stdio subprocess launched by an MCP client (Claude Desktop/Code, Cursor, …), where command-line flags are awkward to pass.

Index

Constants

View Source
const (
	EnvOrgURL            = "ADO_ORG_URL"         // e.g. https://dev.azure.com/myorg
	EnvPAT               = "ADO_PAT"             // Azure DevOps Personal Access Token
	EnvSevenPaceOrg      = "SEVENPACE_ORG"       // 7pace account name (builds the timehub URL)
	EnvSevenPaceToken    = "SEVENPACE_TOKEN"     // 7pace bearer token
	EnvSevenPaceBase     = "SEVENPACE_API_BASE"  // full 7pace OData (read) API base URL override
	EnvSevenPaceRestBase = "SEVENPACE_REST_BASE" // full 7pace REST (write) API base URL override
	EnvToolsets          = "ADO_TOOLSETS"        // comma-separated toolset names, or "all"
	EnvReadOnly          = "ADO_READONLY"        // "true" disables all write tools
	EnvHome              = "ADO_MCP_HOME"        // overrides the application home directory
	EnvCacheTTL          = "ADO_CACHE_TTL"       // GET response cache lifetime, e.g. "30s"; "0" or "off" disables
)

Environment variable names recognised by the server.

View Source
const EnvFile = ".env"

EnvFile is the default dotenv filename loaded for local development.

Variables

This section is empty.

Functions

func Dirs

func Dirs() (home, data string, err error)

Dirs resolves the application's home and data directories without requiring Azure DevOps credentials. It is used by commands that only touch local state (such as the work-log journal), which must work even when no PAT is set.

func LoadEnvFile

func LoadEnvFile(path string) error

LoadEnvFile loads KEY=VALUE pairs from a dotenv file into the process environment. It is intended for local development: run `cp .env.example .env`, fill it in, and the server picks it up on startup.

Lines may be blank, comments (#...), or KEY=VALUE (an optional leading "export " is ignored, and surrounding single/double quotes are stripped from the value). A variable that already has a non-empty value in the environment is left untouched, so real shell variables take precedence over the file. A missing file is not an error.

Types

type Config

type Config struct {
	// OrgURL is the Azure DevOps organization base URL, e.g.
	// "https://dev.azure.com/myorg". It never has a trailing slash.
	OrgURL string

	// PAT is the Azure DevOps Personal Access Token used for Basic auth.
	PAT string

	// SevenPaceOrg is the 7pace account name used to build the API base URL
	// "https://{org}.timehub.7pace.com/api". Empty disables 7pace tools.
	SevenPaceOrg string

	// SevenPaceToken is the 7pace bearer token. Empty disables 7pace tools.
	SevenPaceToken string

	// SevenPaceBase, when set, is the full 7pace OData (read) API base URL
	// (e.g. "https://myorg.timehub.7pace.com/api/odata/v3.2"). Overrides the
	// URL derived from SevenPaceOrg.
	SevenPaceBase string

	// SevenPaceRestBase, when set, is the full 7pace REST (write) API base
	// URL. Overrides the URL derived from SevenPaceOrg. The write API is a
	// separate product surface from the read-only OData Reporting API, so
	// this is a distinct override from SevenPaceBase.
	SevenPaceRestBase string

	// Toolsets is the set of enabled toolset names. A nil/empty set means "all".
	Toolsets []string

	// ReadOnly, when true, causes write (mutating) tools to be skipped at
	// registration time so they are never exposed to the client.
	ReadOnly bool

	// HomeDir is the application's base directory under the user's config
	// directory (e.g. ~/.config/ado-mcp), or ADO_MCP_HOME when set.
	HomeDir string

	// DataDir is the data subdirectory within HomeDir (HomeDir/data).
	DataDir string

	// CacheTTL is how long GET responses from Azure DevOps and 7pace are
	// cached in memory. Zero disables caching. Defaults to 30s; set
	// ADO_CACHE_TTL=0 (or "off") to disable, or a duration string (e.g. "1m")
	// to change it.
	CacheTTL time.Duration
}

Config holds validated server configuration.

func Load

func Load() (*Config, error)

Load reads configuration from the process environment and validates it. It returns an error describing every problem found, so misconfiguration can be fixed in one pass.

func (*Config) AllToolsets

func (c *Config) AllToolsets() bool

AllToolsets reports whether every toolset should be enabled.

func (*Config) EnsureDirs

func (c *Config) EnsureDirs() error

EnsureDirs creates the application's home and data directories if they do not already exist. It is safe to call repeatedly and is a no-op when the paths could not be resolved.

func (*Config) SevenPaceBaseURL

func (c *Config) SevenPaceBaseURL() string

SevenPaceBaseURL returns the 7pace API base URL: the explicit SEVENPACE_API_BASE override if set, otherwise the OData base derived from the account name (https://{org}.timehub.7pace.com/api/odata/{version}).

func (*Config) SevenPaceEnabled

func (c *Config) SevenPaceEnabled() bool

SevenPaceEnabled reports whether 7pace integration is configured. It needs a token plus either an account name or an explicit base URL.

func (*Config) SevenPaceRestBaseURL added in v0.1.2

func (c *Config) SevenPaceRestBaseURL() string

SevenPaceRestBaseURL returns the 7pace write-capable REST API base URL: the explicit SEVENPACE_REST_BASE override if set, otherwise a best-effort URL derived from the account name. Unlike the OData Reporting API (read only, verified against this codebase's existing integration), the exact path/shape of 7pace's write API has not been verified against a live account — if this default is wrong, set SEVENPACE_REST_BASE explicitly.

func (*Config) ToolsetEnabled

func (c *Config) ToolsetEnabled(name string) bool

ToolsetEnabled reports whether the named toolset should be registered.

Jump to

Keyboard shortcuts

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