Documentation
¶
Index ¶
- func ConvertStatistics(stats *graph.ProjectStatistics) map[string]any
- func FilterExported(items []any) []any
- func GenerateFallbackCypher(naturalQuery, projectID string) string
- type GraphAdapter
- type MCPServer
- type ResourceResponse
- type Server
- func (s *Server) AddFunctionRelationships(ctx context.Context, result map[string]any, params map[string]any, ...)
- func (s *Server) AnalyzeFunctionNaming(results []map[string]any) map[string]any
- func (s *Server) AnalyzeInterfaceNaming(results []map[string]any) map[string]any
- func (s *Server) AnalyzeNamingConventions(ctx context.Context, projectID, _ string) map[string]any
- func (s *Server) AnalyzeTestCoverage(ctx context.Context, projectID, path string) TestCoverage
- func (s *Server) AnalyzeTypeNaming(results []map[string]any) map[string]any
- func (s *Server) BuildElementLocationQuery(elementType string) (string, error)
- func (s *Server) DetectCommonPatterns(ctx context.Context, projectID, _ string) []map[string]any
- func (s *Server) DetectErrorPattern(ctx context.Context, projectID string) map[string]any
- func (s *Server) DetectFactoryPattern(ctx context.Context, projectID string) map[string]any
- func (s *Server) DetectInterfacePattern(ctx context.Context, projectID string) map[string]any
- func (s *Server) ExtractCodeContextFromResults(results []map[string]any, projectID, elementType, name string, ...) (*ToolResponse, error)
- func (s *Server) FindTestsForElement(ctx context.Context, projectID, _, name, _ string) []map[string]any
- func (s *Server) HandleAnalyzeProjectInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleCheckTestCoverageInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleCodePatternsResource(_ context.Context, _ map[string]string) ([]byte, error)
- func (s *Server) HandleDetectCircularDepsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleDetectCodePatternsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleExecuteCypherInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleFindImplementationsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleFindTestsForCodeInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleGetCodeContextInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleGetFunctionInfoInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleGetNamingConventionsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleGetPackageStructureInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleListPackagesInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleListProjectsInternal(ctx context.Context, _ map[string]any) (*ToolResponse, error)
- func (s *Server) HandleNaturalLanguageQueryInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleProjectInvariantsResource(_ context.Context, params map[string]string) ([]byte, error)
- func (s *Server) HandleProjectMetadataResource(ctx context.Context, params map[string]string) ([]byte, error)
- func (s *Server) HandleQueryDependenciesInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleQueryTemplatesResource(_ context.Context, _ map[string]string) ([]byte, error)
- func (s *Server) HandleTraceCallChainInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleValidateImportPathInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleValidateProjectInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) HandleVerifyCodeExistsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
- func (s *Server) IsCamelCase(str string) bool
- func (s *Server) IsPascalCase(str string) bool
- func (s *Server) IsPathAllowed(path string) bool
- func (s *Server) IsStandardLibraryPackage(importPath string) bool
- func (s *Server) ParseCodeContextInput(input map[string]any) (projectID, elementType, name string, contextLines int, err error)
- func (s *Server) ReadFileContext(filePath string, targetLine, contextLines int) (string, error)
- func (s *Server) Start(_ context.Context) error
- type ServiceAdapter
- type TestCoverage
- type ToolResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertStatistics ¶
func ConvertStatistics(stats *graph.ProjectStatistics) map[string]any
func FilterExported ¶
func GenerateFallbackCypher ¶
Types ¶
type GraphAdapter ¶
type GraphAdapter struct {
// contains filtered or unexported fields
}
GraphAdapter provides graph operations needed by MCP server
func NewGraphAdapter ¶
func NewGraphAdapter(driver neo4j.DriverWithContext, service graph.Service) *GraphAdapter
NewGraphAdapter creates a new graph adapter
func (*GraphAdapter) ExecuteQuery ¶
func (a *GraphAdapter) ExecuteQuery( ctx context.Context, query string, params map[string]any, ) ([]map[string]any, error)
ExecuteQuery executes a Cypher query directly
func (*GraphAdapter) GetProjectStatistics ¶
func (a *GraphAdapter) GetProjectStatistics(ctx context.Context, projectID core.ID) (*graph.ProjectStatistics, error)
GetProjectStatistics delegates to the underlying service
type MCPServer ¶
type MCPServer interface {
AddTool(tool any)
AddResource(resource any)
Connect(ctx context.Context, transport any) error
}
MCPServer defines the interface for the MCP server
type ResourceResponse ¶
type ResourceResponse struct {
Content []any `json:"content"`
}
ResourceResponse represents a response from a resource
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the MCP server
func NewServer ¶
func NewServer( config *mcpconfig.Config, serviceAdapter ServiceAdapter, llmService llm.CypherTranslator, contextGenerator llm.ContextGenerator, queryBuilder *query.HighLevelBuilder, ) *Server
NewServer creates a new MCP server instance
func (*Server) AddFunctionRelationships ¶
func (s *Server) AddFunctionRelationships( ctx context.Context, result map[string]any, params map[string]any, includeCalls, includeCallers bool, )
AddFunctionRelationships adds calls and callers to function result
func (*Server) AnalyzeFunctionNaming ¶
AnalyzeFunctionNaming analyzes function naming patterns
func (*Server) AnalyzeInterfaceNaming ¶
AnalyzeInterfaceNaming analyzes interface naming patterns
func (*Server) AnalyzeNamingConventions ¶
AnalyzeNamingConventions analyzes naming patterns in the codebase
func (*Server) AnalyzeTestCoverage ¶
func (s *Server) AnalyzeTestCoverage(ctx context.Context, projectID, path string) TestCoverage
AnalyzeTestCoverage analyzes test coverage for a given path
func (*Server) AnalyzeTypeNaming ¶
AnalyzeTypeNaming analyzes struct/type naming patterns
func (*Server) BuildElementLocationQuery ¶
BuildElementLocationQuery builds a query to find an element's location
func (*Server) DetectCommonPatterns ¶
DetectCommonPatterns detects common Go programming patterns
func (*Server) DetectErrorPattern ¶
DetectErrorPattern detects error handling patterns
func (*Server) DetectFactoryPattern ¶
DetectFactoryPattern detects factory function patterns
func (*Server) DetectInterfacePattern ¶
DetectInterfacePattern detects interface implementation patterns
func (*Server) ExtractCodeContextFromResults ¶
func (s *Server) ExtractCodeContextFromResults( results []map[string]any, projectID, elementType, name string, contextLines int, ) (*ToolResponse, error)
ExtractCodeContextFromResults processes query results and extracts code context
func (*Server) FindTestsForElement ¶
func (s *Server) FindTestsForElement( ctx context.Context, projectID, _, name, _ string, ) []map[string]any
FindTestsForElement finds test functions that might test a specific element
func (*Server) HandleAnalyzeProjectInternal ¶
func (s *Server) HandleAnalyzeProjectInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
HandleAnalyzeProjectInternal analyzes a Go project and stores results in Neo4j
func (*Server) HandleCheckTestCoverageInternal ¶
func (s *Server) HandleCheckTestCoverageInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleCheckTestCoverage checks test coverage
func (*Server) HandleCodePatternsResource ¶
handleCodePatternsResource provides code patterns
func (*Server) HandleDetectCircularDepsInternal ¶
func (s *Server) HandleDetectCircularDepsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleDetectCircularDeps detects circular dependencies
func (*Server) HandleDetectCodePatternsInternal ¶
func (s *Server) HandleDetectCodePatternsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleDetectCodePatterns detects code patterns
func (*Server) HandleExecuteCypherInternal ¶
func (s *Server) HandleExecuteCypherInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
HandleExecuteCypherInternal executes a custom Cypher query
func (*Server) HandleFindImplementationsInternal ¶
func (s *Server) HandleFindImplementationsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleFindImplementations finds all implementations of an interface
func (*Server) HandleFindTestsForCodeInternal ¶
func (s *Server) HandleFindTestsForCodeInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleFindTestsForCode finds tests for code elements
func (*Server) HandleGetCodeContextInternal ¶
func (s *Server) HandleGetCodeContextInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleGetCodeContext gets context around a code element
func (*Server) HandleGetFunctionInfoInternal ¶
func (s *Server) HandleGetFunctionInfoInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
HandleGetFunctionInfoInternal gets detailed information about a function
func (*Server) HandleGetNamingConventionsInternal ¶
func (s *Server) HandleGetNamingConventionsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleGetNamingConventions analyzes naming conventions
func (*Server) HandleGetPackageStructureInternal ¶
func (s *Server) HandleGetPackageStructureInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleGetPackageStructure gets detailed structure of a package
func (*Server) HandleListPackagesInternal ¶
func (s *Server) HandleListPackagesInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleListPackages lists all packages in the project
func (*Server) HandleListProjectsInternal ¶ added in v0.0.3
func (s *Server) HandleListProjectsInternal(ctx context.Context, _ map[string]any) (*ToolResponse, error)
HandleListProjectsInternal lists all projects in the database
func (*Server) HandleNaturalLanguageQueryInternal ¶
func (s *Server) HandleNaturalLanguageQueryInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleNaturalLanguageQuery converts natural language to Cypher and executes
func (*Server) HandleProjectInvariantsResource ¶
func (s *Server) HandleProjectInvariantsResource(_ context.Context, params map[string]string) ([]byte, error)
handleProjectInvariantsResource provides project invariants
func (*Server) HandleProjectMetadataResource ¶
func (s *Server) HandleProjectMetadataResource(ctx context.Context, params map[string]string) ([]byte, error)
handleProjectMetadataResource provides project metadata
func (*Server) HandleQueryDependenciesInternal ¶
func (s *Server) HandleQueryDependenciesInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleQueryDependencies finds dependencies for a package or function
func (*Server) HandleQueryTemplatesResource ¶
func (s *Server) HandleQueryTemplatesResource(_ context.Context, _ map[string]string) ([]byte, error)
handleQueryTemplatesResource provides query templates
func (*Server) HandleTraceCallChainInternal ¶
func (s *Server) HandleTraceCallChainInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleTraceCallChain traces call chains between functions
func (*Server) HandleValidateImportPathInternal ¶
func (s *Server) HandleValidateImportPathInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleValidateImportPath validates an import path
func (*Server) HandleValidateProjectInternal ¶ added in v0.0.3
func (s *Server) HandleValidateProjectInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
HandleValidateProjectInternal validates if a project exists in the database
func (*Server) HandleVerifyCodeExistsInternal ¶
func (s *Server) HandleVerifyCodeExistsInternal(ctx context.Context, input map[string]any) (*ToolResponse, error)
handleVerifyCodeExists verifies if a code element exists
func (*Server) IsCamelCase ¶
IsCamelCase checks if a string is in camelCase
func (*Server) IsPascalCase ¶
IsPascalCase checks if a string is in PascalCase
func (*Server) IsPathAllowed ¶
func (*Server) IsStandardLibraryPackage ¶
IsStandardLibraryPackage checks if an import path is a Go standard library package
func (*Server) ParseCodeContextInput ¶
func (s *Server) ParseCodeContextInput( input map[string]any, ) (projectID, elementType, name string, contextLines int, err error)
codeContextParams holds parameters for code context requests ParseCodeContextInput parses and validates input for code context requests
func (*Server) ReadFileContext ¶
ReadFileContext reads lines around a specific line number in a file
type ServiceAdapter ¶
type ServiceAdapter interface {
// Parse operations
ParseProject(ctx context.Context, projectPath string) (*parser.ParseResult, error)
// Analyze operations
AnalyzeProject(ctx context.Context, projectID core.ID, files []*parser.FileInfo) (*analyzer.AnalysisReport, error)
// Graph operations
InitializeProject(ctx context.Context, project *core.Project) error
BuildAnalysisResult(
ctx context.Context,
projectID core.ID,
parseResult *parser.ParseResult,
analysisReport *analyzer.AnalysisReport,
) (*core.AnalysisResult, error)
ImportAnalysisResult(ctx context.Context, result *core.AnalysisResult) (*graph.ProjectGraph, error)
GetProjectStatistics(ctx context.Context, projectID core.ID) (*graph.ProjectStatistics, error)
ExecuteQuery(ctx context.Context, query string, params map[string]any) ([]map[string]any, error)
// Project management operations
ListProjects(ctx context.Context) ([]core.Project, error)
ValidateProject(ctx context.Context, projectID core.ID) (bool, error)
ClearProject(ctx context.Context, projectID core.ID) error
}
ServiceAdapter provides a unified interface for MCP operations
func NewServiceAdapter ¶
func NewServiceAdapter( driver neo4j.DriverWithContext, graphService graph.Service, parserService parser.Parser, analyzerService analyzer.Analyzer, ) ServiceAdapter
NewServiceAdapter creates a new service adapter
type TestCoverage ¶
type TestCoverage struct {
Percentage float64 `json:"percentage"`
CoveredLines int `json:"covered_lines"`
TotalLines int `json:"total_lines"`
TestFiles []map[string]any `json:"test_files"`
}
TestCoverage represents test coverage information
type ToolResponse ¶
type ToolResponse struct {
Content []any `json:"content"`
}
ToolResponse represents a response from a tool