mcp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package mcp serves the codesearch tools over MCP via stdio.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(defaultCfg *config.IndexConfig) error

Serve runs the codesearch MCP server on stdio until EOF.

Each tool call resolves its target project from the tool's optional project_path argument, falling back to defaultCfg when set. Per-project index handles are held in an index.Pool: each is opened lazily on the first tool call for that project and released after an idle window (see index.LazyIndex). This lets a concurrent `codesearch sync` (e.g. from a git hook) acquire the writer lock between bursts of MCP traffic.

defaultCfg may be nil. When it is, tools require project_path or return a clear error. When set (from `codesearch serve --root <path>`) its .codesearch/ must already exist.

Types

type FacetResult

type FacetResult struct {
	Term  string `json:"term"`
	Count int    `json:"count"`
}

FacetResult is one term entry returned by codesearch_facets.

type FacetsArgs

type FacetsArgs struct {
	Field       string `json:"field"`
	Limit       int    `json:"limit,omitempty"`
	ProjectPath string `json:"project_path,omitempty"`
}

FacetsArgs is the typed input for codesearch_facets.

type GetArgs

type GetArgs struct {
	Path        string `json:"path"`
	MaxBytes    int    `json:"max_bytes,omitempty"`
	ProjectPath string `json:"project_path,omitempty"`
}

GetArgs is the typed input for codesearch_get.

type GetResult

type GetResult struct {
	Path      string `json:"path"`
	Content   string `json:"content"`
	Truncated bool   `json:"truncated"`
}

GetResult is the response from codesearch_get.

type SearchArgs

type SearchArgs struct {
	Query       string            `json:"query"`
	Fields      map[string]string `json:"fields,omitempty"`
	Limit       int               `json:"limit,omitempty"`
	ProjectPath string            `json:"project_path,omitempty"`
}

SearchArgs is the typed input for codesearch_search.

type StatusResult

type StatusResult struct {
	IndexPath      string `json:"index_path"`
	DocCount       uint64 `json:"doc_count"`
	IndexSizeBytes int64  `json:"index_size_bytes"`
	SchemaVersion  int    `json:"schema_version"`
	LastSyncAt     string `json:"last_sync_at"`
}

StatusResult is the response from codesearch_status.

Jump to

Keyboard shortcuts

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