Documentation
¶
Index ¶
- Constants
- func CreateHttpClientForSession(ctx context.Context, session server.ClientSession, logger *log.Logger) *http.Client
- func CreateTfeClientForSession(ctx context.Context, session server.ClientSession, logger *log.Logger) (*tfe.Client, error)
- func DeleteHttpClient(sessionId string)
- func DeleteTfeClient(sessionId string)
- func EndSessionHandler(_ context.Context, session server.ClientSession, logger *log.Logger)
- func GetHttpClient(sessionId string) *http.Client
- func GetHttpClientFromContext(ctx context.Context, logger *log.Logger) (*http.Client, error)
- func GetLatestProviderVersion(httpClient *http.Client, providerNamespace string, providerName string, ...) (string, error)
- func GetProviderOverviewDocs(httpClient *http.Client, providerVersionID string, logger *log.Logger) (string, error)
- func GetProviderResourceDocs(httpClient *http.Client, providerDocsID string, logger *log.Logger) (string, error)
- func GetProviderVersionID(httpClient *http.Client, namespace string, name string, version string, ...) (string, error)
- func GetTfeClient(sessionId string) *tfe.Client
- func GetTfeClientFromContext(ctx context.Context, logger *log.Logger) (*tfe.Client, error)
- func IsLocalHost(host string) bool
- func NewHttpClient(sessionId string, terraformSkipTLSVerify bool, logger *log.Logger) *http.Client
- func NewSecurityHandler(handler http.Handler, allowedOrigins []string, corsMode string, ...) http.Handler
- func NewSessionHandler(ctx context.Context, session server.ClientSession, logger *log.Logger)
- func NewTfeClient(sessionId string, terraformAddress string, terraformSkipTLSVerify bool, ...) (*tfe.Client, error)
- func SendRegistryCall(client *http.Client, method string, uri string, logger *log.Logger, ...) ([]byte, error)
- func SetToolRegistryCallback(callback ToolRegistryCallback)
- func TerraformContextMiddleware(logger *log.Logger) func(http.Handler) http.Handler
- type CORSConfig
- type ModuleDependency
- type ModuleDetail
- type ModuleInput
- type ModuleMetadata
- type ModuleOutput
- type ModulePart
- type ModuleProviderDependency
- type ModuleResource
- type ProviderDetail
- type ProviderDoc
- type ProviderDocData
- type ProviderDocs
- type ProviderList
- type ProviderOverviewStruct
- type ProviderResourceDetails
- type ProviderVersionLatest
- type ProviderVersionList
- type RateLimitConfig
- type RateLimitMiddleware
- type TLSConfig
- type TerraformModuleVersionDetails
- type TerraformModules
- type TerraformPolicyDetails
- type TerraformPolicyList
- type ToolRegistryCallback
- type WorkspaceToolResponse
Constants ¶
const ( TerraformAddress = "TFE_ADDRESS" TerraformToken = "TFE_TOKEN" TerraformSkipTLSVerify = "TFE_SKIP_TLS_VERIFY" DefaultTerraformAddress = "https://app.terraform.io" )
const DefaultPublicRegistryURL = "https://registry.terraform.io"
Variables ¶
This section is empty.
Functions ¶
func CreateHttpClientForSession ¶ added in v0.3.0
func CreateHttpClientForSession(ctx context.Context, session server.ClientSession, logger *log.Logger) *http.Client
CreateHttpClientForSession creates only an HTTP client for the session
func CreateTfeClientForSession ¶ added in v0.3.0
func CreateTfeClientForSession(ctx context.Context, session server.ClientSession, logger *log.Logger) (*tfe.Client, error)
CreateTfeClientForSession creates only a TFE client for the session
func DeleteHttpClient ¶ added in v0.3.0
func DeleteHttpClient(sessionId string)
DeleteHttpClient removes the HTTP client for the given session
func DeleteTfeClient ¶ added in v0.3.0
func DeleteTfeClient(sessionId string)
DeleteTfeClient removes the TFE client for the given session
func EndSessionHandler ¶ added in v0.3.0
EndSessionHandler cleans up clients when the session ends
func GetHttpClient ¶ added in v0.3.0
GetHttpClient retrieves the HTTP client for the given session
func GetHttpClientFromContext ¶ added in v0.3.0
GetHttpClientFromContext extracts HTTP client from the MCP context
func GetProviderOverviewDocs ¶
func GetProviderResourceDocs ¶
func GetProviderVersionID ¶
func GetProviderVersionID(httpClient *http.Client, namespace string, name string, version string, logger *log.Logger) (string, error)
Every provider version has a unique ID, which is used to identify the provider version in the registry and its specific documentation https://registry.terraform.io/v2/providers/hashicorp/aws?include=provider-versions
func GetTfeClient ¶ added in v0.3.0
func GetTfeClient(sessionId string) *tfe.Client
GetTfeClient retrieves the TFE client for the given session
func GetTfeClientFromContext ¶ added in v0.3.0
GetTfeClientFromContext extracts TFE client from the MCP context
func IsLocalHost ¶ added in v0.3.0
func NewHttpClient ¶ added in v0.3.0
NewHttpClient creates a new HTTP client for the given session
func NewSecurityHandler ¶
func NewSecurityHandler(handler http.Handler, allowedOrigins []string, corsMode string, logger *log.Logger) http.Handler
NewSecurityHandler creates a new security handler
func NewSessionHandler ¶ added in v0.3.0
NewSessionHandler initializes clients for the session
func NewTfeClient ¶ added in v0.3.0
func NewTfeClient(sessionId string, terraformAddress string, terraformSkipTLSVerify bool, terraformToken string, logger *log.Logger) (*tfe.Client, error)
NewTfeClient creates a new TFE client for the given session
func SendRegistryCall ¶
func SetToolRegistryCallback ¶ added in v0.3.0
func SetToolRegistryCallback(callback ToolRegistryCallback)
SetToolRegistryCallback sets the callback for tool registry operations
func TerraformContextMiddleware ¶ added in v0.3.0
TerraformContextMiddleware adds Terraform-related header values to the request context This middleware extracts Terraform configuration from HTTP headers, query parameters, or environment variables and adds them to the request context for use by MCP tools
Types ¶
type CORSConfig ¶
type CORSConfig struct {
AllowedOrigins []string
Mode string // "strict", "development", "disabled"
}
CORSConfig holds CORS configuration
func LoadCORSConfigFromEnv ¶
func LoadCORSConfigFromEnv() CORSConfig
LoadCORSConfigFromEnv loads CORS configuration from environment variables
type ModuleDependency ¶
type ModuleDependency struct {
Name string `json:"name"`
Source string `json:"source"`
Version string `json:"version"`
}
ModuleDependency represents a Terraform module dependency.
type ModuleDetail ¶
type ModuleInput ¶
type ModuleInput struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
Default any `json:"default"` // Can be string, bool, number, etc.
Required bool `json:"required"`
}
ModuleInput represents a Terraform module input variable.
type ModuleMetadata ¶ added in v0.3.2
type ModuleMetadata struct {
Data struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
GitRefTag string `json:"git-ref-tag"`
GitRepoURL string `json:"git-repo-url"`
InputVariables []struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
Required bool `json:"required"`
Sensitive bool `json:"sensitive"`
} `json:"input-variables"`
Name string `json:"name"`
SourceURL string `json:"source-url"`
Version string `json:"version"`
NoCode bool `json:"no-code"`
} `json:"attributes"`
} `json:"data"`
}
type ModuleOutput ¶
ModuleOutput represents a Terraform module output value.
type ModulePart ¶
type ModulePart struct {
Path string `json:"path"`
Name string `json:"name"`
Readme string `json:"readme"`
Empty bool `json:"empty"`
Inputs []ModuleInput `json:"inputs"`
Outputs []ModuleOutput `json:"outputs"`
Dependencies []ModuleDependency `json:"dependencies"`
ProviderDependencies []ModuleProviderDependency `json:"provider_dependencies"`
Resources []ModuleResource `json:"resources"`
}
ModulePart represents the structure of the root, submodules, or examples within a Terraform module version details response.
type ModuleProviderDependency ¶
type ModuleProviderDependency struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Source string `json:"source"`
Version string `json:"version"`
}
ModuleProviderDependency represents a Terraform provider dependency.
type ModuleResource ¶
ModuleResource represents a resource within a Terraform module.
type ProviderDetail ¶
type ProviderDoc ¶
type ProviderDoc struct {
ID string `json:"id"`
Title string `json:"title"`
Path string `json:"path"`
Slug string `json:"slug"`
Category string `json:"category"`
Subcategory string `json:"subcategory"`
Language string `json:"language"`
}
ProviderDoc represents a single documentation item.
type ProviderDocData ¶
type ProviderDocData struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Category string `json:"category"`
Language string `json:"language"`
Path string `json:"path"`
Slug string `json:"slug"`
Subcategory interface{} `json:"subcategory"`
Title string `json:"title"`
Truncated bool `json:"truncated"`
} `json:"attributes"`
Links struct {
Self string `json:"self"`
} `json:"links"`
}
type ProviderDocs ¶
type ProviderDocs struct {
ID string `json:"id"`
Owner string `json:"owner"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Alias string `json:"alias"`
Version string `json:"version"`
Tag string `json:"tag"`
Description string `json:"description"`
Source string `json:"source"`
PublishedAt string `json:"published_at"`
Downloads int64 `json:"downloads"`
Tier string `json:"tier"`
LogoURL string `json:"logo_url"`
Versions []string `json:"versions"`
Docs []ProviderDoc `json:"docs"`
}
ProviderDocs represents the structure of the provider details response.
type ProviderList ¶
type ProviderList struct {
Data []struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Alias string `json:"alias"`
Description string `json:"description"`
Downloads int `json:"downloads"`
Featured bool `json:"featured"`
FullName string `json:"full-name"`
LogoURL string `json:"logo-url"`
Name string `json:"name"`
Namespace string `json:"namespace"`
OwnerName string `json:"owner-name"`
RobotsNoindex bool `json:"robots-noindex"`
Source string `json:"source"`
Tier string `json:"tier"`
Unlisted bool `json:"unlisted"`
Warning string `json:"warning"`
} `json:"attributes"`
Links struct {
Self string `json:"self"`
} `json:"links"`
} `json:"data"`
Links struct {
First string `json:"first"`
Last string `json:"last"`
Next string `json:"next"`
Prev any `json:"prev"`
} `json:"links"`
Meta struct {
Pagination struct {
PageSize int `json:"page-size"`
CurrentPage int `json:"current-page"`
NextPage int `json:"next-page"`
PrevPage any `json:"prev-page"`
TotalPages int `json:"total-pages"`
TotalCount int `json:"total-count"`
} `json:"pagination"`
} `json:"meta"`
}
ProviderList represents the structure of the provider list response. https://registry.terraform.io/v2/providers?filter[tier]=official
type ProviderOverviewStruct ¶
type ProviderOverviewStruct struct {
Data []ProviderDocData `json:"data"`
}
ProviderOverviewStruct represents the structure of the provider overview (how to use it) response. https://registry.terraform.io/v2/provider-docs?filter[provider-version]=70800&filter[category]=overview&filter[slug]=index
type ProviderResourceDetails ¶
type ProviderResourceDetails struct {
Data struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Category string `json:"category"`
Content string `json:"content"`
Language string `json:"language"`
Path string `json:"path"`
Slug string `json:"slug"`
Subcategory string `json:"subcategory"`
Title string `json:"title"`
Truncated bool `json:"truncated"`
} `json:"attributes"`
Links struct {
Self string `json:"self"`
} `json:"links"`
} `json:"data"`
}
ProviderResourceDetails represents the structure of the provider resource details response. https://registry.terraform.io/v2/provider-docs/8814952
type ProviderVersionLatest ¶
type ProviderVersionLatest struct {
ID string `json:"id"`
Owner string `json:"owner"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Alias string `json:"alias"`
Version string `json:"version"`
Tag string `json:"tag"`
Description string `json:"description"`
Source string `json:"source"`
PublishedAt time.Time `json:"published_at"`
Downloads int64 `json:"downloads"`
Tier string `json:"tier"`
LogoURL string `json:"logo_url"`
Versions []string `json:"versions"`
}
ProviderLatest represents the structure of the latest provider response. https://registry.terraform.io/v1/providers/hashicorp/consul/latest
type ProviderVersionList ¶
type ProviderVersionList struct {
Data struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Alias string `json:"alias"`
Description string `json:"description"`
Downloads int64 `json:"downloads"`
Featured bool `json:"featured"`
FullName string `json:"full-name"`
LogoURL string `json:"logo-url"`
Name string `json:"name"`
Namespace string `json:"namespace"`
OwnerName string `json:"owner-name"`
RobotsNoindex bool `json:"robots-noindex"`
Source string `json:"source"`
Tier string `json:"tier"`
Unlisted bool `json:"unlisted"`
Warning string `json:"warning"`
} `json:"attributes"`
Relationships struct {
ProviderVersions struct {
Data []struct {
ID string `json:"id"`
Type string `json:"type"`
} `json:"data"`
Links struct {
Related string `json:"related"`
} `json:"links"`
} `json:"provider-versions"`
} `json:"relationships"`
Links struct {
Self string `json:"self"`
} `json:"links"`
} `json:"data"`
Included []struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Description string `json:"description"`
Downloads int `json:"downloads"`
PublishedAt time.Time `json:"published-at"`
Tag string `json:"tag"`
Version string `json:"version"`
} `json:"attributes"`
Links struct {
Self string `json:"self"`
} `json:"links"`
} `json:"included"`
}
ProviderVersion represents structure with list of provider versions.
type RateLimitConfig ¶ added in v0.3.0
type RateLimitConfig struct {
GlobalLimit rate.Limit // Global requests per second
GlobalBurst int // Global burst capacity
PerSessionLimit rate.Limit // Per-session requests per second
PerSessionBurst int // Per-session burst capacity
}
RateLimitConfig holds rate limiting configuration
func DefaultRateLimitConfig ¶ added in v0.3.0
func DefaultRateLimitConfig() RateLimitConfig
DefaultRateLimitConfig returns a sensible default configuration
func LoadRateLimitConfigFromEnv ¶ added in v0.3.0
func LoadRateLimitConfigFromEnv() RateLimitConfig
LoadRateLimitConfigFromEnv loads rate limiting configuration from environment variables
type RateLimitMiddleware ¶ added in v0.3.0
type RateLimitMiddleware struct {
// contains filtered or unexported fields
}
RateLimitMiddleware creates a comprehensive rate limiting middleware
func NewRateLimitMiddleware ¶ added in v0.3.0
func NewRateLimitMiddleware(config RateLimitConfig, logger *log.Logger) *RateLimitMiddleware
NewRateLimitMiddleware creates a new rate limiting middleware
func (*RateLimitMiddleware) CleanupSessions ¶ added in v0.3.0
func (m *RateLimitMiddleware) CleanupSessions(activeSessions []string)
CleanupSessions removes inactive session limiters to prevent memory leaks
func (*RateLimitMiddleware) Middleware ¶ added in v0.3.0
func (m *RateLimitMiddleware) Middleware() server.ToolHandlerMiddleware
Middleware returns the tool handler middleware function
type TLSConfig ¶ added in v0.3.0
func GetTLSConfigFromEnv ¶ added in v0.3.0
GetTLSConfigFromEnv loads TLS cert/key file paths from environment variables
type TerraformModuleVersionDetails ¶
type TerraformModuleVersionDetails struct {
ID string `json:"id"`
Owner string `json:"owner"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Version string `json:"version"`
Provider string `json:"provider"`
ProviderLogoURL string `json:"provider_logo_url"`
Description string `json:"description"`
Source string `json:"source"`
Tag string `json:"tag"`
PublishedAt time.Time `json:"published_at"`
Downloads int64 `json:"downloads"`
Verified bool `json:"verified"`
Root ModulePart `json:"root"`
Submodules []ModulePart `json:"submodules"`
Examples []ModulePart `json:"examples"`
Providers []string `json:"providers"`
Versions []string `json:"versions"`
Deprecation any `json:"deprecation"` // Assuming it can be null or an object
}
TerraformModuleVersionDetails represents the detailed structure of a specific Terraform module version response.
type TerraformModules ¶
type TerraformModules struct {
Metadata struct {
Limit int `json:"limit"` // Limit is 15
CurrentOffset int `json:"current_offset"` // always starts at 0
NextOffset int `json:"next_offset"` // always starts at 15
PrevOffset int `json:"prev_offset"` // always starts at nil
NextURL string `json:"next_url"`
PrevURL string `json:"prev_url"`
} `json:"meta"`
Data []struct {
ID string `json:"id"`
Owner string `json:"owner"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Version string `json:"version"`
Provider string `json:"provider"`
Description string `json:"description"`
Source string `json:"source"`
Tag string `json:"tag"`
PublishedAt time.Time `json:"published_at"`
Downloads int64 `json:"downloads"`
Verified bool `json:"verified"`
} `json:"modules"`
}
TerraformModule represents the structure of a Terraform module list response. Note: The API seems to return different structures, this one matches the format where the top-level key is "modules".
type TerraformPolicyDetails ¶
type TerraformPolicyDetails struct {
Data struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Description string `json:"description"`
Downloads int `json:"downloads"`
PublishedAt time.Time `json:"published-at"`
Readme string `json:"readme"`
Source string `json:"source"`
Tag string `json:"tag"`
Version string `json:"version"`
} `json:"attributes"`
Relationships struct {
Policies struct {
Data []struct {
Type string `json:"type"`
ID string `json:"id"`
} `json:"data"`
} `json:"policies"`
PolicyLibrary struct {
Data struct {
Type string `json:"type"`
ID string `json:"id"`
} `json:"data"`
} `json:"policy-library"`
PolicyModules struct {
Data []struct {
Type string `json:"type"`
ID string `json:"id"`
} `json:"data"`
} `json:"policy-modules"`
} `json:"relationships"`
Links struct {
Self string `json:"self"`
} `json:"links"`
} `json:"data"`
Included []struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Description string `json:"description"`
Downloads int `json:"downloads"`
FullName string `json:"full-name"`
Name string `json:"name"`
Shasum string `json:"shasum"`
ShasumType string `json:"shasum-type"`
Title string `json:"title"`
} `json:"attributes"`
Links struct {
Self string `json:"self"`
} `json:"links"`
} `json:"included"`
}
TerraformPolicyDetails represents the detailed response structure for a Terraform policy as returned by the Terraform Registry API. https://registry.terraform.io/v2/policies/hashicorp/CIS-Policy-Set-for-AWS-Terraform/1.0.1?include=policies,policy-modules,policy-library
type TerraformPolicyList ¶
type TerraformPolicyList struct {
Data []struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Downloads int `json:"downloads"`
FullName string `json:"full-name"`
Ingress string `json:"ingress"`
Name string `json:"name"`
Namespace string `json:"namespace"`
OwnerName string `json:"owner-name"`
Source string `json:"source"`
Title string `json:"title"`
Verified bool `json:"verified"`
} `json:"attributes"`
Relationships struct {
LatestVersion struct {
Data struct {
ID string `json:"id"`
Type string `json:"type"`
} `json:"data"`
Links struct {
Related string `json:"related"`
} `json:"links"`
} `json:"latest-version"`
} `json:"relationships"`
Links struct {
Self string `json:"self"`
} `json:"links"`
} `json:"data"`
Included []struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes struct {
Description string `json:"description"`
Downloads int `json:"downloads"`
PublishedAt time.Time `json:"published-at"`
Readme string `json:"readme"`
Source string `json:"source"`
Tag string `json:"tag"`
Version string `json:"version"`
} `json:"attributes"`
Links struct {
Self string `json:"self"`
} `json:"links"`
} `json:"included"`
Links struct {
First string `json:"first"`
Last string `json:"last"`
Next any `json:"next"`
Prev any `json:"prev"`
} `json:"links"`
Meta struct {
Pagination struct {
PageSize int `json:"page-size"`
CurrentPage int `json:"current-page"`
NextPage any `json:"next-page"`
PrevPage any `json:"prev-page"`
TotalPages int `json:"total-pages"`
TotalCount int `json:"total-count"`
} `json:"pagination"`
} `json:"meta"`
}
TerraformPolicyList represents the response structure for a list of Terraform policies retrieved from the HashiCorp Terraform Registry API. https://registry.terraform.io/v2/policies?page%5Bsize%5D=100&include=latest-version
type ToolRegistryCallback ¶ added in v0.3.0
type ToolRegistryCallback interface {
RegisterSessionWithTFE(sessionID string)
UnregisterSessionWithTFE(sessionID string)
}
ToolRegistryCallback defines the interface for interacting with the tool registry