2026-04-06 18:22:02 +00:00
use crate ::ai ::{ ParameterProperty , Tool , ToolParameters } ;
use std ::collections ::HashMap ;
feat(mcp): add MCP Server Support with TDD implementation
Adds full Model Context Protocol (MCP) server management, enabling the
AI assistant to discover and call tools from external MCP servers during
triage conversations.
Backend (Rust):
- rmcp 1.7.0 dependency (client + stdio + Streamable HTTP transports)
- Migration 018: mcp_servers, mcp_tools, mcp_resources tables with
CHECK constraints for transport_type, auth_type, discovery_status
- src/mcp/ module: models, store, client, adapter, discovery, commands,
transport/{stdio,http}
- AppState gains mcp_connections: Arc<TokioMutex<HashMap<...>>>
- .setup() hook auto-discovers enabled servers at startup
- 8 new Tauri commands wired into invoke_handler
- execute_mcp_tool_call: PII scan + mandatory audit_log before execution
- Auth values encrypted at rest via integrations::auth::encrypt_token();
scrubbed before any frontend response
Frontend:
- MCPServers.tsx settings page (/settings/mcp) with server list,
status badges, Discover Now, Add/Edit modal, enable/disable toggle
- tauriCommands.ts: McpServer, McpTool, McpServerStatus types + 8 cmds
- App.tsx: Plug icon, /settings/mcp route, sidebar nav entry
Tests (TDD): 15 new tests, all green
- 5 migration tests (written before migration, red → green)
- 5 store CRUD + encryption tests
- 5 adapter sanitization + conversion tests
Verification: 185/185 Rust, 94/94 Vitest, clippy -D warnings: 0
2026-05-23 21:23:48 +00:00
/// Get all statically-registered tools for AI function calling.
2026-04-06 18:22:02 +00:00
pub fn get_available_tools ( ) -> Vec < Tool > {
feat: full copy from apollo_nxt-trcaa with complete sanitization
Complete backport of all features from apollo_nxt-trcaa repository:
- Three-tier shell execution safety system (Tier 1: auto, Tier 2: approve, Tier 3: deny)
- Ollama function calling with tool use support
- AI provider tool calling auto-detection
- kubectl binary bundling and management
- kubeconfig upload and context management
- Shell approval modal with real-time UI
- MCP protocol HTTP transport with custom headers
- Enhanced security audit logging
- Comprehensive test coverage (275+ tests)
- Updated CI/CD workflows for Gitea Actions
- Complete documentation (ADRs, wiki, release notes)
Sanitization applied to all files:
- Removed all MSI, Motorola, VNXT, Vesta references
- Replaced internal infrastructure references with TFTSR equivalents
- Updated all URLs and API endpoints
- Sanitized commit history references in documentation
Technical changes:
- New modules: shell/classifier, shell/executor, shell/kubectl, shell/kubeconfig
- Enhanced AI providers: ollama.rs, openai.rs with function calling
- New Tauri commands: shell execution, kubeconfig management, tool calling detection
- Database migrations: shell_execution_audit table
- Frontend: ShellApprovalModal, ShellExecution, KubeconfigManager pages
- CI/CD: kubectl bundling, multi-platform builds, Gitea Actions integration
Version: 1.0.8
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-06-05 19:11:00 +00:00
vec! [ get_add_ado_comment_tool ( ) , get_execute_shell_command_tool ( ) ]
2026-04-06 18:22:02 +00:00
}
feat(mcp): add MCP Server Support with TDD implementation
Adds full Model Context Protocol (MCP) server management, enabling the
AI assistant to discover and call tools from external MCP servers during
triage conversations.
Backend (Rust):
- rmcp 1.7.0 dependency (client + stdio + Streamable HTTP transports)
- Migration 018: mcp_servers, mcp_tools, mcp_resources tables with
CHECK constraints for transport_type, auth_type, discovery_status
- src/mcp/ module: models, store, client, adapter, discovery, commands,
transport/{stdio,http}
- AppState gains mcp_connections: Arc<TokioMutex<HashMap<...>>>
- .setup() hook auto-discovers enabled servers at startup
- 8 new Tauri commands wired into invoke_handler
- execute_mcp_tool_call: PII scan + mandatory audit_log before execution
- Auth values encrypted at rest via integrations::auth::encrypt_token();
scrubbed before any frontend response
Frontend:
- MCPServers.tsx settings page (/settings/mcp) with server list,
status badges, Discover Now, Add/Edit modal, enable/disable toggle
- tauriCommands.ts: McpServer, McpTool, McpServerStatus types + 8 cmds
- App.tsx: Plug icon, /settings/mcp route, sidebar nav entry
Tests (TDD): 15 new tests, all green
- 5 migration tests (written before migration, red → green)
- 5 store CRUD + encryption tests
- 5 adapter sanitization + conversion tests
Verification: 185/185 Rust, 94/94 Vitest, clippy -D warnings: 0
2026-05-23 21:23:48 +00:00
/// Fetch tools from all connected, enabled MCP servers.
pub async fn get_enabled_mcp_tools ( state : & crate ::state ::AppState ) -> Vec < Tool > {
crate ::mcp ::adapter ::get_enabled_mcp_tools ( state )
. await
. unwrap_or_default ( )
}
2026-04-06 18:22:02 +00:00
/// Tool definition for adding comments to Azure DevOps work items
fn get_add_ado_comment_tool ( ) -> Tool {
let mut properties = HashMap ::new ( ) ;
properties . insert (
" work_item_id " . to_string ( ) ,
ParameterProperty {
prop_type : " integer " . to_string ( ) ,
description : " The Azure DevOps work item ID (ticket number) to add the comment to "
. to_string ( ) ,
enum_values : None ,
} ,
) ;
properties . insert (
" comment_text " . to_string ( ) ,
ParameterProperty {
prop_type : " string " . to_string ( ) ,
description : " The text content of the comment to add to the work item " . to_string ( ) ,
enum_values : None ,
} ,
) ;
Tool {
name : " add_ado_comment " . to_string ( ) ,
description : " Add a comment to an Azure DevOps work item (ticket). Use this when the user asks you to add a comment, update a ticket, or provide information to a ticket. " . to_string ( ) ,
parameters : ToolParameters {
param_type : " object " . to_string ( ) ,
properties ,
required : vec ! [ " work_item_id " . to_string ( ) , " comment_text " . to_string ( ) ] ,
} ,
}
}
feat: full copy from apollo_nxt-trcaa with complete sanitization
Complete backport of all features from apollo_nxt-trcaa repository:
- Three-tier shell execution safety system (Tier 1: auto, Tier 2: approve, Tier 3: deny)
- Ollama function calling with tool use support
- AI provider tool calling auto-detection
- kubectl binary bundling and management
- kubeconfig upload and context management
- Shell approval modal with real-time UI
- MCP protocol HTTP transport with custom headers
- Enhanced security audit logging
- Comprehensive test coverage (275+ tests)
- Updated CI/CD workflows for Gitea Actions
- Complete documentation (ADRs, wiki, release notes)
Sanitization applied to all files:
- Removed all MSI, Motorola, VNXT, Vesta references
- Replaced internal infrastructure references with TFTSR equivalents
- Updated all URLs and API endpoints
- Sanitized commit history references in documentation
Technical changes:
- New modules: shell/classifier, shell/executor, shell/kubectl, shell/kubeconfig
- Enhanced AI providers: ollama.rs, openai.rs with function calling
- New Tauri commands: shell execution, kubeconfig management, tool calling detection
- Database migrations: shell_execution_audit table
- Frontend: ShellApprovalModal, ShellExecution, KubeconfigManager pages
- CI/CD: kubectl bundling, multi-platform builds, Gitea Actions integration
Version: 1.0.8
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-06-05 19:11:00 +00:00
/// Tool definition for executing shell commands with safety classification
fn get_execute_shell_command_tool ( ) -> Tool {
let mut properties = HashMap ::new ( ) ;
properties . insert (
" command " . to_string ( ) ,
ParameterProperty {
prop_type : " string " . to_string ( ) ,
description : " Shell command to execute. Supports kubectl, pvesh, qm, and general shell commands. Read-only commands execute automatically. Mutating commands require user approval. " . to_string ( ) ,
enum_values : None ,
} ,
) ;
properties . insert (
" working_directory " . to_string ( ) ,
ParameterProperty {
prop_type : " string " . to_string ( ) ,
description : " Optional working directory for command execution " . to_string ( ) ,
enum_values : None ,
} ,
) ;
properties . insert (
" kubeconfig_id " . to_string ( ) ,
ParameterProperty {
prop_type : " string " . to_string ( ) ,
description : " Optional kubeconfig file ID for kubectl commands " . to_string ( ) ,
enum_values : None ,
} ,
) ;
Tool {
name : " execute_shell_command " . to_string ( ) ,
description : " Execute shell commands with automatic safety classification. Tier 1 (read-only): kubectl get/describe/logs, cat, grep, ls - execute automatically. Tier 2 (mutating): kubectl apply/delete/scale, chmod, systemctl restart - require user approval. Tier 3 (destructive): rm -rf, shutdown, mkfs - always denied. " . to_string ( ) ,
parameters : ToolParameters {
param_type : " object " . to_string ( ) ,
properties ,
required : vec ! [ " command " . to_string ( ) ] ,
} ,
}
}