Documentation
¶
Overview ¶
Package resource implements the get-resource MCP tool that exposes TheHive's hierarchical resources (schemas, metadata, docs, config) to clients.
Index ¶
- Constants
- type CategoryBrowse
- type Content
- type GetResourceParams
- type GetResourceResult
- type Tool
- func (t *Tool) Definition() mcp.Tool
- func (t *Tool) Handle(ctx context.Context, _ mcp.CallToolRequest, params GetResourceParams) (GetResourceResult, error)
- func (t *Tool) Handler() server.ToolHandlerFunc
- func (t *Tool) Name() string
- func (t *Tool) ValidateParams(params *GetResourceParams) error
- func (t *Tool) ValidatePermissions(ctx context.Context, _ GetResourceParams) error
Constants ¶
const GetResourceToolDescription = `` /* 1452-byte string literal not displayed */
GetResourceToolDescription is the human-readable description advertised for the get-resource tool.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CategoryBrowse ¶ added in v0.3.1
type CategoryBrowse struct {
URI string `json:"uri"`
Subcategories []map[string]any `json:"subcategories,omitempty"`
Resources []map[string]any `json:"resources,omitempty"`
}
CategoryBrowse represents a directory listing of resources and subcategories
func NewCategoryBrowse ¶ added in v0.3.1
func NewCategoryBrowse(uri string, subcategories []map[string]any, resources []map[string]any) *CategoryBrowse
NewCategoryBrowse creates a CategoryBrowse listing for the given uri.
type Content ¶ added in v1.0.0
type Content struct {
URI string `json:"uri"`
Name string `json:"name"`
MIMEType string `json:"mimeType,omitempty"`
Content string `json:"content,omitempty"`
Data any `json:"data,omitempty"`
}
Content represents a specific resource with its content.
func NewResourceContent ¶ added in v0.3.1
NewResourceContent creates a Content for the resource identified by uri.
func (*Content) SetDataContent ¶ added in v1.0.0
SetDataContent sets the structured data body of the resource and returns rc for chaining.
func (*Content) SetTextContent ¶ added in v1.0.0
SetTextContent sets the plain-text body of the resource and returns rc for chaining.
type GetResourceParams ¶ added in v0.3.1
type GetResourceParams struct {
URI string `` /* 157-byte string literal not displayed */
}
GetResourceParams defines the input parameters for the get-resource tool
type GetResourceResult ¶ added in v0.3.1
type GetResourceResult struct {
Resource *Content `json:"resource,omitempty"`
Category *CategoryBrowse `json:"category,omitempty"`
}
GetResourceResult is the unified response type for get-resource operations Either Resource OR Category will be populated, never both
func NewCategoryResult ¶ added in v0.3.1
func NewCategoryResult(category *CategoryBrowse) *GetResourceResult
NewCategoryResult wraps a category listing in a GetResourceResult.
func NewResourceResult ¶ added in v0.3.1
func NewResourceResult(resource *Content) *GetResourceResult
NewResourceResult wraps resource content in a GetResourceResult.
func (GetResourceResult) Unwrap ¶ added in v0.3.1
func (r GetResourceResult) Unwrap() any
Unwrap implements utils.Unwrapper to flatten the union for serialization.
type Tool ¶ added in v1.0.0
type Tool struct {
// contains filtered or unexported fields
}
Tool is the get-resource MCP tool backed by a resource registry.
func NewResourceTool ¶
func NewResourceTool(registry *resources.ResourceRegistry) *Tool
NewResourceTool creates a Tool serving resources from the given registry.
func (*Tool) Definition ¶ added in v1.0.0
Definition returns the tool's MCP definition, including input and output schemas.
func (*Tool) Handle ¶ added in v1.0.0
func (t *Tool) Handle(ctx context.Context, _ mcp.CallToolRequest, params GetResourceParams) (GetResourceResult, error)
Handle fetches the resource or category identified by params.URI.
func (*Tool) Handler ¶ added in v1.0.0
func (t *Tool) Handler() server.ToolHandlerFunc
Handler returns the validated MCP handler for the tool.
func (*Tool) ValidateParams ¶ added in v1.0.0
func (t *Tool) ValidateParams(params *GetResourceParams) error
ValidateParams applies defaults and normalizes the requested URI in place.
func (*Tool) ValidatePermissions ¶ added in v1.0.0
func (t *Tool) ValidatePermissions(ctx context.Context, _ GetResourceParams) error
ValidatePermissions verifies the caller is allowed to use the get-resource tool.