Documentation
¶
Overview ¶
Package mcp provides instance resolution tools for the MCP server.
Package mcp provides query standardization for MCP.
Index ¶
- Constants
- func EncodeCursor(offset int, query string) string
- func ExtractPaginationParams(args map[string]any) (*PaginationParams, *RPCError)
- func NewToolError(message string, code int, details any) string
- func TruncateNotice(s string, n int) string
- type Analytics
- func (a *Analytics) EndToolCall(m *ToolCallMetrics, success bool)
- func (a *Analytics) ReportClientConnected(clientName, clientVersion string)
- func (a *Analytics) ReportIndexingComplete(stats *IndexingStats)
- func (a *Analytics) ReportIndexingFailed(phase string)
- func (a *Analytics) ReportIndexingStarted()
- func (a *Analytics) ReportServerStarted()
- func (a *Analytics) ReportServerStopped()
- func (a *Analytics) ReportToolCall(toolName string, durationMs int64, success bool)
- func (a *Analytics) StartToolCall(toolName string) *ToolCallMetrics
- type AnnouncementInfo
- type Capabilities
- type ClientInfo
- type ComposeServiceProperties
- type ContentBlock
- type CopyDetails
- type Cursor
- type DefinitionLocation
- type ExposeDetails
- type FromDetails
- type GetInstanceTypeRequest
- type GetInstanceTypeResponse
- type GracefulDegradation
- type HTTPConfig
- type HTTPServer
- type IndexingPhase
- type IndexingProgress
- type IndexingState
- type IndexingStats
- type IndexingStatus
- type InitializeParams
- type InitializeResult
- type InputSchema
- type InstanceCallContext
- type InstanceToolHandler
- type JSONRPCRequest
- type JSONRPCResponse
- type PaginatedResult
- type PaginationInfo
- type PaginationParams
- type Property
- type QueryPattern
- type QueryResolver
- type RPCError
- func IndexNotReadyError(phase string, progress float64) *RPCError
- func InternalError(detail string) *RPCError
- func InvalidParamsError(detail string) *RPCError
- func InvalidRequestError(detail string) *RPCError
- func MethodNotFoundError(method string) *RPCError
- func NewRPCError(code int, data any) *RPCError
- func NewRPCErrorWithMessage(code int, message string, data any) *RPCError
- func ParseError(detail string) *RPCError
- func QueryTimeoutError(timeout string) *RPCError
- func SymbolNotFoundError(symbol string, suggestions []string) *RPCError
- func ValidateIntParam(args map[string]any, name string, defaultVal int) (int, *RPCError)
- func ValidateRequiredParams(args map[string]any, required []string) *RPCError
- func ValidateStringParam(args map[string]any, name string) (string, *RPCError)
- type ResolveInstanceCallRequest
- type ResolveInstanceCallResponse
- type SSEServer
- type Server
- func (s *Server) GetStatusTracker() *StatusTracker
- func (s *Server) IsReady() bool
- func (s *Server) ServeStdio() error
- func (s *Server) SetGoContext(version string, reg *core.GoModuleRegistry)
- func (s *Server) SetIndexReady(callGraph *core.CallGraph, moduleReg *core.ModuleRegistry, ...)
- func (s *Server) SetIndexingError(err error)
- func (s *Server) SetTransport(transport string)
- func (s *Server) SetVersion(version string)
- func (s *Server) UpdateIndexingStatus(state IndexingState, phase IndexingPhase, message string, progress float64)
- type ServerInfo
- type ServerMetadata
- type StandardizedQuery
- type StatusTracker
- func (t *StatusTracker) CompleteIndexing(stats *IndexingStats)
- func (t *StatusTracker) FailIndexing(err error)
- func (t *StatusTracker) GetState() IndexingState
- func (t *StatusTracker) GetStatus() IndexingStatus
- func (t *StatusTracker) IsReady() bool
- func (t *StatusTracker) SetPhase(phase IndexingPhase, message string)
- func (t *StatusTracker) StartIndexing()
- func (t *StatusTracker) Subscribe() chan IndexingStatus
- func (t *StatusTracker) Unsubscribe(ch chan IndexingStatus)
- func (t *StatusTracker) UpdateProgress(processed, total int, currentFile string)
- type StreamingHTTPHandler
- type Tool
- type ToolCallMetrics
- type ToolCallParams
- type ToolError
- type ToolResult
- type ToolsCapability
- type ToolsListResult
- type UserDetails
Constants ¶
const ( ErrCodeParseError = -32700 ErrCodeInvalidRequest = -32600 ErrCodeMethodNotFound = -32601 ErrCodeInvalidParams = -32602 ErrCodeInternalError = -32603 // Custom server error codes (-32000 to -32099). ErrCodeSymbolNotFound = -32001 ErrCodeIndexNotReady = -32002 ErrCodeQueryTimeout = -32003 ErrCodeResultsTruncated = -32004 )
Standard JSON-RPC 2.0 error codes.
const ( DefaultLimit = 50 MaxLimit = 500 )
Default and max limits.
const ( SymbolKindFile = 1 // File SymbolKindModule = 2 // Module SymbolKindNamespace = 3 // Namespace (not used in Python) SymbolKindPackage = 4 // Package SymbolKindClass = 5 // Class SymbolKindMethod = 6 // Method SymbolKindProperty = 7 // Property SymbolKindField = 8 // Field SymbolKindConstructor = 9 // Constructor SymbolKindEnum = 10 // Enum SymbolKindInterface = 11 // Interface SymbolKindFunction = 12 // Function SymbolKindVariable = 13 // Variable SymbolKindConstant = 14 // Constant SymbolKindString = 15 // String (not used for symbols) SymbolKindNumber = 16 // Number (not used for symbols) SymbolKindBoolean = 17 // Boolean (not used for symbols) SymbolKindArray = 18 // Array (not used for symbols) SymbolKindObject = 19 // Object (not used for symbols) SymbolKindKey = 20 // Key (not used for symbols) SymbolKindNull = 21 // Null (not used for symbols) SymbolKindEnumMember = 22 // EnumMember SymbolKindStruct = 23 // Struct (dataclass) SymbolKindEvent = 24 // Event (not used in Python) SymbolKindOperator = 25 // Operator (special methods) SymbolKindTypeParam = 26 // TypeParameter )
LSP Symbol Kind constants (Language Server Protocol specification). Maps Python symbol types to standardized LSP SymbolKind integers. Reference: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#symbolKind
Variables ¶
This section is empty.
Functions ¶
func EncodeCursor ¶
EncodeCursor creates an opaque cursor string.
func ExtractPaginationParams ¶
func ExtractPaginationParams(args map[string]any) (*PaginationParams, *RPCError)
ExtractPaginationParams extracts and validates pagination params.
func NewToolError ¶
NewToolError creates a JSON-formatted tool error response.
func TruncateNotice ¶
TruncateNotice caps s at n bytes, appending "…" (a single UTF-8 ellipsis character, 3 bytes) when truncation is needed. The total result is always ≤ n bytes. Exported for testing.
Types ¶
type Analytics ¶
type Analytics struct {
// contains filtered or unexported fields
}
Analytics provides MCP-specific telemetry helpers. All events are anonymous and contain no PII.
func NewAnalytics ¶
NewAnalytics creates a new analytics instance.
func (*Analytics) EndToolCall ¶
func (a *Analytics) EndToolCall(m *ToolCallMetrics, success bool)
EndToolCall completes tracking and reports the metric.
func (*Analytics) ReportClientConnected ¶
ReportClientConnected reports a client connection with client info. Only client name/version (from MCP protocol) is reported.
func (*Analytics) ReportIndexingComplete ¶
func (a *Analytics) ReportIndexingComplete(stats *IndexingStats)
ReportIndexingComplete reports successful indexing completion. Only aggregate counts are reported, no file paths.
func (*Analytics) ReportIndexingFailed ¶
ReportIndexingFailed reports indexing failure. Error messages are not included to avoid potential PII.
func (*Analytics) ReportIndexingStarted ¶
func (a *Analytics) ReportIndexingStarted()
ReportIndexingStarted reports that indexing has begun.
func (*Analytics) ReportServerStarted ¶
func (a *Analytics) ReportServerStarted()
ReportServerStarted reports that the MCP server has started.
func (*Analytics) ReportServerStopped ¶
func (a *Analytics) ReportServerStopped()
ReportServerStopped reports that the MCP server has stopped.
func (*Analytics) ReportToolCall ¶
ReportToolCall reports a tool invocation with timing and success info. No file paths or code content is included.
func (*Analytics) StartToolCall ¶
func (a *Analytics) StartToolCall(toolName string) *ToolCallMetrics
StartToolCall begins tracking a tool call.
type AnnouncementInfo ¶
type AnnouncementInfo struct {
ID string `json:"id"`
Level string `json:"level"`
Title string `json:"title"`
Text string `json:"text"`
URL string `json:"url,omitempty"`
}
AnnouncementInfo is the wire shape of a single operator announcement embedded in ServerMetadata and in the structured status tool result.
type Capabilities ¶
type Capabilities struct {
Tools *ToolsCapability `json:"tools,omitempty"`
}
Capabilities advertises server features.
type ClientInfo ¶
ClientInfo identifies the MCP client.
type ComposeServiceProperties ¶
type ComposeServiceProperties struct {
Image string
Build string
Ports []string
Volumes []string
Environment []string
Privileged bool
NetworkMode string
CapAdd []string
CapDrop []string
SecurityOpt []string
}
ComposeServiceProperties contains parsed compose service data.
type ContentBlock ¶
ContentBlock represents a content block for tool output.
type CopyDetails ¶
type CopyDetails struct {
Source string // Source path
Destination string // Destination path
FromStage string // --from flag value (empty if not multi-stage copy)
Chown string // --chown flag value (empty if not specified)
}
CopyDetails contains parsed COPY/ADD instruction data.
type Cursor ¶
Cursor represents an opaque pagination cursor.
func DecodeCursor ¶
DecodeCursor parses a cursor string.
type DefinitionLocation ¶
type DefinitionLocation struct {
FilePath string `json:"file_path"` //nolint:tagliatelle // MCP protocol uses snake_case
Line int `json:"line"`
Column int `json:"column"`
Signature string `json:"signature,omitempty"`
Docstring string `json:"docstring,omitempty"`
}
DefinitionLocation represents where a method is defined.
type ExposeDetails ¶
type ExposeDetails struct {
Port int // Port number
Protocol string // "tcp" or "udp" (default: "tcp")
}
ExposeDetails contains parsed EXPOSE instruction data.
type FromDetails ¶
type FromDetails struct {
BaseImage string // e.g., "python"
Tag string // e.g., "3.11" or "latest" (default if omitted)
Digest string // e.g., "sha256:abc123..." (empty if not pinned)
StageAlias string // e.g., "builder" (from AS clause, empty if single-stage)
}
FromDetails contains parsed FROM instruction data.
type GetInstanceTypeRequest ¶
type GetInstanceTypeRequest struct {
Variable string `json:"variable"`
FilePath string `json:"file_path"` //nolint:tagliatelle // MCP protocol uses snake_case
Line int `json:"line"`
}
GetInstanceTypeRequest represents the input for get_instance_type.
type GetInstanceTypeResponse ¶
type GetInstanceTypeResponse struct {
Success bool `json:"success"`
TypeFQN string `json:"type_fqn,omitempty"` //nolint:tagliatelle // MCP protocol uses snake_case
Confidence float64 `json:"confidence"`
Source string `json:"source,omitempty"`
Error string `json:"error,omitempty"`
}
GetInstanceTypeResponse represents the output for get_instance_type.
type GracefulDegradation ¶
type GracefulDegradation struct {
// contains filtered or unexported fields
}
GracefulDegradation provides methods for handling requests during indexing.
func NewGracefulDegradation ¶
func NewGracefulDegradation(tracker *StatusTracker) *GracefulDegradation
NewGracefulDegradation creates a new graceful degradation handler.
func (*GracefulDegradation) CheckReady ¶
func (g *GracefulDegradation) CheckReady() *RPCError
CheckReady checks if the server is ready and returns an appropriate error if not.
func (*GracefulDegradation) GetStatusJSON ¶
func (g *GracefulDegradation) GetStatusJSON() map[string]any
GetStatusJSON returns the current status as a JSON-friendly map.
func (*GracefulDegradation) WrapToolCall ¶
func (g *GracefulDegradation) WrapToolCall(toolName string, fn func() (string, bool)) (string, bool)
WrapToolCall wraps a tool call with readiness checking.
type HTTPConfig ¶
type HTTPConfig struct {
Address string
ReadTimeout time.Duration
WriteTimeout time.Duration
ShutdownTimeout time.Duration
AllowedOrigins []string
}
HTTPConfig holds configuration for the HTTP server.
func DefaultHTTPConfig ¶
func DefaultHTTPConfig() *HTTPConfig
DefaultHTTPConfig returns sensible defaults.
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer wraps the MCP server with HTTP transport.
func NewHTTPServer ¶
func NewHTTPServer(mcpServer *Server, config *HTTPConfig) *HTTPServer
NewHTTPServer creates a new HTTP server wrapping the MCP server.
func (*HTTPServer) Address ¶
func (h *HTTPServer) Address() string
Address returns the configured address.
func (*HTTPServer) IsRunning ¶
func (h *HTTPServer) IsRunning() bool
IsRunning returns whether the server is running.
func (*HTTPServer) ServeHTTP ¶
func (h *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler for JSON-RPC requests.
func (*HTTPServer) Shutdown ¶
func (h *HTTPServer) Shutdown(ctx context.Context) error
Shutdown gracefully shuts down the HTTP server.
func (*HTTPServer) StartAsync ¶
func (h *HTTPServer) StartAsync() error
StartAsync starts the HTTP server in a goroutine and returns immediately.
type IndexingPhase ¶
type IndexingPhase int
IndexingPhase represents the current phase of indexing.
const ( PhaseNone IndexingPhase = iota PhaseParsing PhaseModuleRegistry PhaseCallGraph PhaseComplete )
func (IndexingPhase) String ¶
func (p IndexingPhase) String() string
String returns the string representation of the phase.
type IndexingProgress ¶
type IndexingProgress struct {
Phase IndexingPhase `json:"phase"`
PhaseProgress float64 `json:"phaseProgress"` // 0.0 to 1.0
OverallProgress float64 `json:"overallProgress"` // 0.0 to 1.0
FilesProcessed int `json:"filesProcessed"`
TotalFiles int `json:"totalFiles"`
CurrentFile string `json:"currentFile,omitempty"`
Message string `json:"message,omitempty"`
}
IndexingProgress holds detailed progress information.
type IndexingState ¶
type IndexingState int
IndexingState represents the current state of the indexing process.
const ( // StateUninitialized means indexing hasn't started yet. StateUninitialized IndexingState = iota // StateIndexing means indexing is in progress. StateIndexing // StateReady means indexing is complete and server is ready. StateReady // StateFailed means indexing failed. StateFailed )
func (IndexingState) String ¶
func (s IndexingState) String() string
String returns the string representation of the state.
type IndexingStats ¶
type IndexingStats struct {
Functions int `json:"functions"`
CallEdges int `json:"callEdges"`
Modules int `json:"modules"`
Files int `json:"files"`
BuildDuration time.Duration `json:"buildDuration"`
}
IndexingStats holds statistics after indexing completes.
type IndexingStatus ¶
type IndexingStatus struct {
State IndexingState `json:"state"`
Progress IndexingProgress `json:"progress"`
StartedAt *time.Time `json:"startedAt,omitempty"`
CompletedAt *time.Time `json:"completedAt,omitempty"`
Error string `json:"error,omitempty"`
Stats *IndexingStats `json:"stats,omitempty"`
}
IndexingStatus holds the complete indexing status.
type InitializeParams ¶
type InitializeParams struct {
ProtocolVersion string `json:"protocolVersion"`
ClientInfo ClientInfo `json:"clientInfo"`
}
InitializeParams contains initialization parameters from the client.
type InitializeResult ¶
type InitializeResult struct {
ProtocolVersion string `json:"protocolVersion"`
ServerInfo ServerInfo `json:"serverInfo"`
Capabilities Capabilities `json:"capabilities"`
}
InitializeResult is returned to the client after initialization.
type InputSchema ¶
type InputSchema struct {
Type string `json:"type"`
Properties map[string]Property `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
}
InputSchema describes tool parameters.
type InstanceCallContext ¶
type InstanceCallContext struct {
SelfType string `json:"self_type,omitempty"` //nolint:tagliatelle // MCP protocol uses snake_case
Variables map[string]string `json:"variables,omitempty"`
}
InstanceCallContext provides additional context for resolution.
type InstanceToolHandler ¶
type InstanceToolHandler struct {
// contains filtered or unexported fields
}
InstanceToolHandler handles instance resolution MCP tools.
func NewInstanceToolHandler ¶
func NewInstanceToolHandler( inferencer *resolution.BidirectionalInferencer, attrRegistry strategies.AttributeRegistryInterface, callGraph *core.CallGraph, ) *InstanceToolHandler
NewInstanceToolHandler creates a new InstanceToolHandler.
func (*InstanceToolHandler) HandleGetInstanceType ¶
func (h *InstanceToolHandler) HandleGetInstanceType(args json.RawMessage) (*GetInstanceTypeResponse, error)
HandleGetInstanceType handles the get_instance_type tool.
func (*InstanceToolHandler) HandleResolveInstanceCall ¶
func (h *InstanceToolHandler) HandleResolveInstanceCall(args json.RawMessage) (*ResolveInstanceCallResponse, error)
HandleResolveInstanceCall handles the resolve_instance_call tool.
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
JSONRPCRequest represents a JSON-RPC 2.0 request.
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Result any `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
JSONRPCResponse represents a JSON-RPC 2.0 response.
func ErrorResponse ¶
func ErrorResponse(id any, code int, message string) *JSONRPCResponse
ErrorResponse creates an error JSON-RPC response.
func MakeErrorResponse ¶
func MakeErrorResponse(id any, err *RPCError) *JSONRPCResponse
MakeErrorResponse creates a JSON-RPC error response from an RPCError.
func SuccessResponse ¶
func SuccessResponse(id any, result any) *JSONRPCResponse
SuccessResponse creates a successful JSON-RPC response.
type PaginatedResult ¶
type PaginatedResult struct {
Items any `json:"items"`
Pagination PaginationInfo `json:"pagination"`
}
PaginatedResult wraps results with pagination info.
func NewPaginatedResult ¶
func NewPaginatedResult(items any, info *PaginationInfo) *PaginatedResult
NewPaginatedResult creates a paginated result.
type PaginationInfo ¶
type PaginationInfo struct {
Total int `json:"total"`
Returned int `json:"returned"`
HasMore bool `json:"hasMore"`
NextCursor string `json:"nextCursor,omitempty"`
}
PaginationInfo holds pagination metadata for response.
func PaginateSlice ¶
func PaginateSlice[T any](items []T, params *PaginationParams) ([]T, *PaginationInfo)
PaginateSlice applies pagination to a slice of any type.
type PaginationParams ¶
PaginationParams holds pagination parameters from request.
type QueryPattern ¶
type QueryPattern int
QueryPattern represents a recognized query pattern.
const ( // PatternUnknown represents an unrecognized pattern. PatternUnknown QueryPattern = iota // PatternDirectFQN represents myapp.models.User.get_name. PatternDirectFQN // PatternInstanceCall represents user.get_name(). PatternInstanceCall // PatternSelfCall represents self.process(). PatternSelfCall // PatternChainedCall represents app.service.run(). PatternChainedCall // PatternInlineInstantiation represents UserService().get_user(). PatternInlineInstantiation // PatternStaticMethod represents ClassName.static_method(). PatternStaticMethod // PatternClassMethod represents ClassName.class_method(). PatternClassMethod )
type QueryResolver ¶
type QueryResolver struct {
// contains filtered or unexported fields
}
QueryResolver standardizes various query formats to canonical FQN.
func NewQueryResolver ¶
func NewQueryResolver( inferencer *resolution.BidirectionalInferencer, attrRegistry strategies.AttributeRegistryInterface, ) *QueryResolver
NewQueryResolver creates a new QueryResolver.
func (*QueryResolver) ResolveChainedQuery ¶
func (r *QueryResolver) ResolveChainedQuery( query string, filePath string, knownVariables map[string]string, selfType string, ) *StandardizedQuery
ResolveChainedQuery resolves chained queries like app.service.run().
func (*QueryResolver) StandardizeQuery ¶
func (r *QueryResolver) StandardizeQuery( query string, knownVariables map[string]string, selfType string, ) *StandardizedQuery
StandardizeQuery converts a user query to canonical form.
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
RPCError represents a JSON-RPC 2.0 error.
func IndexNotReadyError ¶
IndexNotReadyError creates an index not ready error with optional progress info.
func InternalError ¶
InternalError creates an internal error.
func InvalidParamsError ¶
InvalidParamsError creates an invalid params error.
func InvalidRequestError ¶
InvalidRequestError creates an invalid request error.
func MethodNotFoundError ¶
MethodNotFoundError creates a method not found error.
func NewRPCError ¶
NewRPCError creates a new RPC error with optional data.
func NewRPCErrorWithMessage ¶
NewRPCErrorWithMessage creates an RPC error with custom message.
func ParseError ¶
ParseError creates a parse error response.
func QueryTimeoutError ¶
QueryTimeoutError creates a query timeout error.
func SymbolNotFoundError ¶
SymbolNotFoundError creates a symbol not found error with suggestions.
func ValidateIntParam ¶
ValidateIntParam validates an integer parameter with optional default.
func ValidateRequiredParams ¶
ValidateRequiredParams checks for required parameters.
func ValidateStringParam ¶
ValidateStringParam validates a string parameter.
type ResolveInstanceCallRequest ¶
type ResolveInstanceCallRequest struct {
Expression string `json:"expression"`
FilePath string `json:"file_path"` //nolint:tagliatelle // MCP protocol uses snake_case
Line int `json:"line"`
Column int `json:"column"`
Context *InstanceCallContext `json:"context,omitempty"`
}
ResolveInstanceCallRequest represents the input for resolve_instance_call.
type ResolveInstanceCallResponse ¶
type ResolveInstanceCallResponse struct {
Success bool `json:"success"`
ResolvedType string `json:"resolved_type,omitempty"` //nolint:tagliatelle // MCP protocol uses snake_case
Method string `json:"method,omitempty"`
CanonicalFQN string `json:"canonical_fqn,omitempty"` //nolint:tagliatelle // MCP protocol uses snake_case
Definition *DefinitionLocation `json:"definition,omitempty"`
Confidence float64 `json:"confidence"`
Error string `json:"error,omitempty"`
}
ResolveInstanceCallResponse represents the output for resolve_instance_call.
type SSEServer ¶
type SSEServer struct {
// contains filtered or unexported fields
}
SSEServer provides Server-Sent Events transport for streaming.
func NewSSEServer ¶
func NewSSEServer(httpServer *HTTPServer) *SSEServer
NewSSEServer creates a new SSE server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server handles MCP protocol communication.
func NewServer ¶
func NewServer( projectPath string, pythonVersion string, callGraph *core.CallGraph, moduleRegistry *core.ModuleRegistry, codeGraph *graph.CodeGraph, buildTime time.Duration, disableAnalytics bool, ) *Server
NewServer creates a new MCP server with the given index data.
func NewServerWithBackgroundIndexing ¶
func NewServerWithBackgroundIndexing(projectPath, pythonVersion string, disableAnalytics bool) *Server
NewServerWithBackgroundIndexing creates a server that will be populated via background indexing.
func (*Server) GetStatusTracker ¶
func (s *Server) GetStatusTracker() *StatusTracker
GetStatusTracker returns the status tracker for external use.
func (*Server) ServeStdio ¶
ServeStdio starts the MCP server on stdin/stdout.
func (*Server) SetGoContext ¶
func (s *Server) SetGoContext(version string, reg *core.GoModuleRegistry)
SetGoContext stores the Go version and module registry so that MCP tool responses can include stdlib metadata (is_stdlib, signature, return_type, etc.) for Go standard library calls.
Must be called after InitGoStdlibLoader has populated reg.StdlibLoader. Safe to skip — tools degrade gracefully when goModuleRegistry is nil.
func (*Server) SetIndexReady ¶
func (s *Server) SetIndexReady(callGraph *core.CallGraph, moduleReg *core.ModuleRegistry, codeGraph *graph.CodeGraph, buildTime time.Duration)
SetIndexReady marks indexing as complete and updates with indexed data.
func (*Server) SetIndexingError ¶
SetIndexingError marks indexing as failed.
func (*Server) SetTransport ¶
SetTransport updates the analytics transport type (e.g., "http").
func (*Server) SetVersion ¶
SetVersion sets the server version reported in MCP initialize responses. Should be called with cmd.Version (injected via ldflags at build time).
func (*Server) UpdateIndexingStatus ¶
func (s *Server) UpdateIndexingStatus(state IndexingState, phase IndexingPhase, message string, progress float64)
UpdateIndexingStatus updates the indexing progress.
type ServerInfo ¶
type ServerInfo struct {
Name string `json:"name"`
Version string `json:"version"`
Metadata *ServerMetadata `json:"metadata,omitempty"`
}
ServerInfo identifies this MCP server.
type ServerMetadata ¶
type ServerMetadata struct {
LatestVersion string `json:"latest_version,omitempty"` //nolint:tagliatelle
UpdateMessage string `json:"update_message,omitempty"` //nolint:tagliatelle
ReleaseURL string `json:"release_url,omitempty"` //nolint:tagliatelle
Announcement *AnnouncementInfo `json:"announcement,omitempty"`
}
ServerMetadata carries optional update-check information in the initialize response. All fields use omitempty so the payload stays compact when nothing is available.
type StandardizedQuery ¶
type StandardizedQuery struct {
OriginalQuery string
Pattern QueryPattern
CanonicalFQN string
ClassName string
MethodName string
Confidence float64
RequiresIndex bool // True if we need to look up in index
IndexQuery string // The query to use for index lookup
}
StandardizedQuery represents a normalized query.
type StatusTracker ¶
type StatusTracker struct {
// contains filtered or unexported fields
}
StatusTracker tracks and reports indexing status.
func NewStatusTracker ¶
func NewStatusTracker() *StatusTracker
NewStatusTracker creates a new status tracker.
func (*StatusTracker) CompleteIndexing ¶
func (t *StatusTracker) CompleteIndexing(stats *IndexingStats)
CompleteIndexing marks indexing as complete.
func (*StatusTracker) FailIndexing ¶
func (t *StatusTracker) FailIndexing(err error)
FailIndexing marks indexing as failed.
func (*StatusTracker) GetState ¶
func (t *StatusTracker) GetState() IndexingState
GetState returns the current indexing state.
func (*StatusTracker) GetStatus ¶
func (t *StatusTracker) GetStatus() IndexingStatus
GetStatus returns the current indexing status.
func (*StatusTracker) IsReady ¶
func (t *StatusTracker) IsReady() bool
IsReady returns true if the server is ready to handle requests.
func (*StatusTracker) SetPhase ¶
func (t *StatusTracker) SetPhase(phase IndexingPhase, message string)
SetPhase updates the current indexing phase.
func (*StatusTracker) StartIndexing ¶
func (t *StatusTracker) StartIndexing()
StartIndexing marks the start of indexing.
func (*StatusTracker) Subscribe ¶
func (t *StatusTracker) Subscribe() chan IndexingStatus
Subscribe returns a channel that receives status updates.
func (*StatusTracker) Unsubscribe ¶
func (t *StatusTracker) Unsubscribe(ch chan IndexingStatus)
Unsubscribe removes a subscription channel.
func (*StatusTracker) UpdateProgress ¶
func (t *StatusTracker) UpdateProgress(processed, total int, currentFile string)
UpdateProgress updates progress within the current phase.
type StreamingHTTPHandler ¶
type StreamingHTTPHandler struct {
// contains filtered or unexported fields
}
StreamingHTTPHandler provides a handler for streaming JSON-RPC over HTTP.
func NewStreamingHTTPHandler ¶
func NewStreamingHTTPHandler(server *Server) *StreamingHTTPHandler
NewStreamingHTTPHandler creates a new streaming handler.
func (*StreamingHTTPHandler) HandleStream ¶
HandleStream processes a stream of JSON-RPC requests.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema InputSchema `json:"inputSchema"`
}
Tool defines a tool for tools/list response.
type ToolCallMetrics ¶
ToolCallMetrics holds metrics for a tool call.
type ToolCallParams ¶
type ToolCallParams struct {
Name string `json:"name"`
Arguments map[string]any `json:"arguments,omitempty"`
}
ToolCallParams contains parameters for tools/call requests.
type ToolError ¶
type ToolError struct {
Error string `json:"error"`
Code int `json:"code,omitempty"`
Details any `json:"details,omitempty"`
}
ToolError represents a structured tool error response.
type ToolResult ¶
type ToolResult struct {
Content []ContentBlock `json:"content"`
IsError bool `json:"isError,omitempty"`
}
ToolResult is returned for tools/call responses.
type ToolsCapability ¶
type ToolsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
ToolsCapability describes tool support capabilities.
type ToolsListResult ¶
type ToolsListResult struct {
Tools []Tool `json:"tools"`
}
ToolsListResult is returned for tools/list requests.
type UserDetails ¶
type UserDetails struct {
User string // Username or UID
Group string // Group name or GID (empty if not specified)
}
UserDetails contains parsed USER instruction data.