Documentation
¶
Overview ¶
Package mcp provides Model Context Protocol server functionality.
Index ¶
- func ServerInstructions() string
- type CommitFinder
- type DiskPathResolver
- type EnrichmentLookup
- type EnrichmentQuery
- type EnrichmentResolver
- type FileContentReader
- type FileFinder
- type FileLister
- type FileURI
- type Grepper
- type KeywordSearcher
- type ParamDefinition
- type RepositoryLister
- type SemanticSearcher
- type Server
- type ServerOption
- type ToolDefinition
- type VisualSearcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServerInstructions ¶ added in v1.1.3
func ServerInstructions() string
ServerInstructions returns the MCP server usage instructions.
Types ¶
type CommitFinder ¶
type CommitFinder interface {
Find(ctx context.Context, options ...repository.Option) ([]repository.Commit, error)
}
CommitFinder provides commit querying for MCP tools.
type DiskPathResolver ¶ added in v1.3.0
type DiskPathResolver interface {
DiskPath(ctx context.Context, repoID int64, blobName, filePath string) (string, string, error)
}
DiskPathResolver resolves a blob reference to an on-disk file path.
type EnrichmentLookup ¶
type EnrichmentLookup interface {
Get(ctx context.Context, options ...repository.Option) (enrichment.Enrichment, error)
}
EnrichmentLookup provides enrichment retrieval by ID for MCP tools.
type EnrichmentQuery ¶
type EnrichmentQuery interface {
List(ctx context.Context, params *service.EnrichmentListParams) ([]enrichment.Enrichment, error)
}
EnrichmentQuery provides enrichment listing for MCP tools.
type EnrichmentResolver ¶
type EnrichmentResolver interface {
SourceFiles(ctx context.Context, enrichmentIDs []int64) (map[string][]int64, error)
SourceLocations(ctx context.Context, enrichmentIDs []int64) (map[string]sourcelocation.SourceLocation, error)
// RepositoryIDs returns, keyed by enrichment ID, the repositories each
// enrichment belongs to, in ascending order.
RepositoryIDs(ctx context.Context, enrichmentIDs []int64) (map[string][]int64, error)
}
EnrichmentResolver provides enrichment-to-entity resolution.
type FileContentReader ¶
type FileContentReader interface {
Content(ctx context.Context, repoID int64, blobName, filePath string) (service.BlobContent, error)
}
FileContentReader provides raw file content from Git repositories.
type FileFinder ¶
type FileFinder interface {
Find(ctx context.Context, options ...repository.Option) ([]repository.File, error)
}
FileFinder provides file lookups by options.
type FileLister ¶
type FileLister interface {
ListFiles(ctx context.Context, repoID int64, pattern string) ([]service.FileEntry, error)
}
FileLister provides pattern-based file listing from repository working copies.
type FileURI ¶
type FileURI struct {
// contains filtered or unexported fields
}
FileURI builds file resource URIs for MCP resource templates. Immutable value object — methods return copies.
func NewFileURI ¶
NewFileURI creates a FileURI with the required fields.
func (FileURI) WithLineRange ¶
WithLineRange returns a copy with line range set.
type Grepper ¶
type Grepper interface {
Search(ctx context.Context, repoID int64, pattern string, pathspec string, maxFiles int) ([]service.GrepResult, error)
}
Grepper provides git grep search over repositories.
type KeywordSearcher ¶
type KeywordSearcher interface {
SearchKeywordsWithScores(ctx context.Context, query string, limit int, filters search.Filters) ([]enrichment.Enrichment, map[string]float64, error)
}
KeywordSearcher provides BM25 keyword search with scores.
type ParamDefinition ¶ added in v1.1.3
type ParamDefinition struct {
// contains filtered or unexported fields
}
ParamDefinition describes a single parameter in a tool definition.
func (ParamDefinition) Description ¶ added in v1.1.3
func (p ParamDefinition) Description() string
Description returns the parameter description.
func (ParamDefinition) Name ¶ added in v1.1.3
func (p ParamDefinition) Name() string
Name returns the parameter name.
func (ParamDefinition) Required ¶ added in v1.1.3
func (p ParamDefinition) Required() bool
Required reports whether the parameter is required.
func (ParamDefinition) Type ¶ added in v1.1.3
func (p ParamDefinition) Type() string
Type returns the parameter type (e.g. "string", "number").
type RepositoryLister ¶
type RepositoryLister interface {
Find(ctx context.Context, options ...repository.Option) ([]repository.Repository, error)
}
RepositoryLister provides repository listing for MCP tools.
type SemanticSearcher ¶
type SemanticSearcher interface {
SearchCodeWithScores(ctx context.Context, query string, topK int, filters search.Filters) ([]enrichment.Enrichment, map[string]float64, error)
}
SemanticSearcher provides code vector search with scores.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the MCP server with kodit-specific tools.
func NewServer ¶
func NewServer( repositories RepositoryLister, commits CommitFinder, enrichmentQuery EnrichmentQuery, fileContent FileContentReader, semanticSearch SemanticSearcher, keywordSearch KeywordSearcher, visualSearch VisualSearcher, enrichmentResolver EnrichmentResolver, fileLister FileLister, files FileFinder, grepper Grepper, version string, logger zerolog.Logger, opts ...ServerOption, ) *Server
NewServer creates a new MCP server with the given dependencies.
func (*Server) ServeStdio ¶
ServeStdio runs the MCP server on stdio.
type ServerOption ¶ added in v1.3.0
type ServerOption func(*Server)
ServerOption configures optional Server dependencies.
func WithRasterization ¶ added in v1.3.0
func WithRasterization(diskPaths DiskPathResolver, rasterizers *rasterization.Registry) ServerOption
WithRasterization enables raster mode for file resource reads.
func WithRepositoryScope ¶ added in v1.4.0
func WithRepositoryScope(repoIDs []int64) ServerOption
WithRepositoryScope restricts the server to the given repository IDs.
NewServer wraps every repository-bound dependency (repositories, commits, file content, every read mode's disk path resolver, semantic, keyword and visual search, grep and file listing) after all other options are applied, so no dependency can reach the server unscoped. Search results are also post-filtered against the scope.
An empty or nil repoIDs scopes the server to no repositories: every tool sees nothing. Build the server without this option to see all repositories.
func WithTextRendering ¶ added in v1.3.1
func WithTextRendering(diskPaths DiskPathResolver, textRenderers *extraction.TextRendererRegistry) ServerOption
WithTextRendering enables text mode for file resource reads.
type ToolDefinition ¶ added in v1.1.3
type ToolDefinition struct {
// contains filtered or unexported fields
}
ToolDefinition describes a tool and its parameters.
func ToolDefinitions ¶ added in v1.1.3
func ToolDefinitions() []ToolDefinition
ToolDefinitions returns the canonical list of MCP tool definitions.
func (ToolDefinition) Description ¶ added in v1.1.3
func (d ToolDefinition) Description() string
Description returns the tool description.
func (ToolDefinition) Name ¶ added in v1.1.3
func (d ToolDefinition) Name() string
Name returns the tool name.
func (ToolDefinition) Params ¶ added in v1.1.3
func (d ToolDefinition) Params() []ParamDefinition
Params returns the tool's parameter definitions.
type VisualSearcher ¶ added in v1.3.0
type VisualSearcher interface {
SearchVisualWithScores(ctx context.Context, query string, topK int, filters search.Filters) ([]enrichment.Enrichment, map[string]float64, error)
}
VisualSearcher provides cross-modal visual search with scores.