mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
first commit
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
// Package server provides MCP server implementation.
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Config holds server configuration.
|
||||
type Config struct {
|
||||
Mode string `yaml:"mode"`
|
||||
Transport string `yaml:"transport"`
|
||||
Host string `yaml:"host"`
|
||||
Port int `yaml:"port"`
|
||||
}
|
||||
|
||||
// Server defines the MCP server interface.
|
||||
type Server interface {
|
||||
// Start begins listening for connections.
|
||||
Start(ctx context.Context) error
|
||||
|
||||
// Stop gracefully shuts down the server.
|
||||
Stop(ctx context.Context) error
|
||||
}
|
||||
|
||||
// QueryRequest represents a search query.
|
||||
type QueryRequest struct {
|
||||
Query string `json:"query"`
|
||||
Limit int `json:"limit,omitempty"`
|
||||
Threshold float64 `json:"threshold,omitempty"`
|
||||
}
|
||||
|
||||
// QueryResponse represents search results.
|
||||
type QueryResponse struct {
|
||||
Query string `json:"query"`
|
||||
Results []Result `json:"results"`
|
||||
Total int `json:"total"`
|
||||
TookMs int64 `json:"took_ms"`
|
||||
}
|
||||
|
||||
// Result represents a single search result.
|
||||
type Result struct {
|
||||
ID string `json:"id"`
|
||||
DocumentID string `json:"document_id"`
|
||||
Content string `json:"content"`
|
||||
Score float64 `json:"score"`
|
||||
Source string `json:"source"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// NewServer creates a new MCP server.
|
||||
func NewServer(config *Config) Server {
|
||||
if config.Mode == "remote" {
|
||||
return NewHTTPServer(config)
|
||||
}
|
||||
return NewStdioServer(config)
|
||||
}
|
||||
|
||||
// NewHTTPServer creates an HTTP-based MCP server.
|
||||
func NewHTTPServer(config *Config) *HTTPServer {
|
||||
return &HTTPServer{config: config}
|
||||
}
|
||||
|
||||
// NewStdioServer creates a stdio-based MCP server.
|
||||
func NewStdioServer(config *Config) *StdioServer {
|
||||
return &StdioServer{config: config}
|
||||
}
|
||||
|
||||
// HTTPServer implements Server for HTTP transport.
|
||||
type HTTPServer struct {
|
||||
config *Config
|
||||
}
|
||||
|
||||
func (s *HTTPServer) Start(ctx context.Context) error {
|
||||
// TODO: Implement HTTP server with MCP endpoints
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *HTTPServer) Stop(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// StdioServer implements Server for stdio transport.
|
||||
type StdioServer struct {
|
||||
config *Config
|
||||
}
|
||||
|
||||
func (s *StdioServer) Start(ctx context.Context) error {
|
||||
// TODO: Implement stdio JSON-RPC server
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *StdioServer) Stop(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user