terraphim / terraphim/terraphim-ai

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

Open
#281 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
62
Forks
5
Avg merge
2h 27m
Merged PRs (30d)
1

Description

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 ✅

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

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.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, rust
Domain
api, backend, documentation, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.