Documentation
¶
Overview ¶
Package tools provides MCP tool definitions for DataHub operations. It implements the Toolkit pattern for composable MCP servers.
Index ¶
- Constants
- Variables
- func DefaultAnnotations(name ToolName) *mcp.ToolAnnotations
- func DefaultDescription(name ToolName) string
- func DefaultIcons() []mcp.Icon
- func DefaultOutputSchema(name ToolName) json.RawMessage
- func DefaultTitle(name ToolName) string
- func ErrorResult(message string) *mcp.CallToolResult
- func JSONResult(v any) (*mcp.CallToolResult, error)
- func TextResult(text string) *mcp.CallToolResult
- type AccessFilterMiddleware
- type AfterFunc
- type AuditLoggerMiddleware
- type BeforeFunc
- type BrowseInput
- type BrowseOutput
- type Config
- type ConnectionInfoOutput
- type CreateInput
- type CreateOutput
- type DataHubClient
- type DeleteInput
- type DeleteOutput
- type GetDataProductInput
- type GetEntityInput
- type GetGlossaryTermInput
- type GetLineageInput
- type GetQueriesInput
- type GetSchemaInput
- type ListConnectionsInput
- type ListConnectionsOutput
- type MetadataEnricherMiddleware
- type SearchFilterInput
- type SearchInput
- type ToolContext
- type ToolMiddleware
- type ToolName
- type ToolOption
- type Toolkit
- func (t *Toolkit) Client() DataHubClient
- func (t *Toolkit) Config() Config
- func (t *Toolkit) ConnectionCount() int
- func (t *Toolkit) ConnectionInfos() []multiserver.ConnectionInfo
- func (t *Toolkit) HasManager() bool
- func (t *Toolkit) HasMiddleware() bool
- func (t *Toolkit) HasQueryProvider() bool
- func (t *Toolkit) Manager() *multiserver.Manager
- func (t *Toolkit) QueryProvider() integration.QueryProvider
- func (t *Toolkit) Register(server *mcp.Server, names ...ToolName)
- func (t *Toolkit) RegisterAll(server *mcp.Server)
- func (t *Toolkit) RegisterWith(server *mcp.Server, name ToolName, opts ...ToolOption)
- type ToolkitOption
- func WithAccessFilter(f integration.AccessFilter) ToolkitOption
- func WithAnnotations(anns map[ToolName]*mcp.ToolAnnotations) ToolkitOption
- func WithAuditLogger(l integration.AuditLogger, getUserID func(context.Context) string) ToolkitOption
- func WithDescriptions(descs map[ToolName]string) ToolkitOption
- func WithIcons(icons map[ToolName][]mcp.Icon) ToolkitOption
- func WithMetadataEnricher(e integration.MetadataEnricher) ToolkitOption
- func WithMiddleware(mw ToolMiddleware) ToolkitOption
- func WithOutputSchemas(schemas map[ToolName]any) ToolkitOption
- func WithQueryProvider(p integration.QueryProvider) ToolkitOption
- func WithTitles(titles map[ToolName]string) ToolkitOption
- func WithToolMiddleware(name ToolName, mw ToolMiddleware) ToolkitOption
- func WithURNResolver(r integration.URNResolver) ToolkitOption
- type URNResolverMiddleware
- type UpdateInput
- type UpdateOutput
Constants ¶
const ( ContextKeyResolvedURN = "resolved_urn" ContextKeyAccessOK = "access_ok" )
Context keys for inter-middleware communication.
Variables ¶
var ErrAccessDenied = errors.New("access denied")
ErrAccessDenied is returned when access to a URN is denied.
Functions ¶
func DefaultAnnotations ¶ added in v0.7.0
func DefaultAnnotations(name ToolName) *mcp.ToolAnnotations
DefaultAnnotations returns the default annotations for a tool. Returns nil for unknown tool names.
func DefaultDescription ¶ added in v0.6.0
DefaultDescription returns the default description for a tool. Returns an empty string if the tool name is not recognized.
func DefaultIcons ¶ added in v0.7.1
DefaultIcons returns the default icons for DataHub tools.
func DefaultOutputSchema ¶ added in v1.0.0
func DefaultOutputSchema(name ToolName) json.RawMessage
DefaultOutputSchema returns the default output JSON Schema for a tool. Returns nil if the tool name is not recognized.
func DefaultTitle ¶ added in v1.0.0
DefaultTitle returns the default human-readable title for a tool. Returns an empty string if the tool name is not recognized.
func ErrorResult ¶
func ErrorResult(message string) *mcp.CallToolResult
ErrorResult creates an error result for tool responses.
func JSONResult ¶
func JSONResult(v any) (*mcp.CallToolResult, error)
JSONResult creates a JSON result for tool responses.
func TextResult ¶
func TextResult(text string) *mcp.CallToolResult
TextResult creates a text result for tool responses.
Types ¶
type AccessFilterMiddleware ¶ added in v0.2.0
type AccessFilterMiddleware struct {
// contains filtered or unexported fields
}
AccessFilterMiddleware wraps an AccessFilter to control access to entities.
func NewAccessFilterMiddleware ¶ added in v0.2.0
func NewAccessFilterMiddleware(f integration.AccessFilter) *AccessFilterMiddleware
NewAccessFilterMiddleware creates a middleware that controls access to entities.
func (*AccessFilterMiddleware) After ¶ added in v0.2.0
func (m *AccessFilterMiddleware) After( ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, _ error, ) (*mcp.CallToolResult, error)
After implements ToolMiddleware - filters URNs from list results.
func (*AccessFilterMiddleware) Before ¶ added in v0.2.0
func (m *AccessFilterMiddleware) Before(ctx context.Context, tc *ToolContext) (context.Context, error)
Before implements ToolMiddleware.
type AfterFunc ¶
type AfterFunc func(ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, err error) (*mcp.CallToolResult, error)
AfterFunc is a convenience type for creating After-only middleware.
func (AfterFunc) After ¶
func (f AfterFunc) After(ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, err error) (*mcp.CallToolResult, error)
After implements ToolMiddleware.
type AuditLoggerMiddleware ¶ added in v0.2.0
type AuditLoggerMiddleware struct {
// contains filtered or unexported fields
}
AuditLoggerMiddleware wraps an AuditLogger to log tool invocations.
func NewAuditLoggerMiddleware ¶ added in v0.2.0
func NewAuditLoggerMiddleware(l integration.AuditLogger, getUserID func(context.Context) string) *AuditLoggerMiddleware
NewAuditLoggerMiddleware creates a middleware that logs tool invocations.
func (*AuditLoggerMiddleware) After ¶ added in v0.2.0
func (m *AuditLoggerMiddleware) After( ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, _ error, ) (*mcp.CallToolResult, error)
After implements ToolMiddleware - logs the tool call.
func (*AuditLoggerMiddleware) Before ¶ added in v0.2.0
func (m *AuditLoggerMiddleware) Before(ctx context.Context, _ *ToolContext) (context.Context, error)
Before implements ToolMiddleware (no-op).
type BeforeFunc ¶
BeforeFunc is a convenience type for creating Before-only middleware.
func (BeforeFunc) After ¶
func (f BeforeFunc) After(_ context.Context, _ *ToolContext, result *mcp.CallToolResult, _ error) (*mcp.CallToolResult, error)
After implements ToolMiddleware (no-op).
func (BeforeFunc) Before ¶
func (f BeforeFunc) Before(ctx context.Context, tc *ToolContext) (context.Context, error)
Before implements ToolMiddleware.
type BrowseInput ¶ added in v1.1.0
type BrowseInput struct {
//nolint:lll // struct tag cannot be split
What string `` /* 129-byte string literal not displayed */
Filter string `json:"filter,omitempty" jsonschema_description:"Optional filter string (tags only)"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
BrowseInput is the input for the datahub_browse tool.
type BrowseOutput ¶ added in v1.1.0
type BrowseOutput struct {
Tags []types.Tag `json:"tags,omitempty"`
Domains []types.Domain `json:"domains,omitempty"`
DataProducts []types.DataProduct `json:"data_products,omitempty"`
}
BrowseOutput is the structured output of the datahub_browse tool. Exactly one of Tags, Domains, or DataProducts is populated per call.
type Config ¶
type Config struct {
// DefaultLimit is the default search result limit. Default: 10.
DefaultLimit int
// MaxLimit is the maximum allowed limit. Default: 100.
MaxLimit int
// MaxLineageDepth is the maximum lineage traversal depth. Default: 5.
MaxLineageDepth int
// WriteEnabled enables write operations (add/remove tags, glossary terms, etc.).
// Default: false (read-only mode).
WriteEnabled bool
// Debug enables debug logging for toolkit operations.
Debug bool
// Logger is the logger for debug output. If nil and Debug is true, uses client.StdLogger.
Logger client.Logger
}
Config configures the DataHub toolkit behavior.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type ConnectionInfoOutput ¶ added in v0.1.1
type ConnectionInfoOutput struct {
Name string `json:"name"`
URL string `json:"url"`
IsDefault bool `json:"is_default"`
}
ConnectionInfoOutput provides information about a single connection.
type CreateInput ¶ added in v1.5.0
type CreateInput struct {
//nolint:lll // struct tag cannot be split
What string `` /* 305-byte string literal not displayed */
// Common fields
Name string `json:"name,omitempty" jsonschema_description:"Name or title of the entity"`
Description string `json:"description,omitempty" jsonschema_description:"Description or content of the entity"`
// Glossary term fields
ParentNode string `json:"parent_node,omitempty" jsonschema_description:"Parent glossary node URN (glossary_term only)"`
// Data product fields
DomainURN string `json:"domain_urn,omitempty" jsonschema_description:"Domain URN (data_product only, required)"`
// Query fields
Value string `json:"value,omitempty" jsonschema_description:"SQL statement (query only)"`
Language string `json:"language,omitempty" jsonschema_description:"Query language, default SQL (query only)"`
DatasetURNs []string `json:"dataset_urns,omitempty" jsonschema_description:"Associated dataset URNs (query, data_contract)"`
// Incident fields
EntityURNs []string `json:"entity_urns,omitempty" jsonschema_description:"Affected entity URNs (incident only)"`
IncidentType string `json:"incident_type,omitempty" jsonschema_description:"Incident type: OPERATIONAL, CUSTOM, etc. (incident only)"`
Priority string `json:"priority,omitempty" jsonschema_description:"Priority: LOW, MEDIUM, HIGH, CRITICAL (incident only)"`
// Document fields
Status string `json:"status,omitempty" jsonschema_description:"Publication status: PUBLISHED or UNPUBLISHED (document only)"`
SubType string `json:"sub_type,omitempty" jsonschema_description:"Document sub-type (document only)"`
RelatedAssets []string `json:"related_assets,omitempty" jsonschema_description:"Related asset URNs (document only)"`
GlobalContext *bool `json:"global_context,omitempty" jsonschema_description:"Show in global search (document only, default: true)"`
// Structured property fields
QualifiedName string `json:"qualified_name,omitempty" jsonschema_description:"Fully qualified name (structured_property)"`
ValueType string `json:"value_type,omitempty" jsonschema_description:"Value type: string, number, date, urn (structured_property)"`
Cardinality string `json:"cardinality,omitempty" jsonschema_description:"SINGLE or MULTIPLE (structured_property only)"`
EntityTypes []string `json:"entity_types,omitempty" jsonschema_description:"Applicable entity types (structured_property only)"`
// Data contract fields
SchemaAssertions []string `json:"schema_assertions,omitempty" jsonschema_description:"Schema assertion URNs"`
FreshnessAssertions []string `json:"freshness_assertions,omitempty" jsonschema_description:"Freshness assertion URNs"`
DataQualityAssertions []string `json:"data_quality_assertions,omitempty" jsonschema_description:"Data quality assertion URNs"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
CreateInput is the input for the datahub_create tool.
type CreateOutput ¶ added in v1.5.0
type CreateOutput struct {
URN string `json:"urn"`
What string `json:"what"`
Action string `json:"action"`
}
CreateOutput is the structured output of the datahub_create tool.
type DataHubClient ¶
type DataHubClient interface {
// Search searches for entities.
Search(ctx context.Context, query string, opts ...client.SearchOption) (*types.SearchResult, error)
// GetEntity retrieves a single entity by URN.
GetEntity(ctx context.Context, urn string) (*types.Entity, error)
// GetSchema retrieves schema for a dataset.
GetSchema(ctx context.Context, urn string) (*types.SchemaMetadata, error)
// GetSchemas retrieves schemas for multiple datasets by URN.
GetSchemas(ctx context.Context, urns []string) (map[string]*types.SchemaMetadata, error)
// GetLineage retrieves lineage for an entity.
GetLineage(ctx context.Context, urn string, opts ...client.LineageOption) (*types.LineageResult, error)
// GetColumnLineage retrieves fine-grained column-level lineage for a dataset.
GetColumnLineage(ctx context.Context, urn string) (*types.ColumnLineage, error)
// GetQueries retrieves queries for a dataset.
GetQueries(ctx context.Context, urn string) (*types.QueryList, error)
// GetGlossaryTerm retrieves a glossary term.
GetGlossaryTerm(ctx context.Context, urn string) (*types.GlossaryTerm, error)
// ListTags lists all tags.
ListTags(ctx context.Context, filter string) ([]types.Tag, error)
// ListDomains lists all domains.
ListDomains(ctx context.Context) ([]types.Domain, error)
// ListDataProducts lists all data products.
ListDataProducts(ctx context.Context) ([]types.DataProduct, error)
// GetDataProduct retrieves a data product by URN.
GetDataProduct(ctx context.Context, urn string) (*types.DataProduct, error)
// Ping tests the connection.
Ping(ctx context.Context) error
// Close closes the client.
Close() error
// UpdateDescription sets the editable description for an entity.
UpdateDescription(ctx context.Context, urn, description string) error
// UpdateColumnDescription sets the description for a specific schema field.
UpdateColumnDescription(ctx context.Context, urn, fieldPath, description string) error
// AddTag adds a tag to an entity.
AddTag(ctx context.Context, urn, tagURN string) error
// RemoveTag removes a tag from an entity.
RemoveTag(ctx context.Context, urn, tagURN string) error
// AddGlossaryTerm adds a glossary term to an entity.
AddGlossaryTerm(ctx context.Context, urn, termURN string) error
// RemoveGlossaryTerm removes a glossary term from an entity.
RemoveGlossaryTerm(ctx context.Context, urn, termURN string) error
// AddLink adds a link to an entity.
AddLink(ctx context.Context, urn, linkURL, description string) error
// RemoveLink removes a link from an entity by URL.
RemoveLink(ctx context.Context, urn, linkURL string) error
// CreateQuery creates a new Query entity.
CreateQuery(ctx context.Context, input client.CreateQueryInput) (*types.Query, error)
// UpdateQuery updates an existing Query entity.
UpdateQuery(ctx context.Context, input client.UpdateQueryInput) (*types.Query, error)
// DeleteQuery deletes a Query entity.
DeleteQuery(ctx context.Context, urn string) error
// GetStructuredProperties retrieves structured property values assigned to an entity.
GetStructuredProperties(ctx context.Context, urn string) ([]types.StructuredPropertyValue, error)
// ListStructuredPropertyDefinitions retrieves all structured property definitions.
ListStructuredPropertyDefinitions(ctx context.Context) ([]types.StructuredPropertyDefinition, error)
// UpsertStructuredProperties sets or updates structured property values on an entity.
UpsertStructuredProperties(ctx context.Context, urn string, properties []types.StructuredPropertyInput) error
// RemoveStructuredProperties removes structured properties from an entity.
RemoveStructuredProperties(ctx context.Context, urn string, propertyURNs []string) error
// GetIncidents retrieves active incidents for an entity.
GetIncidents(ctx context.Context, urn string) (*types.IncidentResult, error)
// RaiseIncident creates a new incident on entities.
RaiseIncident(ctx context.Context, input types.RaiseIncidentInput) (string, error)
// UpdateIncidentStatus changes the state of an incident (ACTIVE or RESOLVED).
UpdateIncidentStatus(ctx context.Context, incidentURN, state, message string) error
// ResolveIncident marks an incident as resolved.
ResolveIncident(ctx context.Context, incidentURN, message string) error
// GetDataContract retrieves the data contract status for a dataset.
GetDataContract(ctx context.Context, datasetURN string) (*types.DataContract, error)
// SearchAcrossEntities searches across entity types with optional advanced filtering.
SearchAcrossEntities(ctx context.Context, query string, opts ...client.SearchOption) (*types.SearchResult, error)
// SemanticSearch performs natural language semantic search across entities.
SemanticSearch(ctx context.Context, query string, opts ...client.SearchOption) (*types.SearchResult, error)
// GetDocument retrieves a context document by URN.
GetDocument(ctx context.Context, urn string) (*types.Document, error)
// GetRelatedDocuments retrieves documents linked to an entity.
GetRelatedDocuments(ctx context.Context, urn string) ([]types.Document, error)
// GetContextDocuments retrieves context documents linked to an entity
// as simplified ContextDocument values for downstream consumption.
GetContextDocuments(ctx context.Context, urn string) ([]types.ContextDocument, error)
// UpsertContextDocument creates or updates a context document on an entity.
// If doc.ID is empty, creates a new document. If set, updates the existing one.
UpsertContextDocument(ctx context.Context, entityURN string, doc types.ContextDocumentInput) (*types.ContextDocument, error)
// DeleteContextDocument removes a context document by its ID.
DeleteContextDocument(ctx context.Context, documentID string) error
// CreateTag creates a new tag entity.
CreateTag(ctx context.Context, name, description string) (string, error)
// CreateDomain creates a new domain entity.
CreateDomain(ctx context.Context, name, description string) (string, error)
// CreateGlossaryTerm creates a new glossary term entity.
CreateGlossaryTerm(ctx context.Context, name, description, parentNode string) (string, error)
// CreateDataProduct creates a new data product entity.
CreateDataProduct(ctx context.Context, name, description, domainURN string) (string, error)
// CreateDocument creates a new context document entity.
CreateDocument(ctx context.Context, input types.CreateDocumentInput) (string, error)
// CreateApplication creates a new application entity.
CreateApplication(ctx context.Context, name, description string) (string, error)
// CreateStructuredProperty creates a new structured property definition.
CreateStructuredProperty(ctx context.Context, input types.CreateStructuredPropertyInput) (string, error)
// UpsertDataContract creates or updates a data contract for a dataset.
UpsertDataContract(ctx context.Context, input types.UpsertDataContractInput) (string, error)
// AddOwner adds an owner to an entity.
AddOwner(ctx context.Context, urn, ownerURN, ownershipType string) error
// RemoveOwner removes an owner from an entity.
RemoveOwner(ctx context.Context, urn, ownerURN string) error
// SetDomain assigns a domain to an entity.
SetDomain(ctx context.Context, entityURN, domainURN string) error
// UnsetDomain removes the domain from an entity.
UnsetDomain(ctx context.Context, entityURN string) error
// UpdateIncident updates an existing incident.
UpdateIncident(ctx context.Context, urn string, input types.UpdateIncidentInput) error
// UpdateStructuredProperty updates a structured property definition.
UpdateStructuredProperty(ctx context.Context, urn string, input types.UpdateStructuredPropertyInput) error
// UpdateDocumentContents updates the title and text of a document.
UpdateDocumentContents(ctx context.Context, urn, title, text string) error
// UpdateDocumentStatus updates the status of a document.
UpdateDocumentStatus(ctx context.Context, urn, status string) error
// UpdateDocumentRelatedEntities updates entities related to a document.
UpdateDocumentRelatedEntities(ctx context.Context, urn string, entityURNs []string) error
// UpdateDocumentSubType updates the sub-type of a document.
UpdateDocumentSubType(ctx context.Context, urn, subType string) error
// DeleteTag deletes a tag entity.
DeleteTag(ctx context.Context, urn string) error
// DeleteDomain deletes a domain entity.
DeleteDomain(ctx context.Context, urn string) error
// DeleteGlossaryEntity deletes a glossary term or node.
DeleteGlossaryEntity(ctx context.Context, urn string) error
// DeleteDataProduct deletes a data product entity.
DeleteDataProduct(ctx context.Context, urn string) error
// DeleteApplication deletes an application entity.
DeleteApplication(ctx context.Context, urn string) error
// DeleteDocument deletes a document entity.
DeleteDocument(ctx context.Context, urn string) error
// DeleteStructuredProperty deletes a structured property definition.
DeleteStructuredProperty(ctx context.Context, urn string) error
}
DataHubClient defines the interface for DataHub operations. This allows for mocking in tests.
type DeleteInput ¶ added in v1.5.0
type DeleteInput struct {
//nolint:lll // struct tag cannot be split
What string `` /* 261-byte string literal not displayed */
URN string `json:"urn" jsonschema_description:"URN of the entity to delete"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
DeleteInput is the input for the datahub_delete tool.
type DeleteOutput ¶ added in v1.5.0
type DeleteOutput struct {
URN string `json:"urn"`
What string `json:"what"`
Action string `json:"action"`
}
DeleteOutput is the structured output of the datahub_delete tool.
type GetDataProductInput ¶
type GetDataProductInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the data product"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetDataProductInput is the input for the get_data_product tool.
type GetEntityInput ¶
type GetEntityInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetEntityInput is the input for the get_entity tool.
type GetGlossaryTermInput ¶
type GetGlossaryTermInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the glossary term"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetGlossaryTermInput is the input for the get_glossary_term tool.
type GetLineageInput ¶
type GetLineageInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the entity"`
//nolint:lll // struct tag cannot be split
Level string `` /* 130-byte string literal not displayed */
Direction string `json:"direction,omitempty" jsonschema_description:"UPSTREAM or DOWNSTREAM (default: DOWNSTREAM, dataset level only)"`
Depth int `json:"depth,omitempty" jsonschema_description:"Max depth of lineage traversal (default: 1, max: 5, dataset level only)"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetLineageInput is the input for the get_lineage tool.
type GetQueriesInput ¶
type GetQueriesInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the dataset"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetQueriesInput is the input for the get_queries tool.
type GetSchemaInput ¶
type GetSchemaInput struct {
URN string `json:"urn" jsonschema_description:"The DataHub URN of the dataset"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
GetSchemaInput is the input for the get_schema tool.
type ListConnectionsInput ¶ added in v0.1.1
type ListConnectionsInput struct{}
ListConnectionsInput defines the input for the datahub_list_connections tool. This tool has no required parameters.
type ListConnectionsOutput ¶ added in v0.1.1
type ListConnectionsOutput struct {
Connections []ConnectionInfoOutput `json:"connections"`
Count int `json:"count"`
}
ListConnectionsOutput defines the output of the datahub_list_connections tool.
type MetadataEnricherMiddleware ¶ added in v0.2.0
type MetadataEnricherMiddleware struct {
// contains filtered or unexported fields
}
MetadataEnricherMiddleware wraps a MetadataEnricher to add custom metadata.
func NewMetadataEnricherMiddleware ¶ added in v0.2.0
func NewMetadataEnricherMiddleware(e integration.MetadataEnricher) *MetadataEnricherMiddleware
NewMetadataEnricherMiddleware creates a middleware that enriches entity responses.
func (*MetadataEnricherMiddleware) After ¶ added in v0.2.0
func (m *MetadataEnricherMiddleware) After( ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, _ error, ) (*mcp.CallToolResult, error)
After implements ToolMiddleware - enriches entity results.
func (*MetadataEnricherMiddleware) Before ¶ added in v0.2.0
func (m *MetadataEnricherMiddleware) Before(ctx context.Context, _ *ToolContext) (context.Context, error)
Before implements ToolMiddleware (no-op).
type SearchFilterInput ¶ added in v1.8.0
type SearchFilterInput struct {
// Field is the filter field name.
Field string `json:"field" jsonschema_description:"Filter field name (see tool description for options)"`
// Value is a convenience field for a single value. Use values for multiple.
Value string `json:"value,omitempty" jsonschema_description:"Single filter value. Use 'values' for multiple."`
// Values are the values to match against.
Values []string `json:"values,omitempty" jsonschema_description:"Filter values to match against"`
// Condition is the filter operator. Defaults to EQUAL if omitted.
Condition string `json:"condition,omitempty" jsonschema_description:"Filter operator: CONTAIN, EQUAL (default), IN, EXISTS"`
// Negated inverts the filter to exclude matches.
Negated bool `json:"negated,omitempty" jsonschema_description:"If true, exclude entities matching this filter"`
}
SearchFilterInput represents a single filter criterion for advanced search.
type SearchInput ¶
type SearchInput struct {
Query string `json:"query" jsonschema_description:"Search query string"`
// EntityType: DATASET, DASHBOARD, DATA_FLOW, DATA_JOB, CONTAINER, etc.
EntityType string `json:"entity_type,omitempty" jsonschema_description:"Entity type (single). Defaults to DATASET."`
// Types allows searching across multiple entity types. Overrides entity_type.
Types []string `json:"types,omitempty" jsonschema_description:"Entity types to search across. Overrides entity_type."`
// Filters enable advanced field-level filtering via searchAcrossEntities.
Filters []SearchFilterInput `json:"filters,omitempty" jsonschema_description:"Advanced field-level filters (AND'd together)."`
Limit int `json:"limit,omitempty" jsonschema_description:"Maximum number of results (default: 10, max: 100)"`
Offset int `json:"offset,omitempty" jsonschema_description:"Result offset for pagination"`
// Mode selects the search strategy: "keyword" (default) or "semantic".
// Semantic search uses vector embeddings for natural language queries.
// Requires DataHub 1.4.x with OpenSearch 2.19.3+.
Mode string `json:"mode,omitempty" jsonschema_description:"Search mode: keyword (default) or semantic"`
// Connection is the named connection to use. Empty uses the default connection.
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
SearchInput is the input for the search tool.
type ToolContext ¶
type ToolContext struct {
// ToolName is the name of the tool being executed.
ToolName ToolName
// Input is the parsed input for the tool.
Input any
// StartTime is when the tool execution started.
StartTime time.Time
// Extra allows middleware to pass data between Before and After.
Extra map[string]any
}
ToolContext provides context for middleware about the current tool execution.
func NewToolContext ¶
func NewToolContext(name ToolName, input any) *ToolContext
NewToolContext creates a new ToolContext.
func (*ToolContext) Duration ¶
func (tc *ToolContext) Duration() time.Duration
Duration returns the time elapsed since the tool started.
func (*ToolContext) Get ¶
func (tc *ToolContext) Get(key string) (any, bool)
Get retrieves a value from Extra.
func (*ToolContext) GetString ¶ added in v0.6.0
func (tc *ToolContext) GetString(key string) string
GetString retrieves a string value from Extra. Returns an empty string if the key is not found or the value is not a string.
func (*ToolContext) Set ¶
func (tc *ToolContext) Set(key string, value any)
Set stores a value in Extra.
type ToolMiddleware ¶
type ToolMiddleware interface {
// Before is called before the tool handler executes.
// Return a modified context or an error to abort execution.
Before(ctx context.Context, tc *ToolContext) (context.Context, error)
// After is called after the tool handler executes.
// Can modify the result or handle errors.
After(ctx context.Context, tc *ToolContext, result *mcp.CallToolResult, err error) (*mcp.CallToolResult, error)
}
ToolMiddleware intercepts tool execution for cross-cutting concerns.
type ToolName ¶
type ToolName string
ToolName identifies a DataHub MCP tool.
const ( ToolSearch ToolName = "datahub_search" ToolGetEntity ToolName = "datahub_get_entity" ToolGetSchema ToolName = "datahub_get_schema" ToolGetLineage ToolName = "datahub_get_lineage" ToolGetQueries ToolName = "datahub_get_queries" ToolBrowse ToolName = "datahub_browse" ToolGetGlossaryTerm ToolName = "datahub_get_glossary_term" ToolGetDataProduct ToolName = "datahub_get_data_product" ToolListConnections ToolName = "datahub_list_connections" // Write tool names (CRUD pattern). ToolCreate ToolName = "datahub_create" ToolUpdate ToolName = "datahub_update" ToolDelete ToolName = "datahub_delete" )
Tool name constants.
func AllTools ¶
func AllTools() []ToolName
AllTools returns all available read-only tool names. This does not include write tools for backward compatibility.
func WriteTools ¶ added in v0.5.0
func WriteTools() []ToolName
WriteTools returns all write tool names.
type ToolOption ¶
type ToolOption func(*toolConfig)
ToolOption configures a single tool registration.
func WithAnnotation ¶ added in v0.7.0
func WithAnnotation(ann *mcp.ToolAnnotations) ToolOption
WithAnnotation overrides the annotations for a single tool registration. This is the highest priority override, taking precedence over both toolkit-level WithAnnotations and default annotations.
func WithDescription ¶ added in v0.6.0
func WithDescription(desc string) ToolOption
WithDescription overrides the description for a single tool registration. This is the highest priority override, taking precedence over both toolkit-level WithDescriptions and default descriptions.
func WithIcon ¶ added in v0.7.1
func WithIcon(icons []mcp.Icon) ToolOption
WithIcon overrides the icons for a single tool registration. This is the highest priority override, taking precedence over both toolkit-level WithIcons and default icons.
func WithOutputSchema ¶ added in v1.0.0
func WithOutputSchema(schema any) ToolOption
WithOutputSchema overrides the output schema for a single tool registration. This is the highest priority override, taking precedence over both toolkit-level WithOutputSchemas and default output schemas.
func WithPerToolMiddleware ¶
func WithPerToolMiddleware(mw ToolMiddleware) ToolOption
WithPerToolMiddleware adds middleware for a single tool registration.
func WithTitle ¶ added in v1.0.0
func WithTitle(title string) ToolOption
WithTitle overrides the display title for a single tool registration. This is the highest priority override, taking precedence over both toolkit-level WithTitles and default titles.
type Toolkit ¶
type Toolkit struct {
// contains filtered or unexported fields
}
Toolkit provides MCP tools for DataHub operations. It's designed to be composable - you can add its tools to any MCP server.
func NewToolkit ¶
func NewToolkit(c DataHubClient, cfg Config, opts ...ToolkitOption) *Toolkit
NewToolkit creates a new DataHub toolkit. Accepts optional ToolkitOption arguments for middleware, etc. Maintains backwards compatibility - existing code works unchanged.
func NewToolkitWithManager ¶ added in v0.1.1
func NewToolkitWithManager(mgr *multiserver.Manager, cfg Config, opts ...ToolkitOption) *Toolkit
NewToolkitWithManager creates a Toolkit with multi-server support. Use this when you need to connect to multiple DataHub servers.
func (*Toolkit) Client ¶
func (t *Toolkit) Client() DataHubClient
Client returns the underlying DataHub client.
func (*Toolkit) ConnectionCount ¶ added in v0.1.1
ConnectionCount returns the number of configured connections.
func (*Toolkit) ConnectionInfos ¶ added in v0.1.1
func (t *Toolkit) ConnectionInfos() []multiserver.ConnectionInfo
ConnectionInfos returns information about all configured connections. Returns a single "default" connection in single-client mode.
func (*Toolkit) HasManager ¶ added in v0.1.1
HasManager returns true if multi-server mode is enabled.
func (*Toolkit) HasMiddleware ¶
HasMiddleware returns true if any middleware is configured.
func (*Toolkit) HasQueryProvider ¶ added in v0.2.0
HasQueryProvider returns true if a query provider is configured.
func (*Toolkit) Manager ¶ added in v0.1.1
func (t *Toolkit) Manager() *multiserver.Manager
Manager returns the connection manager, or nil if in single-client mode.
func (*Toolkit) QueryProvider ¶ added in v0.2.0
func (t *Toolkit) QueryProvider() integration.QueryProvider
QueryProvider returns the configured query provider, or nil if not configured.
func (*Toolkit) RegisterAll ¶
RegisterAll adds all DataHub tools to the given MCP server. If WriteEnabled is true, also registers write tools.
func (*Toolkit) RegisterWith ¶
func (t *Toolkit) RegisterWith(server *mcp.Server, name ToolName, opts ...ToolOption)
RegisterWith adds a tool with additional per-registration options.
type ToolkitOption ¶
type ToolkitOption func(*Toolkit)
ToolkitOption configures a Toolkit.
func WithAccessFilter ¶ added in v0.2.0
func WithAccessFilter(f integration.AccessFilter) ToolkitOption
WithAccessFilter adds access control capability to the toolkit. When configured, tools will check access before execution and filter results to only include accessible entities.
func WithAnnotations ¶ added in v0.7.0
func WithAnnotations(anns map[ToolName]*mcp.ToolAnnotations) ToolkitOption
WithAnnotations sets toolkit-level annotation overrides for multiple tools. These take priority over default annotations but are overridden by per-registration WithAnnotation options.
func WithAuditLogger ¶ added in v0.2.0
func WithAuditLogger(l integration.AuditLogger, getUserID func(context.Context) string) ToolkitOption
WithAuditLogger adds audit logging capability to the toolkit. When configured, all tool invocations will be logged with the tool name, parameters, and user ID.
The getUserID function extracts the user ID from the context. If nil, an empty user ID will be logged.
func WithDescriptions ¶ added in v0.6.0
func WithDescriptions(descs map[ToolName]string) ToolkitOption
WithDescriptions sets toolkit-level description overrides for multiple tools. These take priority over default descriptions but are overridden by per-registration WithDescription options.
func WithIcons ¶ added in v0.7.1
func WithIcons(icons map[ToolName][]mcp.Icon) ToolkitOption
WithIcons sets toolkit-level icon overrides for multiple tools. These take priority over default icons but are overridden by per-registration WithIcon options.
func WithMetadataEnricher ¶ added in v0.2.0
func WithMetadataEnricher(e integration.MetadataEnricher) ToolkitOption
WithMetadataEnricher adds metadata enrichment capability to the toolkit. When configured, entity responses will be enriched with custom metadata before being returned.
func WithMiddleware ¶
func WithMiddleware(mw ToolMiddleware) ToolkitOption
WithMiddleware adds global middleware to all tools.
func WithOutputSchemas ¶ added in v1.0.0
func WithOutputSchemas(schemas map[ToolName]any) ToolkitOption
WithOutputSchemas sets toolkit-level output schema overrides for multiple tools. These take priority over default output schemas but are overridden by per-registration WithOutputSchema options.
func WithQueryProvider ¶ added in v0.2.0
func WithQueryProvider(p integration.QueryProvider) ToolkitOption
WithQueryProvider adds query execution context to the toolkit. When configured, tools will enrich their responses with query execution context from the provider (table resolution, query examples, availability).
This enables bidirectional integration with query engines like Trino.
func WithTitles ¶ added in v1.0.0
func WithTitles(titles map[ToolName]string) ToolkitOption
WithTitles sets toolkit-level title overrides for multiple tools. These take priority over default titles but are overridden by per-registration WithTitle options.
func WithToolMiddleware ¶
func WithToolMiddleware(name ToolName, mw ToolMiddleware) ToolkitOption
WithToolMiddleware adds middleware to a specific tool.
func WithURNResolver ¶ added in v0.2.0
func WithURNResolver(r integration.URNResolver) ToolkitOption
WithURNResolver adds URN resolution capability to the toolkit. When configured, tools will resolve external identifiers to DataHub URNs before execution.
type URNResolverMiddleware ¶ added in v0.2.0
type URNResolverMiddleware struct {
// contains filtered or unexported fields
}
URNResolverMiddleware wraps a URNResolver to resolve external IDs to DataHub URNs.
func NewURNResolverMiddleware ¶ added in v0.2.0
func NewURNResolverMiddleware(r integration.URNResolver) *URNResolverMiddleware
NewURNResolverMiddleware creates a middleware that resolves external IDs to DataHub URNs.
func (*URNResolverMiddleware) After ¶ added in v0.2.0
func (m *URNResolverMiddleware) After(_ context.Context, _ *ToolContext, result *mcp.CallToolResult, _ error) (*mcp.CallToolResult, error)
After implements ToolMiddleware (no-op).
func (*URNResolverMiddleware) Before ¶ added in v0.2.0
func (m *URNResolverMiddleware) Before(ctx context.Context, tc *ToolContext) (context.Context, error)
Before implements ToolMiddleware.
type UpdateInput ¶ added in v1.5.0
type UpdateInput struct {
//nolint:lll // struct tag cannot be split
What string `` /* 553-byte string literal not displayed */
//nolint:lll // struct tag cannot be split
Action string `` /* 210-byte string literal not displayed */
// Entity identification
URN string `json:"urn" jsonschema_description:"URN of the entity to update"`
// Common value field
Value string `json:"value,omitempty" jsonschema_description:"New value (description text, status, sub_type, label, message, etc.)"`
// Target URN for add/remove operations (tag, glossary_term, owner, domain)
TargetURN string `json:"target_urn,omitempty" jsonschema_description:"Target URN (tag, glossary term, owner, or domain URN)"`
// Link-specific fields
URL string `json:"url,omitempty" jsonschema_description:"URL for link operations"`
// Column description
FieldPath string `json:"field_path,omitempty" jsonschema_description:"Schema field path (column_description only)"`
// Owner-specific
OwnershipType string `json:"ownership_type,omitempty" jsonschema_description:"Ownership type (owner add only, e.g. TECHNICAL_OWNER)"`
// Structured properties on assets
Properties []types.StructuredPropertyInput `json:"properties,omitempty" jsonschema_description:"Structured property values to set"`
PropertyURNs []string `json:"property_urns,omitempty" jsonschema_description:"Property URNs to remove"`
// Query-specific
Name string `json:"name,omitempty" jsonschema_description:"Updated name (query, incident, structured_property)"`
Description string `json:"description,omitempty" jsonschema_description:"Updated description"`
Language string `json:"language,omitempty" jsonschema_description:"Query language (query only)"`
DatasetURNs []string `json:"dataset_urns,omitempty" jsonschema_description:"Dataset URNs (query, data_contract)"`
// Incident-specific
IncidentType string `json:"incident_type,omitempty" jsonschema_description:"Incident type (incident only)"`
Priority string `json:"priority,omitempty" jsonschema_description:"Priority: LOW, MEDIUM, HIGH, CRITICAL (incident only)"`
State string `json:"state,omitempty" jsonschema_description:"Incident state: ACTIVE, RESOLVED (incident_status only)"`
// Document-specific
Title string `json:"title,omitempty" jsonschema_description:"Document title (document_contents only)"`
Text string `json:"text,omitempty" jsonschema_description:"Document text (document_contents only)"`
EntityURNs []string `json:"entity_urns,omitempty" jsonschema_description:"Related entity URNs (document_related_entities only)"`
// Data contract fields
SchemaAssertions []string `json:"schema_assertions,omitempty" jsonschema_description:"Schema assertion URNs"`
//nolint:lll // struct tag
FreshnessAssertions []string `json:"freshness_assertions,omitempty" jsonschema_description:"Freshness assertion URNs (data_contract only)"`
DataQualityAssertions []string `json:"data_quality_assertions,omitempty" jsonschema_description:"Data quality assertion URNs"`
Connection string `json:"connection,omitempty" jsonschema_description:"Named connection to use (see datahub_list_connections)"`
}
UpdateInput is the input for the datahub_update tool.
Source Files
¶
- annotations.go
- browse.go
- client_interface.go
- config.go
- connections.go
- context.go
- dataproducts.go
- descriptions.go
- doc.go
- entity.go
- errors.go
- glossary.go
- icons.go
- integration_adapters.go
- lineage.go
- middleware.go
- names.go
- options.go
- output_schemas.go
- outputs.go
- queries.go
- schema.go
- search.go
- titles.go
- toolkit.go
- write_create.go
- write_delete.go
- write_update.go
- write_update_handlers.go