DeepSeek TUI MCP Protocol Features Supported: Complete Technical Reference
DeepSeek TUI implements a production-ready MCP (Model Context Protocol) client that exposes the full MCP specification—including tool invocation, resource reading, and prompt execution—through both STDIO and HTTP/SSE transports, automatically surfacing external server capabilities as native tools using the mcp__<server>__<tool> naming convention.
DeepSeek TUI is a Rust-based terminal user interface that bridges DeepSeek language models with external tool ecosystems via the Model Context Protocol. The codebase delivers a complete MCP client implementation split across two architectural layers: a JSON-RPC 2.0 server runtime in crates/mcp/src/lib.rs and an async connection manager in crates/tui/src/mcp.rs, enabling seamless discovery and execution of remote capabilities.
Core MCP Architecture
The STDIO Server Implementation
Located in crates/mcp/src/lib.rs, the MCP stdio server provides the JSON-RPC 2.0 foundation for process-based communication. The run_stdio_server function handles incoming requests for registration, tool listing, and execution, while McpManager::register_server persists server configurations alongside optional ToolFilter allow/deny lists for capability filtering.
The Async Client Runtime
The TUI-side runtime in crates/tui/src/mcp.rs manages the McpConnection pool and configuration parsing. It reads ~/.deepseek/mcp.json (or the path specified by mcp_config_path) into McpConfig structs, then initializes connections via McpConnection::connect_with_policy. This supports both STDIO transport (spawning local server binaries) and HTTP/SSE transport (connecting to remote endpoints), with the latter gated by the NetworkPolicyDecider to prevent SSRF attacks.
Supported MCP Capabilities
Server Lifecycle Management
Servers configured with enabled: true are started automatically through McpManager::start_all. The implementation exposes server/start and server/stop JSON-RPC methods for dynamic control. Graceful shutdown is handled by StdioTransport::shutdown, which sends SIGTERM and waits a grace period before forcefully terminating the child process.
Tool Discovery and Invocation
Once connected, McpConnection::discover_tools sends a tools/list request and caches the returned McpTool structs. These are filtered through configured ToolFilter rules (allow/deny lists) before exposure to the LLM. The qualify_tool_name function applies the naming convention mcp__<server>__<tool> (e.g., mcp_deepseek_shell). Invocation routes through McpPool::call_tool, which parses the prefixed identifier and dispatches to the underlying tools/call JSON-RPC endpoint.
Resource and Prompt Access
Resources are discovered via McpConnection::discover_resources and discover_resource_templates, corresponding to resources/list and resources/templates/list MCP methods. Reading resources uses McpConnection::read_resource (exposed as mcp_read_resource or read_mcp_resource aliases), while prompt execution uses McpConnection::get_prompt via the prompts/get method. The TUI automatically injects pseudo-tools list_mcp_resources and list_mcp_resource_templates into the model's tool catalog to enable runtime enumeration.
Configuration Schema
The McpConfig and McpServerConfig structs in crates/tui/src/mcp.rs define per-server timeouts (connect_timeout, execute_timeout, read_timeout), transport selection, enable/disable flags, and capability filtering rules. Global configuration is loaded from ~/.deepseek/mcp.json or overridden via the main TUI configuration file.
Security and Error Handling
HTTP/SSE connections are validated against the global NetworkPolicyDecider defined in crates/tui/src/network_policy.rs. Error handling sanitizes sensitive information through mask_url_secrets and redact_body_preview functions before logging, ensuring credentials in URLs or response bodies are not exposed in logs or UI outputs.
Implementation Examples
The following example demonstrates initializing the MCP connection pool and enumerating available tools:
use deepseek_tui::mcp::McpPool;
use std::path::Path;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Load configuration from the default path (~/.deepseek/mcp.json)
let pool = McpPool::from_config_path(Path::new("/home/user/.deepseek/mcp.json"))?;
// Connect to all enabled servers
let errors = pool.connect_all().await;
if !errors.is_empty() {
eprintln!("Some MCP servers failed: {:?}", errors);
}
// Turn the discovered MCP tools into the API tool list
let api_tools = pool.to_api_tools();
for tool in api_tools {
println!("Tool: {} – {}", tool.name, tool.description);
}
Ok(())
}
To invoke a remote MCP tool programmatically:
let mut pool = McpPool::new(config);
let result = pool.call_tool("mcp_deepseek_shell", serde_json::json!({
"command": "git status"
})).await?;
println!("Shell output: {}", result);
The CLI workflow for bootstrapping and managing MCP servers:
# Bootstrap a self-hosted DeepSeek MCP server
deepseek-tui mcp add-self # writes a stdio entry that runs `deepseek-tui serve --mcp`
deepseek-tui mcp list # shows the configured server
deepseek-tui mcp validate # checks the server starts correctly
# Inside the TUI, invoke the tool
/run mcp_deepseek_shell {"command":"ls -l"} # runs `ls -l` on the server side
Summary
- Complete MCP client implementation in Rust covering JSON-RPC 2.0 server and async client runtime
- Dual transport support for both STDIO (local binaries) and HTTP/SSE (remote servers) with SSRF protection via
NetworkPolicyDecider - Unified tool namespace using the
mcp__<server>__<tool>convention (e.g.,mcp_deepseek_shell) for seamless LLM integration - Granular capability filtering through
ToolFilterallow/deny lists and per-server enable/disable flags - Automatic lifecycle management including
McpManager::start_all, graceful shutdown viaStdioTransport::shutdown, and configuration validation - Built-in enumeration tools (
list_mcp_resources,list_mcp_resource_templates) exposing MCP assets to the model - Security-hardened error handling with automatic secret redaction in URLs and response bodies
Frequently Asked Questions
What transports does DeepSeek TUI support for MCP connections?
DeepSeek TUI supports both STDIO and HTTP/SSE transports. STDIO spawns the MCP server as a local child process, while HTTP/SSE connects to remote endpoints. All HTTP/SSE connections are validated through the NetworkPolicyDecider to prevent SSRF vulnerabilities before establishing the connection via McpConnection::connect_with_policy.
How are MCP tools exposed to the DeepSeek language model?
MCP tools are automatically qualified using the naming pattern mcp__<server>__<tool> (implemented in the qualify_tool_name function) and exposed through McpPool::to_api_tools. This allows the LLM to invoke external tools using the same mechanism as built-in tools, with names like mcp_deepseek_shell. The TUI also injects convenience tools such as list_mcp_resources to let the model discover available assets at runtime.
Where is MCP configuration stored and what format does it use?
Configuration is stored in ~/.deepseek/mcp.json by default, though this path can be overridden via mcp_config_path in the main TUI configuration. The file is parsed into McpConfig structs supporting per-server settings for timeouts (connect_timeout, execute_timeout, read_timeout), transport type, enable/disable flags, and ToolFilter definitions for capability filtering.
Does DeepSeek TUI support filtering which MCP tools are available to the model?
Yes. The implementation supports granular filtering through the ToolFilter struct, which can define explicit allow or deny lists for tool names. These filters are applied during the discovery phase in McpConnection::discover_tools, ensuring only permitted tools are cached and exposed to the LLM via the qualified naming convention.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →