shadcnui

package
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShadcnDocsURL        = "https://ui.shadcn.com"
	ShadcnDocsComponents = ShadcnDocsURL + "/docs/components"
	ShadcnGitHubURL      = "https://github.com/shadcn-ui/ui"
	ShadcnRawGitHubURL   = "https://raw.githubusercontent.com/shadcn-ui/ui/main"

	// DefaultShadcnRateLimit is the default maximum requests per second
	DefaultShadcnRateLimit = 5
	// ShadcnRateLimitEnvVar is the environment variable for configuring rate limit
	ShadcnRateLimitEnvVar = "SHADCN_RATE_LIMIT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheEntry

type CacheEntry struct {
	Data      any
	Timestamp time.Time
}

CacheEntry defines the structure for cached data. Moved here to be shared across shadcnui tools.

type ComponentExample

type ComponentExample struct {
	Title       string `json:"title"`
	Code        string `json:"code"`
	Description string `json:"description,omitempty"`
}

ComponentExample defines a usage example for a component.

type ComponentInfo

type ComponentInfo struct {
	Name         string                   `json:"name"`
	Description  string                   `json:"description"`
	URL          string                   `json:"url"`                    // Link to the docs page
	SourceURL    string                   `json:"sourceUrl,omitempty"`    // Link to GitHub source
	APIReference string                   `json:"apiReference,omitempty"` // If available
	Installation string                   `json:"installation,omitempty"` // npx command
	Usage        string                   `json:"usage,omitempty"`        // General usage code block
	Props        map[string]ComponentProp `json:"props,omitempty"`        // Component props/variants
	Examples     []ComponentExample       `json:"examples,omitempty"`
}

ComponentInfo holds all details for a shadcn ui component.

type ComponentProp

type ComponentProp struct {
	Type        string `json:"type"` // e.g., "variant", "string", "boolean"
	Description string `json:"description"`
	Required    bool   `json:"required"`
	Default     string `json:"default,omitempty"`
	Example     string `json:"example,omitempty"` // For variants, this could be code
}

ComponentProp defines the structure for a component's property or variant.

type GetComponentDetailsTool

type GetComponentDetailsTool struct{}

GetComponentDetailsTool defines the tool for getting shadcn ui component details.

func (*GetComponentDetailsTool) Definition

func (t *GetComponentDetailsTool) Definition() mcp.Tool

Definition returns the tool's definition.

func (*GetComponentDetailsTool) Execute

func (t *GetComponentDetailsTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)

Execute performs the tool's action.

type GetComponentExamplesTool

type GetComponentExamplesTool struct{}

GetComponentExamplesTool defines the tool for getting shadcn ui component examples.

func (*GetComponentExamplesTool) Definition

func (t *GetComponentExamplesTool) Definition() mcp.Tool

Definition returns the tool's definition.

func (*GetComponentExamplesTool) Execute

func (t *GetComponentExamplesTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)

Execute performs the tool's action.

type HTTPClient

type HTTPClient interface {
	Get(url string) (*http.Response, error)
}

HTTPClient defines the interface for an HTTP client. This interface is maintained for compatibility but tools should migrate to security.Operations

var DefaultHTTPClient HTTPClient = NewRateLimitedHTTPClient()

DefaultHTTPClient is the default HTTP client implementation with rate limiting.

type ListShadcnComponentsTool

type ListShadcnComponentsTool struct{}

ListShadcnComponentsTool defines the tool for listing shadcn ui components. listComponentsCacheKey and listComponentsCacheTTL are now in utils.go

func (*ListShadcnComponentsTool) Definition

func (t *ListShadcnComponentsTool) Definition() mcp.Tool

Definition returns the tool's definition.

func (*ListShadcnComponentsTool) Execute

func (t *ListShadcnComponentsTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)

Execute performs the tool's action.

type RateLimitedHTTPClient added in v0.21.1

type RateLimitedHTTPClient struct {
	// contains filtered or unexported fields
}

RateLimitedHTTPClient implements HTTPClient with rate limiting

func NewRateLimitedHTTPClient added in v0.21.1

func NewRateLimitedHTTPClient() *RateLimitedHTTPClient

NewRateLimitedHTTPClient creates a new rate-limited HTTP client with proxy support

func (*RateLimitedHTTPClient) Get added in v0.21.1

func (c *RateLimitedHTTPClient) Get(reqURL string) (*http.Response, error)

Get implements the HTTPClient interface with rate limiting Note: This client is deprecated in favour of security.Operations.SafeHTTPGet

type SearchShadcnComponentsTool

type SearchShadcnComponentsTool struct {
}

SearchShadcnComponentsTool defines the tool for searching shadcn ui components.

func (*SearchShadcnComponentsTool) Definition

func (t *SearchShadcnComponentsTool) Definition() mcp.Tool

Definition returns the tool's definition.

func (*SearchShadcnComponentsTool) Execute

func (t *SearchShadcnComponentsTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)

Execute performs the tool's action.

type UnifiedShadcnTool

type UnifiedShadcnTool struct {
	// contains filtered or unexported fields
}

UnifiedShadcnTool provides a single interface for all shadcn ui operations

func (*UnifiedShadcnTool) Definition

func (t *UnifiedShadcnTool) Definition() mcp.Tool

Definition returns the tool's definition for MCP registration

func (*UnifiedShadcnTool) Execute

func (t *UnifiedShadcnTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)

Execute executes the unified shadcn tool

func (*UnifiedShadcnTool) ProvideExtendedInfo added in v0.22.0

func (t *UnifiedShadcnTool) ProvideExtendedInfo() *tools.ExtendedHelp

ProvideExtendedInfo provides detailed usage information for the shadcn tool

Jump to

Keyboard shortcuts

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