initial mcp server setup
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
"""
|
||||
Client Configuration
|
||||
"""
|
||||
from typing import Dict, Any, Optional
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class ClientConfig:
|
||||
"""Configuration class for MCP clients"""
|
||||
|
||||
provider: str = "openai"
|
||||
model: str = "gpt-4o"
|
||||
api_key: Optional[str] = None
|
||||
|
||||
# Model parameters
|
||||
temperature: float = 0.7
|
||||
max_tokens: int = 1000
|
||||
top_p: float = 1.0
|
||||
|
||||
# Connection settings
|
||||
timeout: int = 30
|
||||
max_retries: int = 3
|
||||
retry_delay: float = 1.0
|
||||
|
||||
# MCP-specific settings
|
||||
enable_tool_calling: bool = True
|
||||
enable_resource_access: bool = True
|
||||
enable_prompts: bool = True
|
||||
|
||||
# Transport settings
|
||||
transport_host: str = "localhost"
|
||||
transport_port: int = 8050
|
||||
transport_endpoint: str = "/sse"
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, config_dict: Dict[str, Any]) -> 'ClientConfig':
|
||||
"""Create ClientConfig from dictionary"""
|
||||
return cls(**config_dict)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Convert to dictionary"""
|
||||
return self.__dict__.copy()
|
||||
|
||||
def get_provider_config(self) -> Dict[str, Any]:
|
||||
"""Get provider-specific configuration"""
|
||||
return {
|
||||
"model_name": self.model,
|
||||
"api_key": self.api_key,
|
||||
"temperature": self.temperature,
|
||||
"max_tokens": self.max_tokens,
|
||||
"top_p": self.top_p,
|
||||
"timeout": self.timeout,
|
||||
"max_retries": self.max_retries,
|
||||
"retry_delay": self.retry_delay,
|
||||
}
|
||||
|
||||
def validate(self) -> bool:
|
||||
"""Validate configuration"""
|
||||
if not self.provider:
|
||||
return False
|
||||
if not self.model:
|
||||
return False
|
||||
if not self.api_key:
|
||||
return False
|
||||
if self.temperature < 0 or self.temperature > 2:
|
||||
return False
|
||||
if self.max_tokens < 1:
|
||||
return False
|
||||
return True
|
||||
Reference in New Issue
Block a user