mirror of
https://github.com/syntrex-lab/gomcp.git
synced 2026-04-29 14:26:22 +02:00
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
// Copyright 2026 Syntrex Lab. All rights reserved.
|
|
// Use of this source code is governed by an Apache-2.0 license
|
|
// that can be found in the LICENSE file.
|
|
|
|
package tools
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/syntrex-lab/gomcp/internal/domain/crystal"
|
|
)
|
|
|
|
// CrystalService implements MCP tool logic for code crystal operations.
|
|
type CrystalService struct {
|
|
store crystal.CrystalStore
|
|
}
|
|
|
|
// NewCrystalService creates a new CrystalService.
|
|
func NewCrystalService(store crystal.CrystalStore) *CrystalService {
|
|
return &CrystalService{store: store}
|
|
}
|
|
|
|
// GetCrystal retrieves a crystal by path.
|
|
func (s *CrystalService) GetCrystal(ctx context.Context, path string) (*crystal.Crystal, error) {
|
|
return s.store.Get(ctx, path)
|
|
}
|
|
|
|
// ListCrystals lists crystals matching a path pattern.
|
|
func (s *CrystalService) ListCrystals(ctx context.Context, pattern string, limit int) ([]*crystal.Crystal, error) {
|
|
if limit <= 0 {
|
|
limit = 50
|
|
}
|
|
return s.store.List(ctx, pattern, limit)
|
|
}
|
|
|
|
// SearchCrystals searches crystals by content/primitives.
|
|
func (s *CrystalService) SearchCrystals(ctx context.Context, query string, limit int) ([]*crystal.Crystal, error) {
|
|
if limit <= 0 {
|
|
limit = 20
|
|
}
|
|
return s.store.Search(ctx, query, limit)
|
|
}
|
|
|
|
// GetCrystalStats returns crystal store statistics.
|
|
func (s *CrystalService) GetCrystalStats(ctx context.Context) (*crystal.CrystalStats, error) {
|
|
return s.store.Stats(ctx)
|
|
}
|
|
|
|
// Store returns the underlying CrystalStore for direct access.
|
|
func (s *CrystalService) Store() crystal.CrystalStore {
|
|
return s.store
|
|
}
|