terraphim / terraphim/terraphim-ai

Phase 4: Implement Advanced Features (Multi-tenancy & UI)

Aperta
#281 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Rust
Stelle
62
Fork
5
Merge medio
2h 27m
PR unite (30g)
1

Descrizione

Goal

Enterprise features and management UI

Tasks

Backend Implementation ✅ COMPLETE
  • Add user_id to all MCP resources
  • Implement public/private namespace scoping
  • Audit trail for tool invocations
  • Add health endpoint (GET /metamcp/health)
  • Add audit listing endpoint (GET /metamcp/audits)
  • AuditMiddleware for automatic tool call logging
  • REST wrapper for MCP tools
  • OpenAPI spec generation at /metamcp/openapi.json
In Progress / Planned
  • Role-based access control for endpoints (future enhancement)
  • Auto-generate OpenAPI specs from MCP tools (manual for now)
  • Swagger UI integration (OpenAPI JSON available for external viewers)
Frontend (Deferred to Phase 5)
  • Extend Svelte frontend with MCP management views
  • Namespace CRUD operations UI
  • Tool enable/disable toggles
  • Endpoint management dashboard
  • Real-time server status display

Completed Features

Phase 4A - Multi-Tenancy & Compliance

Commit: 6ce6d3ad

Persistence Layer

  • McpAuditRecord for tool invocation tracking
  • NamespaceVisibility enum (Public/Private) with Private default
  • Audit trail methods: save_audit, get_audit, list_audits, delete_audit
  • list_namespaces_with_visibility for multi-tenancy support
  • OpenDAL-based audit storage

Middleware

  • AuditMiddleware for automatic tool call logging
  • Feature-gated with 'audit' feature flag
  • Tracks: tool name, arguments, response, errors, latency

API Layer

  • get_mcp_health endpoint with namespace/endpoint counts
  • list_audits endpoint (limit 100 recent records)
  • Visibility field in CreateNamespaceRequest

Routes

  • GET /metamcp/health - Server health with counts
  • GET /metamcp/audits - Recent audit trail
Phase 4B - REST API Wrapper

Commit: 3d5a1c32

API Module (terraphim_server/src/api_mcp_tools.rs)

  • list_tools_for_endpoint: Lists all tools for an endpoint
  • execute_tool: Executes tool with JSON arguments
  • create_proxy_from_namespace: Initializes McpProxy from config
  • Error handling for missing endpoints/namespaces

Routes

  • GET /metamcp/endpoints/{endpoint_uuid}/tools
  • POST /metamcp/endpoints/{endpoint_uuid}/tools/{tool_name}

Integration

  • Leverages terraphim_mcp_proxy for routing
  • Uses MCP persistence for lookups
  • Supports all transports (STDIO, SSE, HTTP, OAuth)
Phase 4C - OpenAPI Documentation

Commit: 318f113a

API Specification

  • Complete OpenAPI 3.0 spec at GET /metamcp/openapi.json
  • Documented paths, parameters, request/response schemas
  • Ready for Postman/Insomnia/Swagger UI import

Type System

  • McpTool: OpenAPI-compatible tool wrapper
  • McpContentItem: Response content enum
  • ToolListResponse, ToolCallRequestPayload, ToolCallResponsePayload
  • All types implement ToSchema for documentation

Test Coverage

  • Persistence: 6/6 tests passing (audit, visibility)
  • MCP Proxy: 19/19 tests passing
  • MCP Tools API: 7/7 tests passing
  • Total: 32 tests passing ✅

Success Criteria

  • Multi-user support with proper isolation (namespace visibility)
  • Audit trail for compliance
  • REST API for tool execution
  • OpenAPI documentation
  • High test coverage (32 tests)
  • Web UI for managing MCP configuration (deferred to Phase 5)

Usage Examples

# List tools
curl http://localhost:8080/metamcp/endpoints/{uuid}/tools

# Execute tool
curl -X POST http://localhost:8080/metamcp/endpoints/{uuid}/tools/filesystem__read_file \
  -H "Content-Type: application/json" \
  -d '{"arguments": {"path": "/path/to/file"}}'

# Get OpenAPI spec
curl http://localhost:8080/metamcp/openapi.json > mcp-api.json

# Health check
curl http://localhost:8080/metamcp/health

# Audit trail
curl http://localhost:8080/metamcp/audits

Timeline

Week 7-8 (Backend completed ahead of schedule ✅)

Phase 4 COMPLETE - All backend features implemented with full test coverage.

Depends on: Phase 3 ✅

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

This is a completed phase tracker rather than a single scoped task. Start with terraphim_server/src/api_mcp_tools.rs and the listed MCP routes, then inspect the current backend and frontend entry points. The remaining work is broad: role-based access control, automatic OpenAPI generation, Swagger UI, and deferred Svelte management views.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
openapi, rust
Ambito
api, backend, documentation, frontend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
15/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.