feat(phase10): complete MCP-only architecture migration
Phase 10 "Cleanup & Production Polish" is now complete. All LLM interactions now go through the Model Context Protocol (MCP), removing direct provider dependencies from CLI/TUI. ## Major Changes ### MCP Architecture - All providers (local and cloud Ollama) now use RemoteMcpClient - Removed owlen-ollama dependency from owlen-tui - MCP LLM server accepts OLLAMA_URL environment variable for cloud providers - Proper notification handling for streaming responses - Fixed response deserialization (McpToolResponse unwrapping) ### Code Cleanup - Removed direct OllamaProvider instantiation from TUI - Updated collect_models_from_all_providers() to use MCP for all providers - Updated switch_provider() to use MCP with environment configuration - Removed unused general config variable ### Documentation - Added comprehensive MCP Architecture section to docs/architecture.md - Documented MCP communication flow and cloud provider support - Updated crate breakdown to reflect MCP servers ### Security & Performance - Path traversal protection verified for all resource operations - Process isolation via separate MCP server processes - Tool permissions controlled via consent manager - Clean release build of entire workspace verified ## Benefits of MCP Architecture 1. **Separation of Concerns**: TUI/CLI never directly instantiates providers 2. **Process Isolation**: LLM interactions run in separate processes 3. **Extensibility**: New providers can be added as MCP servers 4. **Multi-Transport**: Supports STDIO, HTTP, and WebSocket 5. **Tool Integration**: MCP servers expose tools to LLMs This completes Phase 10 and establishes a clean, production-ready architecture for future development. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -31,10 +31,54 @@ A simplified diagram of how components interact:
|
||||
|
||||
## Crate Breakdown
|
||||
|
||||
- `owlen-core`: Defines the core traits and data structures, like `Provider` and `Session`.
|
||||
- `owlen-core`: Defines the core traits and data structures, like `Provider` and `Session`. Also contains the MCP client implementation.
|
||||
- `owlen-tui`: Contains all the logic for the terminal user interface, including event handling and rendering.
|
||||
- `owlen-cli`: The command-line entry point, responsible for parsing arguments and starting the TUI.
|
||||
- `owlen-ollama` / `owlen-openai` / etc.: Implementations of the `Provider` trait for specific services.
|
||||
- `owlen-mcp-llm-server`: MCP server that wraps Ollama providers and exposes them via the Model Context Protocol.
|
||||
- `owlen-mcp-server`: Generic MCP server for file operations and resource management.
|
||||
- `owlen-ollama`: Direct Ollama provider implementation (legacy, used only by MCP servers).
|
||||
|
||||
## MCP Architecture (Phase 10)
|
||||
|
||||
As of Phase 10, OWLEN uses a **MCP-only architecture** where all LLM interactions go through the Model Context Protocol:
|
||||
|
||||
```
|
||||
[TUI/CLI] -> [RemoteMcpClient] -> [MCP LLM Server] -> [Ollama Provider] -> [Ollama API]
|
||||
```
|
||||
|
||||
### Benefits of MCP Architecture
|
||||
|
||||
1. **Separation of Concerns**: The TUI/CLI never directly instantiates provider implementations.
|
||||
2. **Process Isolation**: LLM interactions run in a separate process, improving stability.
|
||||
3. **Extensibility**: New providers can be added by implementing MCP servers.
|
||||
4. **Multi-Transport**: Supports STDIO, HTTP, and WebSocket transports.
|
||||
5. **Tool Integration**: MCP servers can expose tools (file operations, web search, etc.) to the LLM.
|
||||
|
||||
### MCP Communication Flow
|
||||
|
||||
1. **Client Creation**: `RemoteMcpClient::new()` spawns an MCP server binary via STDIO.
|
||||
2. **Initialization**: Client sends `initialize` request to establish protocol version.
|
||||
3. **Tool Discovery**: Client calls `tools/list` to discover available LLM operations.
|
||||
4. **Chat Requests**: Client calls the `generate_text` tool with chat parameters.
|
||||
5. **Streaming**: Server sends progress notifications during generation, then final response.
|
||||
6. **Response Handling**: Client skips notifications and returns the final text to the caller.
|
||||
|
||||
### Cloud Provider Support
|
||||
|
||||
For Ollama Cloud providers, the MCP server accepts an `OLLAMA_URL` environment variable:
|
||||
|
||||
```rust
|
||||
let env_vars = HashMap::from([
|
||||
("OLLAMA_URL".to_string(), "https://cloud-provider-url".to_string())
|
||||
]);
|
||||
let config = McpServerConfig {
|
||||
command: "path/to/owlen-mcp-llm-server",
|
||||
env: env_vars,
|
||||
transport: "stdio",
|
||||
...
|
||||
};
|
||||
let client = RemoteMcpClient::new_with_config(&config)?;
|
||||
```
|
||||
|
||||
## Session Management
|
||||
|
||||
|
||||
Reference in New Issue
Block a user