Update the MCP configuration, replace the hardcoding value with server_reference in config, and add the MCPSettings class in config.py to support MCP configuration.

This commit is contained in:
zhiyuanren
2025-03-28 10:09:18 +08:00
parent a10b973494
commit e10aa08013
3 changed files with 37 additions and 11 deletions
+22
View File
@@ -90,6 +90,14 @@ class SandboxSettings(BaseModel):
)
class MCPSettings(BaseModel):
"""Configuration for MCP (Model Context Protocol)"""
server_reference: str = Field(
"app.mcp.server", description="Module reference for the MCP server"
)
class AppConfig(BaseModel):
llm: Dict[str, LLMSettings]
sandbox: Optional[SandboxSettings] = Field(
@@ -101,6 +109,7 @@ class AppConfig(BaseModel):
search_config: Optional[SearchSettings] = Field(
None, description="Search configuration"
)
mcp_config: Optional[MCPSettings] = Field(None, description="MCP configuration")
class Config:
arbitrary_types_allowed = True
@@ -203,6 +212,13 @@ class Config:
else:
sandbox_settings = SandboxSettings()
mcp_config = raw_config.get("mcp", {})
mcp_settings = None
if mcp_config:
mcp_settings = MCPSettings(**mcp_config)
else:
mcp_settings = MCPSettings()
config_dict = {
"llm": {
"default": default_settings,
@@ -214,6 +230,7 @@ class Config:
"sandbox": sandbox_settings,
"browser_config": browser_settings,
"search_config": search_settings,
"mcp_config": mcp_settings,
}
self._config = AppConfig(**config_dict)
@@ -234,6 +251,11 @@ class Config:
def search_config(self) -> Optional[SearchSettings]:
return self._config.search_config
@property
def mcp_config(self) -> MCPSettings:
"""Get the MCP configuration"""
return self._config.mcp_config
@property
def workspace_root(self) -> Path:
"""Get the workspace root directory"""
+14 -10
View File
@@ -1,10 +1,10 @@
# Global LLM configuration
[llm]
model = "claude-3-7-sonnet-20250219" # The LLM model to use
base_url = "https://api.anthropic.com/v1/" # API endpoint URL
api_key = "YOUR_API_KEY" # Your API key
max_tokens = 8192 # Maximum number of tokens in the response
temperature = 0.0 # Controls randomness
model = "claude-3-7-sonnet-20250219" # The LLM model to use
base_url = "https://api.anthropic.com/v1/" # API endpoint URL
api_key = "YOUR_API_KEY" # Your API key
max_tokens = 8192 # Maximum number of tokens in the response
temperature = 0.0 # Controls randomness
# [llm] # Amazon Bedrock
# api_type = "aws" # Required
@@ -33,11 +33,11 @@ temperature = 0.0 # Controls randomness
# Optional configuration for specific LLM models
[llm.vision]
model = "claude-3-7-sonnet-20250219" # The vision model to use
base_url = "https://api.anthropic.com/v1/" # API endpoint URL for vision model
api_key = "YOUR_API_KEY" # Your API key for vision model
max_tokens = 8192 # Maximum number of tokens in the response
temperature = 0.0 # Controls randomness for vision model
model = "claude-3-7-sonnet-20250219" # The vision model to use
base_url = "https://api.anthropic.com/v1/" # API endpoint URL for vision model
api_key = "YOUR_API_KEY" # Your API key for vision model
max_tokens = 8192 # Maximum number of tokens in the response
temperature = 0.0 # Controls randomness for vision model
# [llm.vision] #OLLAMA VISION:
# api_type = 'ollama'
@@ -90,3 +90,7 @@ temperature = 0.0 # Controls randomness for vision mod
#cpu_limit = 2.0
#timeout = 300
#network_enabled = true
# MCP (Model Context Protocol) configuration
[mcp]
server_reference = "app.mcp.server" # default server module reference
+1 -1
View File
@@ -13,7 +13,7 @@ class MCPRunner:
def __init__(self):
self.root_path = config.root_path
self.server_reference = "app.mcp.server"
self.server_reference = config.mcp_config.server_reference
self.agent = MCPAgent()
async def initialize(