Implementation of a basic search tool
diff --git a/tools/search.go b/tools/search.go
new file mode 100644
index 0000000..c11caa9
--- /dev/null
+++ b/tools/search.go
@@ -0,0 +1,93 @@
+package tools
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/korap/korap-mcp/service"
+ "github.com/mark3labs/mcp-go/mcp"
+ "github.com/rs/zerolog/log"
+)
+
+// SearchTool implements the Tool interface for KorAP corpus search
+type SearchTool struct {
+ client *service.Client
+}
+
+// NewSearchTool creates a new search tool instance
+func NewSearchTool(client *service.Client) *SearchTool {
+ return &SearchTool{
+ client: client,
+ }
+}
+
+// Name returns the tool name
+func (s *SearchTool) Name() string {
+ return "korap_search"
+}
+
+// Description returns the tool description
+func (s *SearchTool) Description() string {
+ return "Search for words or phrases in KorAP corpora using various query languages"
+}
+
+// InputSchema returns the JSON schema for tool parameters
+func (s *SearchTool) InputSchema() map[string]interface{} {
+ return map[string]interface{}{
+ "type": "object",
+ "properties": map[string]interface{}{
+ "query": map[string]interface{}{
+ "type": "string",
+ "description": "The search query (word, phrase, or pattern)",
+ },
+ "query_language": map[string]interface{}{
+ "type": "string",
+ "description": "Query language: 'poliqarp' (default), 'cosmas2', or 'annis'",
+ "enum": []string{"poliqarp", "cosmas2", "annis"},
+ "default": "poliqarp",
+ },
+ "corpus": map[string]interface{}{
+ "type": "string",
+ "description": "Virtual corpus to search in",
+ },
+ "count": map[string]interface{}{
+ "type": "integer",
+ "description": "Number of results to return (max 100)",
+ "minimum": 1,
+ "maximum": 100,
+ "default": 25,
+ },
+ },
+ "required": []string{"query"},
+ }
+}
+
+// Execute performs the search operation
+func (s *SearchTool) Execute(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
+ log.Debug().
+ Str("tool", s.Name()).
+ Msg("Executing search tool")
+
+ // Extract required query parameter using the same pattern as main.go
+ query, err := request.RequireString("query")
+ if err != nil {
+ return nil, fmt.Errorf("query parameter is required: %w", err)
+ }
+
+ log.Debug().
+ Str("query", query).
+ Msg("Parsed search parameters")
+
+ // For now, return a simple response to verify the tool works
+ // TODO: Implement actual KorAP search functionality
+ result := "KorAP Search Results\n"
+ result += "====================\n\n"
+ result += fmt.Sprintf("Query: %s\n", query)
+ result += "Status: Tool is working, KorAP integration to be implemented\n"
+
+ log.Info().
+ Str("query", query).
+ Msg("Search tool executed successfully")
+
+ return mcp.NewToolResultText(result), nil
+}