mcp

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxTokensPerChunk = 30000 // Default fallback value

Variables

This section is empty.

Functions

func GenerateDirectoryStructure

func GenerateDirectoryStructure(path string, allowedFileList []string, opt *commandline.Option) ([]string, error)

func HandleChunkByID

func HandleChunkByID(root string, files []string) http.HandlerFunc

HandleChunkByID serves one chunk's file contents in arklite-like format

func HandleChunks

func HandleChunks(root string, files []string) http.HandlerFunc

HandleChunks serves the list of available chunks as JSON

func HandleFile

func HandleFile(root string, allowedFiles []string, opt *commandline.ServeOption) http.HandlerFunc

HandleFile serves the content of a single file specified via query param "path"

func HandleMetadata

func HandleMetadata() http.HandlerFunc

HandleMetadata returns static info about available endpoints

func HandleSearch

func HandleSearch(root string, allowedFiles []string) http.HandlerFunc

HandleSearch allows simple plain-text search over allowed files

func HandleStructureJSON

func HandleStructureJSON(allowedFiles []string) http.HandlerFunc

HandleStructureJSON serves the project structure as a hierarchical JSON tree

func RunMCPServe

func RunMCPServe(root string, serverOpt *commandline.ServeOption)

RunMCPServe launches an MCP-compatible HTTP server using ProjectWatcher

func SetupRoutes

func SetupRoutes(root string, pw *ProjectWatcher, serverOpt *commandline.ServeOption) http.Handler

SetupRoutes initializes all MCP endpoints using the ProjectWatcher.

Types

type Chunk

type Chunk struct {
	ID            int      `json:"id"`
	TokenEstimate int      `json:"token_estimate"`
	Files         []string `json:"files"`
}

Chunk represents a group of files split by token estimate

type ChunkIndex

type ChunkIndex struct {
	TotalTokensEstimate int     `json:"total_tokens_estimate"`
	MaxPerChunk         int     `json:"max_per_chunk"`
	Chunks              []Chunk `json:"chunks"`
}

func GenerateChunkIndex

func GenerateChunkIndex(root string, files []string, maxChunkSize int) (ChunkIndex, error)

GenerateChunkIndex generates a list of file-based chunks given a root dir and a list of allowed files

type EndpointMeta

type EndpointMeta struct {
	Path        string `json:"path"`
	Description string `json:"description"`
	Method      string `json:"method"`
}

type FileNode

type FileNode struct {
	Name     string     `json:"name"`
	Type     string     `json:"type"` // "file" or "dir"
	Children []FileNode `json:"children,omitempty"`
}

type Metadata

type Metadata struct {
	Name          string         `json:"name"`
	InterfaceType string         `json:"interfaceType"`
	Description   string         `json:"description"`
	Endpoints     []EndpointMeta `json:"endpoints"`
}

type ProjectWatcher

type ProjectWatcher struct {
	Root         string
	AllowedFiles []string
	// contains filtered or unexported fields
}

func NewProjectWatcher

func NewProjectWatcher(root string, initial []string, rescan func(string) []string) *ProjectWatcher

func (*ProjectWatcher) GetAllowed

func (pw *ProjectWatcher) GetAllowed() []string

GetAllowed returns the current allowed file list

func (*ProjectWatcher) RefreshIfDirty

func (pw *ProjectWatcher) RefreshIfDirty()

RefreshIfDirty rescans files if dirty flag is set

func (*ProjectWatcher) ShouldRefresh

func (pw *ProjectWatcher) ShouldRefresh() bool

ShouldRefresh tells whether refresh hint should be set

type SearchResult

type SearchResult struct {
	Path    string `json:"path"`
	Line    int    `json:"line"`
	Snippet string `json:"snippet"`
}

Jump to

Keyboard shortcuts

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