feat: Add MCP integration to enable tools from skills.sh and other MCP servers

- Added MCP client to discover and convert MCP tools to LangChain Tools
- Extended configuration manager to support MCP server configurations
- Updated CLI to manage MCP server configurations (list, add, remove, use)
- Integrated MCP tools into the agent's tool loading system
- Added documentation for MCP integration design
This commit is contained in:
opencode committed 2026-03-21 19:01:58 +01:00
1 parent 55a31278a8
commit 753c7d491e
5 files changed
+380 -11

No files matched your search

+37 -2
View File
@@ -42,6 +42,13 @@ def print_configurations(configs=None, title="LangCode Agent Configurations"):
print(f" API Key: {'Set' if config.get('api_key') else 'Not set'}")
base_url = config.get("base_url", "https://openrouter.ai/api/v1")
print(f" Base URL: {base_url}")
elif provider == "mcp":
server_url = config.get("server_url", "Not set")
print(f" Server URL: {server_url}")
api_key_status = 'Set' if config.get('api_key') else 'Not set'
print(f" API Key: {api_key_status}")
timeout = config.get("timeout", 30)
print(f" Timeout: {timeout}s")
print()
@@ -101,12 +108,14 @@ def add_configuration_interactive():
print("1. OpenAI")
print("2. Ollama")
print("3. OpenRouter")
print("4. MCP (Model Context Protocol)")
provider_choice = input("Enter choice (1-3): ").strip()
provider_choice = input("Enter choice (1-4): ").strip()
provider_map = {
"1": "openai",
"2": "ollama",
"3": "openrouter"
"3": "openrouter",
"4": "mcp"
}
if provider_choice not in provider_map:
@@ -146,6 +155,32 @@ def add_configuration_interactive():
if not base_url:
base_url = "https://openrouter.ai/api/v1"
config["base_url"] = base_url
elif provider == "mcp":
server_url = input("MCP server URL (e.g., https://skills.sh/mcp): ").strip()
if not server_url:
print("Error: Server URL is required for MCP")
return
config["server_url"] = server_url
api_key = input("MCP API key (optional, press Enter to skip): ").strip()
if api_key:
config["api_key"] = api_key
timeout_input = input(f"MCP request timeout in seconds (default: 30): ").strip()
if timeout_input:
try:
timeout = int(timeout_input)
if timeout <= 0:
print("Warning: Timeout must be positive, using default 30")
config["timeout"] = "30"
else:
config["timeout"] = str(timeout)
except ValueError:
print("Warning: Invalid timeout value, using default 30")
config["timeout"] = "30"
else:
config["timeout"] = "30"
# Ask if this should be the active configuration
set_active = input("Set as active configuration? (y/N): ").strip().lower()