feat: implement v2 3-tier architecture (mcpctl → mcplocal → mcpd)
- Rename local-proxy to mcplocal with HTTP server, LLM pipeline, mcpd discovery - Add LLM pre-processing: token estimation, filter cache, metrics, Gemini CLI + DeepSeek providers - Add mcpd auth (login/logout) and MCP proxy endpoints - Update CLI: dual URLs (mcplocalUrl/mcpdUrl), auth commands, --direct flag - Add tiered health monitoring, shell completions, e2e integration tests - 57 test files, 597 tests passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
272
.taskmaster/docs/prd-v2-architecture.md
Normal file
272
.taskmaster/docs/prd-v2-architecture.md
Normal file
@@ -0,0 +1,272 @@
|
||||
# mcpctl v2 - Corrected 3-Tier Architecture PRD
|
||||
|
||||
## Overview
|
||||
|
||||
mcpctl is a kubectl-inspired system for managing MCP (Model Context Protocol) servers. It consists of 4 components arranged in a 3-tier architecture:
|
||||
|
||||
```
|
||||
Claude Code
|
||||
|
|
||||
v (stdio - MCP protocol)
|
||||
mcplocal (Local Daemon - runs on developer machine)
|
||||
|
|
||||
v (HTTP REST)
|
||||
mcpd (External Daemon - runs on server/NAS)
|
||||
|
|
||||
v (Docker API / K8s API)
|
||||
mcp_servers (MCP server containers)
|
||||
```
|
||||
|
||||
## Components
|
||||
|
||||
### 1. mcpctl (CLI Tool)
|
||||
- **Package**: `src/cli/` (`@mcpctl/cli`)
|
||||
- **What it is**: kubectl-like CLI for managing the entire system
|
||||
- **Talks to**: mcplocal (local daemon) via HTTP REST
|
||||
- **Key point**: mcpctl does NOT talk to mcpd directly. It always goes through mcplocal.
|
||||
- **Distributed as**: RPM package via Gitea registry (bun compile + nfpm)
|
||||
- **Commands**: get, describe, apply, setup, instance, claude, project, backup, restore, config, status
|
||||
|
||||
### 2. mcplocal (Local Daemon)
|
||||
- **Package**: `src/local-proxy/` (rename to `src/mcplocal/`)
|
||||
- **What it is**: Local daemon running on the developer's machine
|
||||
- **Talks to**: mcpd (external daemon) via HTTP REST
|
||||
- **Exposes to Claude**: MCP protocol via stdio (tools, resources, prompts)
|
||||
- **Exposes to mcpctl**: HTTP REST API for management commands
|
||||
|
||||
**Core responsibility: LLM Pre-processing**
|
||||
|
||||
This is the intelligence layer. When Claude asks for data from MCP servers, mcplocal:
|
||||
|
||||
1. Receives Claude's request (e.g., "get Slack messages about security")
|
||||
2. Uses a local/cheap LLM (Gemini CLI binary, Ollama, vLLM, DeepSeek API) to interpret what Claude actually wants
|
||||
3. Sends narrow, filtered requests to mcpd which forwards to the actual MCP servers
|
||||
4. Receives raw results from MCP servers (via mcpd)
|
||||
5. Uses the local LLM again to filter/summarize results - extracting only what's relevant
|
||||
6. Returns the smallest, most comprehensive response to Claude
|
||||
|
||||
**Why**: Claude Code tokens are expensive. Instead of dumping 500 Slack messages into Claude's context window, mcplocal uses a cheap LLM to pre-filter to the 12 relevant ones.
|
||||
|
||||
**LLM Provider Strategy** (already partially exists):
|
||||
- Gemini CLI binary (local, free)
|
||||
- Ollama (local, free)
|
||||
- vLLM (local, free)
|
||||
- DeepSeek API (cheap)
|
||||
- OpenAI API (fallback)
|
||||
- Anthropic API (fallback)
|
||||
|
||||
**Additional mcplocal responsibilities**:
|
||||
- MCP protocol routing (namespace tools: `slack/send_message`, `jira/create_issue`)
|
||||
- Connection health monitoring for upstream MCP servers
|
||||
- Caching frequently requested data
|
||||
- Proxying mcpctl management commands to mcpd
|
||||
|
||||
### 3. mcpd (External Daemon)
|
||||
- **Package**: `src/mcpd/` (`@mcpctl/mcpd`)
|
||||
- **What it is**: Server-side daemon that runs on centralized infrastructure (Synology NAS, cloud server, etc.)
|
||||
- **Deployed via**: Docker Compose (Dockerfile + docker-compose.yml)
|
||||
- **Database**: PostgreSQL for state, audit logs, access control
|
||||
|
||||
**Core responsibilities**:
|
||||
- **Deploy and run MCP server containers** (Docker now, Kubernetes later)
|
||||
- **Instance lifecycle management**: start, stop, restart, logs, inspect
|
||||
- **MCP server registry**: Store server definitions, configuration templates, profiles
|
||||
- **Project management**: Group MCP profiles into projects for Claude sessions
|
||||
- **Auditing**: Log every operation - who ran what, when, with what result
|
||||
- **Access management**: Users, sessions, permissions - who can access which MCP servers
|
||||
- **Credential storage**: MCP servers often need API tokens (Slack, Jira, GitHub) - stored securely on server side, never exposed to local machine
|
||||
- **Backup/restore**: Export and import configuration
|
||||
|
||||
**Key point**: mcpd holds the credentials. When mcplocal asks mcpd to query Slack, mcpd runs the Slack MCP server container with the proper SLACK_TOKEN injected - mcplocal never sees the token.
|
||||
|
||||
### 4. mcp_servers (MCP Server Containers)
|
||||
- **What they are**: The actual MCP server processes (Slack, Jira, GitHub, Terraform, filesystem, postgres, etc.)
|
||||
- **Managed by**: mcpd via Docker/Podman API
|
||||
- **Network**: Isolated network, only accessible by mcpd
|
||||
- **Credentials**: Injected by mcpd as environment variables
|
||||
- **Communication**: MCP protocol (stdio or SSE/HTTP) between mcpd and the containers
|
||||
|
||||
## Data Flow Examples
|
||||
|
||||
### Example 1: Claude asks for Slack messages
|
||||
```
|
||||
Claude: "Get messages about security incidents from the last week"
|
||||
|
|
||||
v (MCP tools/call: slack/search_messages)
|
||||
mcplocal:
|
||||
1. Intercepts the tool call
|
||||
2. Calls local Gemini: "User wants security incident messages from last week.
|
||||
Generate optimal Slack search query and date filters."
|
||||
3. Gemini returns: query="security incident OR vulnerability OR CVE", after="2024-01-15"
|
||||
4. Sends filtered request to mcpd
|
||||
|
|
||||
v (HTTP POST /api/v1/mcp/proxy)
|
||||
mcpd:
|
||||
1. Looks up Slack MCP instance (injects SLACK_TOKEN)
|
||||
2. Forwards narrowed query to Slack MCP server container
|
||||
3. Returns raw results (200 messages)
|
||||
|
|
||||
v (response)
|
||||
mcplocal:
|
||||
1. Receives 200 messages
|
||||
2. Calls local Gemini: "Filter these 200 Slack messages. Keep only those
|
||||
directly about security incidents. Return message IDs and 1-line summaries."
|
||||
3. Gemini returns: 15 relevant messages with summaries
|
||||
4. Returns filtered result to Claude
|
||||
|
|
||||
v (MCP response: 15 messages instead of 200)
|
||||
Claude: processes only the relevant 15 messages
|
||||
```
|
||||
|
||||
### Example 2: mcpctl management command
|
||||
```
|
||||
$ mcpctl get servers
|
||||
|
|
||||
v (HTTP GET)
|
||||
mcplocal:
|
||||
1. Recognizes this is a management command (not MCP data)
|
||||
2. Proxies directly to mcpd (no LLM processing needed)
|
||||
|
|
||||
v (HTTP GET /api/v1/servers)
|
||||
mcpd:
|
||||
1. Queries PostgreSQL for server definitions
|
||||
2. Returns list
|
||||
|
|
||||
v (proxied response)
|
||||
mcplocal -> mcpctl -> formatted table output
|
||||
```
|
||||
|
||||
### Example 3: mcpctl instance management
|
||||
```
|
||||
$ mcpctl instance start slack
|
||||
|
|
||||
v
|
||||
mcplocal -> mcpd:
|
||||
1. Creates Docker container for Slack MCP server
|
||||
2. Injects SLACK_TOKEN from secure storage
|
||||
3. Connects to isolated mcp-servers network
|
||||
4. Logs audit entry: "user X started slack instance"
|
||||
5. Returns instance status
|
||||
```
|
||||
|
||||
## What Already Exists (completed work)
|
||||
|
||||
### Done and reusable as-is:
|
||||
- Project structure: pnpm monorepo, TypeScript strict mode, Vitest, ESLint
|
||||
- Database schema: Prisma + PostgreSQL (User, McpServer, McpProfile, Project, McpInstance, AuditLog)
|
||||
- mcpd server framework: Fastify 5, routes, services, repositories, middleware
|
||||
- mcpd MCP server CRUD: registration, profiles, projects
|
||||
- mcpd Docker container management: dockerode, instance lifecycle
|
||||
- mcpd audit logging, health monitoring, metrics, backup/restore
|
||||
- mcpctl CLI framework: Commander.js, commands, config, API client, formatters
|
||||
- mcpctl RPM distribution: bun compile, nfpm, Gitea publishing, shell completions
|
||||
- MCP protocol routing in local-proxy: namespace tools, resources, prompts
|
||||
- LLM provider abstractions: OpenAI, Anthropic, Ollama adapters (defined but unused)
|
||||
- Shared types and profile templates
|
||||
|
||||
### Needs rework:
|
||||
- mcpctl currently talks to mcpd directly -> must talk to mcplocal instead
|
||||
- local-proxy is just a dumb router -> needs LLM pre-processing intelligence
|
||||
- local-proxy has no HTTP API for mcpctl -> needs REST endpoints for management proxying
|
||||
- mcpd has no MCP proxy endpoint -> needs endpoint that mcplocal can call to execute MCP tool calls on managed instances
|
||||
- No integration between LLM providers and MCP request/response pipeline
|
||||
|
||||
## New Tasks Needed
|
||||
|
||||
### Phase 1: Rename and restructure local-proxy -> mcplocal
|
||||
- Rename `src/local-proxy/` to `src/mcplocal/`
|
||||
- Update all package references and imports
|
||||
- Add HTTP REST server (Fastify) alongside existing stdio server
|
||||
- mcplocal needs TWO interfaces: stdio for Claude, HTTP for mcpctl
|
||||
|
||||
### Phase 2: mcplocal management proxy
|
||||
- Add REST endpoints that mirror mcpd's API (get servers, instances, projects, etc.)
|
||||
- mcpctl config changes: `daemonUrl` now points to mcplocal (e.g., localhost:3200) instead of mcpd
|
||||
- mcplocal proxies management requests to mcpd (configurable `mcpdUrl` e.g., http://nas:3100)
|
||||
- Pass-through with no LLM processing for management commands
|
||||
|
||||
### Phase 3: mcpd MCP proxy endpoint
|
||||
- Add `/api/v1/mcp/proxy` endpoint to mcpd
|
||||
- Accepts: `{ serverId, method, params }` - execute an MCP tool call on a managed instance
|
||||
- mcpd looks up the instance, connects to the container, executes the MCP call, returns result
|
||||
- This is how mcplocal talks to MCP servers without needing direct Docker access
|
||||
|
||||
### Phase 4: LLM pre-processing pipeline in mcplocal
|
||||
- Create request interceptor in mcplocal's MCP router
|
||||
- Before forwarding `tools/call` to mcpd, run the request through LLM for interpretation
|
||||
- After receiving response from mcpd, run through LLM for filtering/summarization
|
||||
- LLM provider selection based on config (prefer local/cheap models)
|
||||
- Configurable: enable/disable pre-processing per server or per tool
|
||||
- Bypass for simple operations (list, create, delete - no filtering needed)
|
||||
|
||||
### Phase 5: Smart context optimization
|
||||
- Token counting: estimate how many tokens the raw response would consume
|
||||
- Decision logic: if raw response < threshold, skip LLM filtering (not worth the latency)
|
||||
- If raw response > threshold, filter with LLM
|
||||
- Cache LLM filtering decisions for repeated similar queries
|
||||
- Metrics: track tokens saved, latency added by filtering
|
||||
|
||||
### Phase 6: mcpctl -> mcplocal migration
|
||||
- Update mcpctl's default daemonUrl to point to mcplocal (localhost:3200)
|
||||
- Update all CLI commands to work through mcplocal proxy
|
||||
- Add `mcpctl config set mcpd-url <url>` for configuring upstream mcpd
|
||||
- Add `mcpctl config set mcplocal-url <url>` for configuring local daemon
|
||||
- Health check: `mcpctl status` shows both mcplocal and mcpd connectivity
|
||||
- Shell completions update if needed
|
||||
|
||||
### Phase 7: End-to-end integration testing
|
||||
- Test full flow: mcpctl -> mcplocal -> mcpd -> mcp_server -> response -> LLM filter -> Claude
|
||||
- Test management commands pass through correctly
|
||||
- Test LLM pre-processing reduces context window size
|
||||
- Test credential isolation (mcplocal never sees MCP server credentials)
|
||||
- Test health monitoring across all tiers
|
||||
|
||||
## Authentication & Authorization
|
||||
|
||||
### Database ownership
|
||||
- **mcpd owns the database** (PostgreSQL). It is the only component that talks to the DB.
|
||||
- mcplocal has NO database. It is stateless (config file only).
|
||||
- mcpctl has NO database. It stores user credentials locally in `~/.mcpctl/config.yaml`.
|
||||
|
||||
### Auth flow
|
||||
```
|
||||
mcpctl login
|
||||
|
|
||||
v (user enters mcpd URL + credentials)
|
||||
mcpctl stores API token in ~/.mcpctl/config.yaml
|
||||
|
|
||||
v (passes token to mcplocal config)
|
||||
mcplocal authenticates to mcpd using Bearer token on every request
|
||||
|
|
||||
v (Authorization: Bearer <token>)
|
||||
mcpd validates token against Session table in PostgreSQL
|
||||
|
|
||||
v (authenticated request proceeds)
|
||||
```
|
||||
|
||||
### mcpctl responsibilities
|
||||
- `mcpctl login` command: prompts user for mcpd URL and credentials (username/password or API token)
|
||||
- `mcpctl login` calls mcpd's auth endpoint to get a session token
|
||||
- Stores the token in `~/.mcpctl/config.yaml` (or `~/.mcpctl/credentials` with restricted permissions)
|
||||
- Passes the token to mcplocal (either via config or as startup argument)
|
||||
- `mcpctl logout` command: invalidates the session token
|
||||
|
||||
### mcplocal responsibilities
|
||||
- Reads auth token from its config (set by mcpctl)
|
||||
- Attaches `Authorization: Bearer <token>` header to ALL requests to mcpd
|
||||
- If mcpd returns 401, mcplocal returns appropriate error to mcpctl/Claude
|
||||
- Does NOT store credentials itself - they come from mcpctl's config
|
||||
|
||||
### mcpd responsibilities
|
||||
- Owns User and Session tables
|
||||
- Provides auth endpoints: `POST /api/v1/auth/login`, `POST /api/v1/auth/logout`
|
||||
- Validates Bearer tokens on every request via auth middleware (already exists)
|
||||
- Returns 401 for invalid/expired tokens
|
||||
- Audit logs include the authenticated user
|
||||
|
||||
## Non-functional Requirements
|
||||
- mcplocal must start fast (developer's machine, runs per-session or as daemon)
|
||||
- LLM pre-processing must not add more than 2-3 seconds latency
|
||||
- If local LLM is unavailable, fall back to passing data through unfiltered
|
||||
- All components must be independently deployable and testable
|
||||
- mcpd must remain stateless (outside of DB) and horizontally scalable
|
||||
@@ -531,8 +531,9 @@
|
||||
"7",
|
||||
"4"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T05:14:48.368Z"
|
||||
},
|
||||
{
|
||||
"id": "10",
|
||||
@@ -545,8 +546,9 @@
|
||||
"7",
|
||||
"5"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T05:17:02.390Z"
|
||||
},
|
||||
{
|
||||
"id": "11",
|
||||
@@ -558,9 +560,9 @@
|
||||
"dependencies": [
|
||||
"1"
|
||||
],
|
||||
"status": "in-progress",
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T04:56:01.658Z"
|
||||
"updatedAt": "2026-02-21T05:00:28.388Z"
|
||||
},
|
||||
{
|
||||
"id": "12",
|
||||
@@ -572,8 +574,74 @@
|
||||
"dependencies": [
|
||||
"11"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Create main.ts entry point with configuration loading",
|
||||
"description": "Implement the main.ts entry point that reads proxy configuration from file or CLI arguments, initializes upstreams based on config, and boots the StdioProxyServer.",
|
||||
"dependencies": [],
|
||||
"details": "Create src/local-proxy/src/main.ts that: 1) Parses command-line arguments (--config flag for JSON config path, or individual --upstream flags), 2) Loads ProxyConfig from JSON file if specified, 3) Instantiates StdioUpstream or HttpUpstream for each UpstreamConfig based on transport type, 4) Calls start() on each StdioUpstream to spawn child processes, 5) Adds all upstreams to McpRouter via addUpstream(), 6) Creates StdioProxyServer with the router and calls start(), 7) Handles SIGTERM/SIGINT for graceful shutdown calling router.closeAll(). Use a simple arg parser or process.argv directly. Export a main() function and call it when run directly.",
|
||||
"status": "done",
|
||||
"testStrategy": "Test config file loading with valid/invalid JSON. Test CLI argument parsing. Integration test: spawn proxy with mock upstream config and verify it starts and responds to initialize request.",
|
||||
"parentId": "undefined",
|
||||
"updatedAt": "2026-02-21T05:05:48.624Z"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Add resource forwarding support to McpRouter",
|
||||
"description": "Extend McpRouter to handle resources/list and resources/read methods, forwarding them to upstream servers with proper namespacing similar to tools.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Modify src/local-proxy/src/router.ts to: 1) Add a resourceToServer Map similar to toolToServer, 2) Create discoverResources() method that calls resources/list on each upstream and aggregates results with namespaced URIs (e.g., 'servername://resource'), 3) Add 'resources' to capabilities in initialize response, 4) Handle 'resources/list' in route() by calling discoverResources(), 5) Handle 'resources/read' by parsing the namespaced URI, extracting server name, stripping prefix, and forwarding to correct upstream, 6) Handle 'resources/subscribe' and 'resources/unsubscribe' if needed for completeness. Update types.ts if additional resource-related types are needed.",
|
||||
"status": "done",
|
||||
"testStrategy": "Unit test discoverResources() with mocked upstreams returning different resources. Test resources/read routing extracts correct server and forwards properly. Test error handling when resource URI has unknown server prefix.",
|
||||
"parentId": "undefined",
|
||||
"updatedAt": "2026-02-21T05:05:48.626Z"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Add prompt forwarding support to McpRouter",
|
||||
"description": "Extend McpRouter to handle prompts/list and prompts/get methods, forwarding them to upstream servers with proper namespacing.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Modify src/local-proxy/src/router.ts to: 1) Add a promptToServer Map for tracking prompt origins, 2) Create discoverPrompts() method that calls prompts/list on each upstream and aggregates with namespaced names (e.g., 'servername/prompt-name'), 3) Add 'prompts' to capabilities in initialize response, 4) Handle 'prompts/list' in route() by calling discoverPrompts(), 5) Handle 'prompts/get' by parsing namespaced prompt name, extracting server, stripping prefix, and forwarding to correct upstream. Follow same pattern as tools for consistency.",
|
||||
"status": "done",
|
||||
"testStrategy": "Unit test discoverPrompts() with mocked upstreams. Test prompts/get routing correctly forwards to upstream. Test error handling for unknown prompt names.",
|
||||
"parentId": "undefined",
|
||||
"updatedAt": "2026-02-21T05:05:48.638Z"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Implement notification forwarding from upstreams to client",
|
||||
"description": "Add support for forwarding JSON-RPC notifications from upstream servers to the proxy client, enabling real-time updates like progress notifications.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Modify upstream classes and server: 1) Add onNotification callback to UpstreamConnection interface in types.ts, 2) Update StdioUpstream to detect notifications (messages without 'id' field) in stdout handler and invoke onNotification callback with namespaced method if needed, 3) Update HttpUpstream if SSE support is needed (may require EventSource or SSE client for true streaming), 4) Add setNotificationHandler(callback) method to McpRouter that registers handler and wires it to all upstreams, 5) Update StdioProxyServer to call router.setNotificationHandler() with a function that writes notification JSON to stdout, 6) Consider namespacing notification params to indicate source server.",
|
||||
"status": "done",
|
||||
"testStrategy": "Test StdioUpstream correctly identifies and forwards notifications. Integration test: upstream sends progress notification, verify proxy forwards it to stdout. Test notifications are properly namespaced with source server name.",
|
||||
"parentId": "undefined",
|
||||
"updatedAt": "2026-02-21T05:05:48.641Z"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Implement connection health monitoring with reconnection",
|
||||
"description": "Add health monitoring for upstream connections with automatic status tracking, health check pings, and reconnection logic for failed STDIO upstreams.",
|
||||
"dependencies": [
|
||||
1,
|
||||
4
|
||||
],
|
||||
"details": "Create src/local-proxy/src/health.ts with HealthMonitor class: 1) Track connection state for each upstream (healthy, degraded, disconnected), 2) Implement periodic health checks using ping/pong or a lightweight method like calling initialize, 3) Emit health status change events via EventEmitter pattern, 4) Add reconnection logic for StdioUpstream: detect process exit, attempt restart with exponential backoff (1s, 2s, 4s... max 30s), 5) Update McpRouter to accept HealthMonitor instance and use it to filter available upstreams, 6) Add health status to proxy logs/stderr for debugging, 7) Optionally expose health status via a special proxy method (e.g., 'proxy/health'). Update main.ts to instantiate and wire HealthMonitor.",
|
||||
"status": "done",
|
||||
"testStrategy": "Test health check detects unresponsive upstream. Test reconnection attempts with mocked process that fails then succeeds. Test exponential backoff timing. Test degraded upstream is excluded from tool discovery until healthy.",
|
||||
"parentId": "undefined",
|
||||
"updatedAt": "2026-02-21T05:05:48.643Z"
|
||||
}
|
||||
],
|
||||
"updatedAt": "2026-02-21T05:05:48.643Z"
|
||||
},
|
||||
{
|
||||
"id": "13",
|
||||
@@ -585,8 +653,9 @@
|
||||
"dependencies": [
|
||||
"12"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T05:22:44.011Z"
|
||||
},
|
||||
{
|
||||
"id": "14",
|
||||
@@ -598,8 +667,9 @@
|
||||
"dependencies": [
|
||||
"3"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T05:09:18.694Z"
|
||||
},
|
||||
{
|
||||
"id": "15",
|
||||
@@ -611,8 +681,71 @@
|
||||
"dependencies": [
|
||||
"4"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Define Profile Template Types and Schemas",
|
||||
"description": "Create TypeScript interfaces and Zod validation schemas for profile templates that extend the existing McpProfile type.",
|
||||
"dependencies": [],
|
||||
"details": "Create src/shared/src/profiles/types.ts with ProfileTemplate interface containing: id, serverType, name, displayName, description, category (filesystem/database/integration/etc), command, args, requiredEnvVars (with EnvTemplateEntry array), optionalEnvVars, defaultPermissions, setupInstructions, and documentationUrl. Also create profileTemplateSchema.ts with Zod schemas for validation. The templates should be immutable definitions that can be instantiated into actual profiles.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit test Zod schemas with valid and invalid template data. Verify type compatibility with existing McpServerConfig and McpProfile types.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Implement Common MCP Server Profile Templates",
|
||||
"description": "Create profile template definitions for common MCP servers including filesystem, github, postgres, slack, and other popular integrations.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Create src/shared/src/profiles/templates/ directory with individual template files: filesystem.ts (npx @modelcontextprotocol/server-filesystem with path args), github.ts (npx @modelcontextprotocol/server-github with GITHUB_TOKEN env), postgres.ts (npx @modelcontextprotocol/server-postgres with DATABASE_URL), slack.ts (npx @modelcontextprotocol/server-slack with SLACK_TOKEN), memory.ts, and fetch.ts. Each template exports a ProfileTemplate constant with pre-configured best-practice settings. Include clear descriptions and setup guides for each.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Validate each template against the ProfileTemplate Zod schema. Verify all required fields are populated. Test that commands and args are syntactically correct.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Build Profile Registry with Lookup and Filtering",
|
||||
"description": "Create a profile registry that aggregates all templates and provides lookup, filtering, and search capabilities.",
|
||||
"dependencies": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"details": "Create src/shared/src/profiles/registry.ts implementing a ProfileRegistry class with methods: getAll(), getById(id), getByCategory(category), getByServerType(type), search(query), and getCategories(). The registry should be a singleton that lazily loads all templates from the templates directory. Export a default registry instance. Also create src/shared/src/profiles/index.ts to export all profile-related types, templates, and the registry.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test registry initialization loads all templates. Test each lookup method returns correct results. Test search functionality with partial matches. Verify no duplicate IDs across templates.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Add Profile Validation and Instantiation Utilities",
|
||||
"description": "Create utility functions to validate profile templates and instantiate them into concrete profile configurations.",
|
||||
"dependencies": [
|
||||
1,
|
||||
3
|
||||
],
|
||||
"details": "Create src/shared/src/profiles/utils.ts with functions: validateTemplate(template) - validates a ProfileTemplate against schema, instantiateProfile(templateId, envValues) - creates a concrete profile config from a template by filling in env vars, validateEnvValues(template, envValues) - checks if all required env vars are provided, getMissingEnvVars(template, envValues) - returns list of missing required env vars, and generateMcpJsonEntry(profile) - converts instantiated profile to .mcp.json format entry.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test validateTemplate with valid and invalid templates. Test instantiateProfile produces correct configs. Test env validation catches missing required vars. Test .mcp.json output matches expected format.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Export Profiles Module and Add Integration Tests",
|
||||
"description": "Export the profiles module from shared package main entry and create comprehensive integration tests.",
|
||||
"dependencies": [
|
||||
3,
|
||||
4
|
||||
],
|
||||
"details": "Update src/shared/src/index.ts to add 'export * from ./profiles/index.js'. Create src/shared/src/profiles/__tests__/profiles.test.ts with tests covering: all templates are valid, registry contains expected templates, instantiation works for each template type, .mcp.json generation produces valid output, and round-trip validation (instantiate then validate). Also add documentation comments to all exported functions and types.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Run full test suite with vitest. Verify exports are accessible from @mcpctl/shared. Integration test the full workflow: lookup template, validate, instantiate with env vars, generate .mcp.json entry.",
|
||||
"parentId": "undefined"
|
||||
}
|
||||
],
|
||||
"updatedAt": "2026-02-21T05:26:02.010Z"
|
||||
},
|
||||
{
|
||||
"id": "16",
|
||||
@@ -624,8 +757,9 @@
|
||||
"dependencies": [
|
||||
"6"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T05:11:52.795Z"
|
||||
},
|
||||
{
|
||||
"id": "17",
|
||||
@@ -637,8 +771,70 @@
|
||||
"dependencies": [
|
||||
"6"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Create K8s API HTTP client and connection handling",
|
||||
"description": "Implement a Kubernetes API client using node:http/https to communicate with the K8s API server, including authentication, TLS handling, and base request/response utilities.",
|
||||
"dependencies": [],
|
||||
"details": "Create src/mcpd/src/services/k8s/k8s-client.ts with: 1) K8sClientConfig interface supporting kubeconfig file parsing, in-cluster config detection, and direct API server URL/token config. 2) HTTP client wrapper using node:http/https that handles TLS certificates, bearer token auth, and API versioning. 3) Base request methods (get, post, delete, patch) with proper error handling and response parsing. 4) Support for watching resources with streaming responses. Reference the Docker container-manager.ts pattern for constructor options and ping() implementation.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit tests with mocked HTTP responses for successful API calls, auth failures, connection errors. Test kubeconfig parsing with sample config files. Test in-cluster config detection by mocking environment variables and service account token file.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Implement K8s manifest generation for MCP servers",
|
||||
"description": "Create manifest generator that converts ContainerSpec to Kubernetes Pod and Deployment YAML/JSON specifications with proper resource limits and security contexts.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Create src/mcpd/src/services/k8s/manifest-generator.ts with: 1) generatePodSpec(spec: ContainerSpec, namespace: string) that creates a Pod manifest with container image, env vars, resource limits (CPU/memory from spec.nanoCpus and spec.memoryLimit), and labels including mcpctl.managed=true. 2) generateDeploymentSpec() for replicated deployments with selector labels. 3) generateServiceSpec() for exposing container ports. 4) Security context configuration (non-root user, read-only root filesystem, drop capabilities). 5) Map ContainerSpec fields to K8s equivalents (memoryLimit to resources.limits.memory, nanoCpus to resources.limits.cpu, etc.).",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit tests validating generated manifests match expected K8s spec structure. Test resource limit conversion (bytes to Ki/Mi/Gi, nanoCPUs to millicores). Test label propagation from ContainerSpec.labels. Validate manifests against K8s API schema if possible.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Implement KubernetesOrchestrator class with McpOrchestrator interface",
|
||||
"description": "Create the main KubernetesOrchestrator class that implements the McpOrchestrator interface using the K8s client and manifest generator.",
|
||||
"dependencies": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"details": "Create src/mcpd/src/services/k8s/kubernetes-orchestrator.ts implementing McpOrchestrator interface: 1) Constructor accepting K8sClientConfig and default namespace. 2) ping() - call /api/v1 endpoint to verify cluster connectivity. 3) pullImage() - no-op for K8s (images pulled on pod schedule) or optionally create a pre-pull DaemonSet. 4) createContainer(spec) - generate Pod/Deployment manifest, POST to K8s API, wait for pod Ready condition, return ContainerInfo with pod name as containerId. 5) stopContainer(containerId) - scale deployment to 0 or delete pod. 6) removeContainer(containerId) - DELETE the pod/deployment resource. 7) inspectContainer(containerId) - GET pod status, map phase to ContainerInfo state (Running→running, Pending→starting, Failed→error, etc.). 8) getContainerLogs(containerId) - GET /api/v1/namespaces/{ns}/pods/{name}/log endpoint.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Integration tests with mocked K8s API responses for each method. Test createContainer returns valid ContainerInfo with mapped state. Test state mapping from K8s pod phases. Test log retrieval with tail and since parameters. Test error handling when pod not found or API errors.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Add namespace and multi-namespace support",
|
||||
"description": "Extend KubernetesOrchestrator to support configurable namespaces, namespace creation, and querying resources across namespaces.",
|
||||
"dependencies": [
|
||||
3
|
||||
],
|
||||
"details": "Enhance src/mcpd/src/services/k8s/kubernetes-orchestrator.ts with: 1) Add namespace parameter to ContainerSpec or use labels to specify target namespace. 2) ensureNamespace(name) method that creates namespace if not exists (POST /api/v1/namespaces). 3) listContainers(namespace?: string) method to list all mcpctl-managed pods in a namespace or all namespaces. 4) Add namespace to ContainerInfo response. 5) Support 'default' namespace fallback and configurable default namespace in constructor. 6) Add namespace label to generated manifests for filtering. 7) Validate namespace names (DNS-1123 label format).",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test namespace creation with mocked API. Test namespace validation for invalid names. Test listing pods across namespaces. Test ContainerInfo includes correct namespace. Test default namespace fallback behavior.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Add comprehensive tests and module exports",
|
||||
"description": "Create unit tests with mocked K8s API responses, integration test utilities, and export the KubernetesOrchestrator from the services module.",
|
||||
"dependencies": [
|
||||
3,
|
||||
4
|
||||
],
|
||||
"details": "1) Create src/mcpd/src/services/k8s/index.ts exporting KubernetesOrchestrator, K8sClientConfig, and helper types. 2) Update src/mcpd/src/services/index.ts to export k8s module. 3) Create src/mcpd/src/services/k8s/__tests__/kubernetes-orchestrator.test.ts with mocked HTTP responses using vitest's mock system. 4) Create mock-k8s-api.ts helper that simulates K8s API responses (pod list, pod status, logs, errors). 5) Test all McpOrchestrator interface methods with success and error cases. 6) Add tests for resource limit edge cases (0 memory, very high CPU). 7) Document usage examples in code comments showing how to switch from DockerContainerManager to KubernetesOrchestrator.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Ensure all tests pass with mocked responses. Verify test coverage for all public methods. Test error scenarios (404 pod not found, 403 forbidden, 500 server error). Optional: Add integration test script that runs against kind/minikube if available.",
|
||||
"parentId": "undefined"
|
||||
}
|
||||
],
|
||||
"updatedAt": "2026-02-21T05:30:53.921Z"
|
||||
},
|
||||
{
|
||||
"id": "18",
|
||||
@@ -653,8 +849,9 @@
|
||||
"9",
|
||||
"10"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T05:19:02.525Z"
|
||||
},
|
||||
{
|
||||
"id": "19",
|
||||
@@ -662,7 +859,7 @@
|
||||
"description": "Merged into Task 3 subtasks",
|
||||
"details": null,
|
||||
"testStrategy": null,
|
||||
"priority": null,
|
||||
"priority": "low",
|
||||
"dependencies": [],
|
||||
"status": "cancelled",
|
||||
"subtasks": [],
|
||||
@@ -674,7 +871,7 @@
|
||||
"description": "Merged into Task 5",
|
||||
"details": null,
|
||||
"testStrategy": null,
|
||||
"priority": null,
|
||||
"priority": "low",
|
||||
"dependencies": [],
|
||||
"status": "cancelled",
|
||||
"subtasks": [],
|
||||
@@ -686,7 +883,7 @@
|
||||
"description": "Merged into Task 14",
|
||||
"details": null,
|
||||
"testStrategy": null,
|
||||
"priority": null,
|
||||
"priority": "low",
|
||||
"dependencies": [],
|
||||
"status": "cancelled",
|
||||
"subtasks": [],
|
||||
@@ -703,8 +900,72 @@
|
||||
"6",
|
||||
"14"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Create MetricsCollector Service",
|
||||
"description": "Implement a MetricsCollector service in src/mcpd/src/services/metrics-collector.ts that tracks instance health metrics, uptime, request counts, error rates, and resource usage data.",
|
||||
"dependencies": [],
|
||||
"details": "Create MetricsCollector class with methods: recordRequest(), recordError(), updateInstanceMetrics(), getMetrics(). Store metrics in-memory using Map<instanceId, InstanceMetrics>. Define InstanceMetrics interface with fields: instanceId, status, uptime, requestCount, errorCount, lastRequestAt, memoryUsage, cpuUsage. Inject IMcpInstanceRepository and McpOrchestrator dependencies to gather real-time instance status from containers. Export service from src/mcpd/src/services/index.ts.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit tests with mocked repository and orchestrator dependencies. Test metric recording, aggregation, and retrieval. Verify error rate calculations and uptime tracking accuracy.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Implement Health Aggregation Service",
|
||||
"description": "Create a HealthAggregator service that computes overall system health by aggregating health status across all MCP server instances.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Add HealthAggregator class in src/mcpd/src/services/health-aggregator.ts. Methods: getOverview() returns SystemHealth with totalInstances, healthyCount, unhealthyCount, errorCount, and overallStatus (healthy/degraded/unhealthy). Use MetricsCollector to gather per-instance metrics. Include orchestrator.ping() check for runtime availability. Compute aggregate error rate and average uptime. Export from services/index.ts.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit tests with mocked MetricsCollector. Test aggregation logic for various instance states. Verify overall status determination rules (e.g., >50% unhealthy = degraded).",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Create Health Monitoring REST Endpoints",
|
||||
"description": "Implement REST endpoints for health monitoring: GET /api/v1/health/overview, GET /api/v1/health/instances/:id, and GET /api/v1/metrics in src/mcpd/src/routes/health-monitoring.ts.",
|
||||
"dependencies": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"details": "Create registerHealthMonitoringRoutes(app, deps) function. GET /api/v1/health/overview returns SystemHealth from HealthAggregator.getOverview(). GET /api/v1/health/instances/:id returns InstanceMetrics for specific instance from MetricsCollector. GET /api/v1/metrics returns all metrics in Prometheus-compatible format or JSON. Add proper error handling for 404 when instance not found. Register routes in src/mcpd/src/routes/index.ts and wire up in server.ts.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Integration tests using Fastify inject(). Test all three endpoints with mocked services. Verify 200 responses with correct payload structure, 404 for missing instances.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Add Request/Error Metrics Middleware",
|
||||
"description": "Create middleware in src/mcpd/src/middleware/metrics.ts that intercepts requests to record metrics for request counts and error rates per instance.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Implement Fastify preHandler hook that extracts instance ID from request params/query where applicable. Record request start time. Use onResponse hook to record completion and calculate latency. Use onError hook to record errors with MetricsCollector.recordError(). Track metrics per-route and per-instance. Register middleware in src/mcpd/src/middleware/index.ts. Apply to instance-related routes (/api/v1/instances/*) to track per-instance metrics.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit tests verifying hooks call MetricsCollector methods. Integration tests confirming request/error counts increment correctly after API calls.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Write Comprehensive Health Monitoring Tests",
|
||||
"description": "Create test suite in src/mcpd/tests/health-monitoring.test.ts covering MetricsCollector, HealthAggregator, health monitoring routes, and metrics middleware.",
|
||||
"dependencies": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4
|
||||
],
|
||||
"details": "Write tests for: MetricsCollector - test recordRequest(), recordError(), getMetrics(), concurrent access safety. HealthAggregator - test getOverview() with various instance states, edge cases (no instances, all unhealthy). Routes - test /api/v1/health/overview, /api/v1/health/instances/:id, /api/v1/metrics endpoints with mocked dependencies. Middleware - test request counting, error tracking, latency recording. Use vi.mock() for dependencies following existing test patterns in the codebase.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Self-referential - this subtask IS the test implementation. Verify all tests pass with `npm test`. Aim for >80% coverage on new health monitoring code.",
|
||||
"parentId": "undefined"
|
||||
}
|
||||
],
|
||||
"updatedAt": "2026-02-21T05:34:25.289Z"
|
||||
},
|
||||
{
|
||||
"id": "23",
|
||||
@@ -717,8 +978,71 @@
|
||||
"2",
|
||||
"5"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Implement BackupService for JSON export",
|
||||
"description": "Create BackupService in src/mcpd/src/services/backup/ that exports servers, profiles, and projects from repositories to a structured JSON bundle.",
|
||||
"dependencies": [],
|
||||
"details": "Create BackupService class that uses IMcpServerRepository, IMcpProfileRepository, and IProjectRepository to fetch all data. Define a BackupBundle interface with metadata (version, timestamp, mcpctlVersion), servers array, profiles array, and projects array. Implement createBackup() method that aggregates all data into the bundle format. Add optional filtering by resource type (e.g., only servers, or only specific profiles). Export via services/index.ts following existing patterns.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit test BackupService with mocked repositories. Verify bundle structure includes all expected fields. Test filtering options. Test handling of empty repositories.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Add secrets encryption using Node crypto",
|
||||
"description": "Implement AES-256-GCM encryption for sensitive data in backup bundles using password-derived keys via scrypt.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Create crypto utility module in src/mcpd/src/services/backup/crypto.ts using Node's built-in crypto module. Implement deriveKey() using scrypt with configurable salt length and key length. Implement encrypt() that creates IV, encrypts data with AES-256-GCM, and returns base64-encoded result with IV and auth tag prepended. Implement decrypt() that reverses the process. In BackupService, detect fields containing secrets (env vars with sensitive patterns like *_KEY, *_SECRET, *_TOKEN, PASSWORD) and encrypt them. Store encryption metadata (algorithm, salt) in bundle header.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test encryption/decryption round-trip with various data sizes. Verify wrong password fails decryption. Test key derivation produces consistent results with same inputs. Test detection of sensitive field patterns.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Implement RestoreService for JSON import",
|
||||
"description": "Create RestoreService that imports a backup bundle back into the system, handling decryption and conflict resolution.",
|
||||
"dependencies": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"details": "Create RestoreService class in src/mcpd/src/services/backup/. Implement restore() method that parses JSON bundle, validates version compatibility, decrypts encrypted fields using provided password, and imports data using repositories. Support conflict resolution strategies: 'skip' (ignore existing), 'overwrite' (replace existing), 'fail' (abort on conflict). Implement validateBundle() for schema validation before import. Handle partial failures with transaction-like rollback or detailed error reporting.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test restore with valid bundle creates expected resources. Test conflict resolution modes (skip, overwrite, fail). Test encrypted bundle restore with correct/incorrect passwords. Test invalid bundle rejection.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Add REST endpoints for backup and restore",
|
||||
"description": "Create REST API routes in src/mcpd/src/routes/ for triggering backup creation and restore operations.",
|
||||
"dependencies": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
"details": "Create backup.ts routes file with: POST /api/v1/backup (create backup, optional password for encryption, returns JSON bundle), POST /api/v1/restore (accepts JSON bundle in body, password if encrypted, conflict strategy option, returns import summary). Register routes in routes/index.ts. Define BackupDeps interface following existing patterns. Add appropriate error handling for invalid bundles, decryption failures, and conflict errors. Include validation schemas for request bodies.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Integration test backup endpoint returns valid JSON bundle. Test restore endpoint with valid/invalid bundles. Test encrypted backup/restore round-trip via API. Test error responses for various failure scenarios.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Add CLI commands for backup and restore",
|
||||
"description": "Implement CLI commands in src/cli/src/commands/ for backup export to file and restore from file.",
|
||||
"dependencies": [
|
||||
4
|
||||
],
|
||||
"details": "Create backup.ts commands file with: 'mcpctl backup' command with options --output/-o (file path), --encrypt (prompt for password), --resources (filter: servers,profiles,projects). Create 'mcpctl restore' command with options --input/-i (file path), --password (or prompt if encrypted), --conflict (skip|overwrite|fail). Commands should call the daemon API endpoints. Add progress output and summary of backed up/restored resources. Register commands in cli/src/index.ts following existing createXxxCommand pattern.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test backup command creates valid file. Test restore command from backup file. Test encryption password prompting. Test --resources filtering. Test various conflict resolution modes via CLI.",
|
||||
"parentId": "undefined"
|
||||
}
|
||||
],
|
||||
"updatedAt": "2026-02-21T05:40:51.787Z"
|
||||
},
|
||||
{
|
||||
"id": "24",
|
||||
@@ -730,15 +1054,367 @@
|
||||
"dependencies": [
|
||||
"1"
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T05:12:31.235Z"
|
||||
},
|
||||
{
|
||||
"id": "25",
|
||||
"title": "Rename local-proxy to mcplocal",
|
||||
"description": "Rename the src/local-proxy directory to src/mcplocal and update all package references, imports, and build configurations throughout the monorepo.",
|
||||
"details": "1. Rename directory: `mv src/local-proxy src/mcplocal`\n2. Update package.json name from `@mcpctl/local-proxy` to `@mcpctl/mcplocal`\n3. Update pnpm-workspace.yaml if needed\n4. Update all imports in other packages that reference local-proxy:\n - Search for `@mcpctl/local-proxy` and replace with `@mcpctl/mcplocal`\n - Check tsconfig references and path mappings\n5. Update any scripts in package.json root that reference local-proxy\n6. Update docker-compose files in deploy/ if they reference local-proxy\n7. Update documentation and README references\n8. Run `pnpm install` to regenerate lockfile with new package name\n9. Verify TypeScript compilation succeeds: `pnpm build`\n10. Run existing tests to ensure nothing broke: `pnpm test`",
|
||||
"testStrategy": "1. Verify directory rename completed: `ls src/mcplocal`\n2. Verify package.json has correct name\n3. Run `pnpm install` - should complete without errors\n4. Run `pnpm build` - all packages should compile\n5. Run `pnpm test` - all existing tests should pass\n6. Grep codebase for 'local-proxy' - should find no stale references except git history",
|
||||
"priority": "high",
|
||||
"dependencies": [],
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:04:17.018Z"
|
||||
},
|
||||
{
|
||||
"id": "26",
|
||||
"title": "Add HTTP REST server to mcplocal",
|
||||
"description": "Add a Fastify HTTP server to mcplocal that runs alongside the existing stdio server, providing REST endpoints for mcpctl management commands.",
|
||||
"details": "1. Add Fastify dependency to mcplocal package.json: `@fastify/cors`, `fastify`\n2. Create `src/mcplocal/src/http/server.ts` with Fastify app setup:\n ```typescript\n import Fastify from 'fastify';\n import cors from '@fastify/cors';\n \n export async function createHttpServer(config: HttpServerConfig) {\n const app = Fastify({ logger: true });\n await app.register(cors, { origin: true });\n // Register routes\n return app;\n }\n ```\n3. Create `src/mcplocal/src/http/routes/` directory structure\n4. Create health check endpoint: `GET /health`\n5. Create config types in `src/mcplocal/src/config.ts`:\n - `httpPort`: number (default 3200)\n - `httpHost`: string (default '127.0.0.1')\n - `mcpdUrl`: string (default 'http://localhost:3100')\n6. Update mcplocal entry point to start both servers:\n - stdio server for Claude MCP protocol\n - HTTP server for mcpctl REST API\n7. Add graceful shutdown handling for both servers",
|
||||
"testStrategy": "1. Unit test: HTTP server starts on configured port\n2. Unit test: Health endpoint returns 200 OK\n3. Integration test: Both stdio and HTTP servers can run simultaneously\n4. Test graceful shutdown stops both servers cleanly\n5. Test CORS headers are present on responses\n6. Manual test: curl http://localhost:3200/health",
|
||||
"priority": "high",
|
||||
"dependencies": [
|
||||
"25"
|
||||
],
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:09:26.322Z"
|
||||
},
|
||||
{
|
||||
"id": "27",
|
||||
"title": "Implement mcplocal management proxy routes",
|
||||
"description": "Add REST endpoints to mcplocal that mirror mcpd's API and proxy management requests to mcpd without LLM processing. All requests must include proper authentication to mcpd using a Bearer token read from mcplocal config.",
|
||||
"status": "done",
|
||||
"dependencies": [
|
||||
"26"
|
||||
],
|
||||
"priority": "high",
|
||||
"details": "1. Create HTTP client for mcpd communication with auth: `src/local-proxy/src/http/mcpd-client.ts`\n ```typescript\n export class McpdClient {\n private token: string;\n \n constructor(private baseUrl: string, token: string) {\n this.token = token;\n }\n \n private getHeaders(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n };\n }\n \n async get<T>(path: string): Promise<T> {\n const response = await fetch(`${this.baseUrl}${path}`, {\n method: 'GET',\n headers: this.getHeaders()\n });\n await this.handleAuthError(response);\n return response.json();\n }\n \n async post<T>(path: string, body: unknown): Promise<T> {\n const response = await fetch(`${this.baseUrl}${path}`, {\n method: 'POST',\n headers: this.getHeaders(),\n body: JSON.stringify(body)\n });\n await this.handleAuthError(response);\n return response.json();\n }\n \n async put<T>(path: string, body: unknown): Promise<T> {\n const response = await fetch(`${this.baseUrl}${path}`, {\n method: 'PUT',\n headers: this.getHeaders(),\n body: JSON.stringify(body)\n });\n await this.handleAuthError(response);\n return response.json();\n }\n \n async delete<T>(path: string): Promise<T> {\n const response = await fetch(`${this.baseUrl}${path}`, {\n method: 'DELETE',\n headers: this.getHeaders()\n });\n await this.handleAuthError(response);\n return response.json();\n }\n \n private async handleAuthError(response: Response): Promise<void> {\n if (response.status === 401) {\n throw new AuthenticationError('Invalid or expired token. Please check mcplocal config.');\n }\n }\n }\n \n export class AuthenticationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'AuthenticationError';\n }\n }\n ```\n2. Add token to mcplocal config type (extend ProxyConfig or similar):\n ```typescript\n export interface McpdAuthConfig {\n /** Bearer token for mcpd API authentication */\n mcpdToken: string;\n }\n ```\n3. Create proxy routes in `src/local-proxy/src/http/routes/`:\n - `servers.ts`: GET/POST /api/v1/servers, GET/PUT/DELETE /api/v1/servers/:id\n - `profiles.ts`: GET/POST /api/v1/profiles, GET/PUT/DELETE /api/v1/profiles/:id\n - `instances.ts`: GET/POST /api/v1/instances, GET/POST/DELETE /api/v1/instances/:id, etc.\n - `projects.ts`: GET/POST /api/v1/projects, etc.\n - `audit.ts`: GET /api/v1/audit-logs\n - `backup.ts`: POST /api/v1/backup, POST /api/v1/restore\n4. Each route handler forwards to mcpd with auth:\n ```typescript\n app.get('/api/v1/servers', async (req, reply) => {\n try {\n const result = await mcpdClient.get('/api/v1/servers');\n return result;\n } catch (error) {\n if (error instanceof AuthenticationError) {\n return reply.status(401).send({ error: error.message });\n }\n throw error;\n }\n });\n ```\n5. Add comprehensive error handling:\n - If mcpd is unreachable, return 503 Service Unavailable\n - If mcpd returns 401, return 401 with clear message about token configuration\n - Forward other HTTP errors from mcpd with appropriate status codes\n6. Add request/response logging for debugging",
|
||||
"testStrategy": "1. Unit test: McpdClient attaches Authorization header to all request methods (GET, POST, PUT, DELETE)\n2. Unit test: McpdClient throws AuthenticationError on 401 response from mcpd\n3. Unit test: Each proxy route forwards requests correctly with auth headers\n4. Unit test: Error handling when mcpd is unreachable (503 response)\n5. Unit test: Error handling when mcpd returns 401 (clear error message returned)\n6. Integration test: Full request flow mcpctl -> mcplocal -> mcpd with valid token\n7. Integration test: Full request flow with invalid token returns 401\n8. Test query parameters are forwarded correctly\n9. Test request body is forwarded correctly for POST/PUT\n10. Test path parameters (:id) are passed through correctly\n11. Mock mcpd responses and verify mcplocal returns them unchanged\n12. Test token is read correctly from mcplocal config",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:34:20.942Z"
|
||||
},
|
||||
{
|
||||
"id": "28",
|
||||
"title": "Add MCP proxy endpoint to mcpd",
|
||||
"description": "Create a new endpoint in mcpd at /api/v1/mcp/proxy that accepts MCP tool call requests and executes them on managed MCP server instances. Also add authentication endpoints (login/logout) that mcpctl will use to authenticate users.",
|
||||
"status": "done",
|
||||
"dependencies": [],
|
||||
"priority": "high",
|
||||
"details": "## MCP Proxy Endpoint\n\n1. Create new route file: `src/mcpd/src/routes/mcp-proxy.ts`\n2. Define request schema:\n ```typescript\n interface McpProxyRequest {\n serverId: string; // or instanceId\n method: string; // e.g., 'tools/call', 'resources/read'\n params: Record<string, unknown>;\n }\n ```\n3. Create McpProxyService in `src/mcpd/src/services/mcp-proxy-service.ts`:\n - Look up instance by serverId (auto-start if profile allows)\n - Connect to the container via stdio or HTTP (depending on transport type)\n - Execute the MCP JSON-RPC call\n - Return the result\n4. Handle MCP JSON-RPC protocol:\n ```typescript\n async executeCall(instanceId: string, method: string, params: unknown) {\n const instance = await this.instanceService.getInstance(instanceId);\n const connection = await this.getOrCreateConnection(instance);\n const result = await connection.call(method, params);\n return result;\n }\n ```\n5. Connection pooling: maintain persistent connections to running instances\n6. Add route: `POST /api/v1/mcp/proxy` (must be behind auth middleware)\n7. Add audit logging for all MCP proxy calls - include authenticated userId from request.userId\n8. Handle errors: instance not found, instance not running, MCP call failed\n\n## Authentication Endpoints\n\n9. Create auth routes file: `src/mcpd/src/routes/auth.ts`\n10. Implement `POST /api/v1/auth/login`:\n - Request body: `{ username: string, password: string }`\n - Validate credentials against User table (use bcrypt for password comparison)\n - Create new Session record with token (use crypto.randomUUID or similar)\n - Response: `{ token: string, expiresAt: string }`\n11. Implement `POST /api/v1/auth/logout`:\n - Requires Bearer token in Authorization header\n - Delete/invalidate the Session record\n - Response: `{ success: true }`\n\n## Auth Integration Notes\n\n- Existing auth middleware in `src/mcpd/src/middleware/auth.ts` validates Bearer tokens against Session table\n- It sets `request.userId` on successful authentication\n- MCP proxy endpoint MUST use this auth middleware\n- Auth endpoints (login) should NOT require auth middleware\n- Logout endpoint SHOULD require auth middleware to validate the session being invalidated",
|
||||
"testStrategy": "1. Unit test: Proxy service looks up correct instance\n2. Unit test: JSON-RPC call is formatted correctly\n3. Integration test: Full flow with a mock MCP server container\n4. Test error handling: non-existent server returns 404\n5. Test error handling: stopped instance returns appropriate error\n6. Test audit log entries include authenticated userId\n7. Test connection reuse for multiple calls to same instance\n8. Test login endpoint: valid credentials return session token\n9. Test login endpoint: invalid credentials return 401\n10. Test logout endpoint: valid session is invalidated\n11. Test logout endpoint: invalid/missing token returns 401\n12. Test MCP proxy endpoint without auth token returns 401\n13. Test MCP proxy endpoint with expired token returns 401\n14. Test MCP proxy endpoint with valid token succeeds and logs userId in audit",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Create auth routes with login/logout endpoints",
|
||||
"description": "Create src/mcpd/src/routes/auth.ts with POST /api/v1/auth/login and POST /api/v1/auth/logout endpoints for mcpctl authentication.",
|
||||
"dependencies": [],
|
||||
"details": "Implement login endpoint: validate username/password against User table using bcrypt, create Session record with generated token and expiry. Implement logout endpoint: require auth middleware, delete/invalidate Session record. Login does NOT require auth, logout DOES require auth. Export registerAuthRoutes function and update routes/index.ts.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test login with valid/invalid credentials. Test logout invalidates session. Test logout requires valid auth token. Test session token format and expiry.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Create MCP proxy route file with auth middleware",
|
||||
"description": "Create src/mcpd/src/routes/mcp-proxy.ts with POST /api/v1/mcp/proxy endpoint protected by auth middleware.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Define McpProxyRequest interface (serverId, method, params). Register route handler that extracts userId from request.userId (set by auth middleware). Apply auth middleware using preHandler hook. Validate request body schema.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test endpoint returns 401 without auth token. Test endpoint returns 401 with invalid/expired token. Test valid auth token allows request through.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Create McpProxyService for instance lookup and connection",
|
||||
"description": "Create src/mcpd/src/services/mcp-proxy-service.ts to handle instance lookup, connection management, and MCP call execution.",
|
||||
"dependencies": [],
|
||||
"details": "Implement getInstance to look up by serverId, auto-start if profile allows. Implement getOrCreateConnection for connection pooling. Handle both stdio and HTTP transports. Implement executeCall method that formats JSON-RPC call and returns result.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit test instance lookup. Unit test connection pooling reuses connections. Test auto-start behavior. Test both transport types.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Implement MCP JSON-RPC call execution",
|
||||
"description": "Implement the core JSON-RPC call logic in McpProxyService to execute tool calls on MCP server instances.",
|
||||
"dependencies": [
|
||||
3
|
||||
],
|
||||
"details": "Format JSON-RPC 2.0 request with method and params. Send request over established connection (stdio/HTTP). Parse JSON-RPC response and handle errors. Return result or throw appropriate error for failed calls.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit test JSON-RPC request formatting. Test successful call returns result. Test JSON-RPC error responses are handled. Integration test with mock MCP server.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Add audit logging with userId for MCP proxy calls",
|
||||
"description": "Ensure all MCP proxy calls are logged to audit log including the authenticated userId from the session.",
|
||||
"dependencies": [
|
||||
2,
|
||||
4
|
||||
],
|
||||
"details": "Use existing audit middleware/service. Include userId from request.userId in audit log entry. Log serverId, method, and outcome (success/failure). Log any errors that occur during MCP call execution.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test audit log entries contain userId. Test audit log entries contain serverId and method. Test failed calls are logged with error details.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "Integrate auth and proxy routes into server.ts",
|
||||
"description": "Register the new auth and mcp-proxy routes in the Fastify server with proper auth middleware wiring.",
|
||||
"dependencies": [
|
||||
1,
|
||||
2,
|
||||
5
|
||||
],
|
||||
"details": "Update server.ts to register auth routes (no auth required for login). Register mcp-proxy routes with auth middleware. Ensure auth middleware is wired with findSession dependency from Prisma. Update routes/index.ts exports.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Integration test full login -> proxy call flow. Test auth middleware correctly protects proxy endpoint. Test health endpoints remain unauthenticated.",
|
||||
"parentId": "undefined"
|
||||
}
|
||||
],
|
||||
"updatedAt": "2026-02-21T18:09:26.327Z"
|
||||
},
|
||||
{
|
||||
"id": "29",
|
||||
"title": "Implement LLM pre-processing pipeline in mcplocal",
|
||||
"description": "Create the core LLM pre-processing pipeline that intercepts MCP tool calls, uses a local LLM to optimize requests before sending to mcpd, and filters responses before returning to Claude.",
|
||||
"details": "1. Create `src/mcplocal/src/llm/processor.ts` - the core pipeline:\n ```typescript\n export class LlmProcessor {\n constructor(\n private providerRegistry: ProviderRegistry,\n private config: LlmProcessorConfig\n ) {}\n \n async preprocessRequest(toolName: string, params: unknown): Promise<ProcessedRequest> {\n // Use LLM to interpret and optimize the request\n const prompt = this.buildRequestPrompt(toolName, params);\n const result = await this.providerRegistry.getActiveProvider().complete({\n systemPrompt: REQUEST_OPTIMIZATION_SYSTEM_PROMPT,\n userPrompt: prompt\n });\n return this.parseOptimizedRequest(result);\n }\n \n async filterResponse(toolName: string, originalRequest: unknown, rawResponse: unknown): Promise<FilteredResponse> {\n // Use LLM to filter/summarize the response\n const prompt = this.buildFilterPrompt(toolName, originalRequest, rawResponse);\n const result = await this.providerRegistry.getActiveProvider().complete({\n systemPrompt: RESPONSE_FILTER_SYSTEM_PROMPT,\n userPrompt: prompt\n });\n return this.parseFilteredResponse(result);\n }\n }\n ```\n2. Create system prompts in `src/mcplocal/src/llm/prompts.ts`:\n - REQUEST_OPTIMIZATION_SYSTEM_PROMPT: instruct LLM to generate optimal queries\n - RESPONSE_FILTER_SYSTEM_PROMPT: instruct LLM to extract relevant information\n3. Integrate into router.ts - wrap tools/call handler:\n ```typescript\n async handleToolsCall(request: JsonRpcRequest) {\n if (this.shouldPreprocess(request.params.name)) {\n const processed = await this.llmProcessor.preprocessRequest(...);\n // Call mcpd with processed request\n const rawResponse = await this.callMcpd(processed);\n const filtered = await this.llmProcessor.filterResponse(...);\n return filtered;\n }\n return this.callMcpd(request.params);\n }\n ```\n4. Add configuration options:\n - `enablePreprocessing`: boolean\n - `preprocessingExclude`: string[] (tool names to skip)\n - `preferredProvider`: string (ollama, gemini, deepseek, etc.)\n5. Add bypass logic for simple operations (list, create, delete)",
|
||||
"testStrategy": "1. Unit test: Request preprocessing generates optimized queries\n2. Unit test: Response filtering reduces data volume\n3. Unit test: Bypass logic works for excluded tools\n4. Integration test: Full pipeline with mock LLM provider\n5. Test error handling: LLM failure falls back to unfiltered pass-through\n6. Test configuration options are respected\n7. Measure: response size reduction percentage",
|
||||
"priority": "high",
|
||||
"dependencies": [
|
||||
"25",
|
||||
"27",
|
||||
"28"
|
||||
],
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:41:26.539Z"
|
||||
},
|
||||
{
|
||||
"id": "30",
|
||||
"title": "Add Gemini CLI LLM provider",
|
||||
"description": "Implement a new LLM provider that uses the Gemini CLI binary for local, free LLM inference as the preferred provider for pre-processing.",
|
||||
"details": "1. Create `src/mcplocal/src/providers/gemini-cli.ts`:\n ```typescript\n import { spawn } from 'child_process';\n \n export class GeminiCliProvider implements LlmProvider {\n readonly name = 'gemini-cli';\n private binaryPath: string;\n \n constructor(config: GeminiCliConfig) {\n this.binaryPath = config.binaryPath || 'gemini';\n }\n \n async isAvailable(): Promise<boolean> {\n // Check if gemini binary exists and is executable\n try {\n await this.runCommand(['--version']);\n return true;\n } catch {\n return false;\n }\n }\n \n async complete(options: CompletionOptions): Promise<CompletionResult> {\n const input = this.formatPrompt(options);\n const output = await this.runCommand(['--prompt', input]);\n return { content: output, model: 'gemini-cli' };\n }\n \n private async runCommand(args: string[]): Promise<string> {\n // Spawn gemini CLI process and capture output\n }\n }\n ```\n2. Research actual Gemini CLI interface and adjust implementation\n3. Add to provider registry with high priority (prefer over API providers)\n4. Add configuration: `geminiCliBinaryPath`\n5. Handle timeout for slow inference\n6. Add fallback to next provider if Gemini CLI fails",
|
||||
"testStrategy": "1. Unit test: Provider correctly detects CLI availability\n2. Unit test: Prompt formatting is correct\n3. Unit test: Output parsing handles various formats\n4. Integration test: Full completion with actual Gemini CLI (if available)\n5. Test timeout handling for slow responses\n6. Test fallback when CLI is not installed",
|
||||
"priority": "medium",
|
||||
"dependencies": [
|
||||
"25"
|
||||
],
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:34:20.968Z"
|
||||
},
|
||||
{
|
||||
"id": "31",
|
||||
"title": "Add DeepSeek API LLM provider",
|
||||
"description": "Implement DeepSeek API provider as a cheap cloud-based fallback when local LLMs are unavailable.",
|
||||
"details": "1. Create `src/mcplocal/src/providers/deepseek.ts`:\n ```typescript\n export class DeepSeekProvider implements LlmProvider {\n readonly name = 'deepseek';\n private apiKey: string;\n private baseUrl = 'https://api.deepseek.com/v1';\n \n constructor(config: DeepSeekConfig) {\n this.apiKey = config.apiKey || process.env.DEEPSEEK_API_KEY;\n }\n \n async isAvailable(): Promise<boolean> {\n return !!this.apiKey;\n }\n \n async complete(options: CompletionOptions): Promise<CompletionResult> {\n // DeepSeek uses OpenAI-compatible API\n const response = await fetch(`${this.baseUrl}/chat/completions`, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n model: 'deepseek-chat',\n messages: [{ role: 'user', content: options.userPrompt }]\n })\n });\n // Parse and return\n }\n }\n ```\n2. Add DEEPSEEK_API_KEY to configuration\n3. Register in provider registry with medium priority\n4. Support both deepseek-chat and deepseek-coder models\n5. Add rate limiting handling",
|
||||
"testStrategy": "1. Unit test: Provider correctly checks API key availability\n2. Unit test: Request formatting matches DeepSeek API spec\n3. Unit test: Response parsing handles all fields\n4. Integration test: Full completion with actual API (with valid key)\n5. Test error handling for rate limits\n6. Test error handling for invalid API key",
|
||||
"priority": "medium",
|
||||
"dependencies": [
|
||||
"25"
|
||||
],
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:34:20.974Z"
|
||||
},
|
||||
{
|
||||
"id": "32",
|
||||
"title": "Implement smart context optimization",
|
||||
"description": "Add token counting and decision logic to intelligently skip LLM filtering when responses are small enough, and cache filtering decisions for repeated queries.",
|
||||
"details": "1. Create `src/mcplocal/src/llm/token-counter.ts`:\n ```typescript\n export function estimateTokens(text: string): number {\n // Simple estimation: ~4 chars per token for English\n // More accurate: use tiktoken or similar library\n return Math.ceil(text.length / 4);\n }\n ```\n2. Create `src/mcplocal/src/llm/filter-cache.ts`:\n ```typescript\n export class FilterCache {\n private cache: LRUCache<string, FilterDecision>;\n \n shouldFilter(toolName: string, params: unknown, responseSize: number): boolean {\n const key = this.computeKey(toolName, params);\n const cached = this.cache.get(key);\n if (cached) return cached.shouldFilter;\n // No cache hit - use default threshold logic\n return responseSize > this.tokenThreshold;\n }\n \n recordDecision(toolName: string, params: unknown, decision: FilterDecision): void {\n const key = this.computeKey(toolName, params);\n this.cache.set(key, decision);\n }\n }\n ```\n3. Add configuration options:\n - `tokenThreshold`: number (default 1000 tokens)\n - `filterCacheSize`: number (default 1000 entries)\n - `filterCacheTtl`: number (default 3600 seconds)\n4. Integrate into LlmProcessor:\n ```typescript\n async filterResponse(...) {\n const tokens = estimateTokens(JSON.stringify(rawResponse));\n if (tokens < this.config.tokenThreshold) {\n // Not worth filtering - return as-is\n return { filtered: false, response: rawResponse };\n }\n // Proceed with LLM filtering\n }\n ```\n5. Add metrics tracking:\n - Total tokens processed\n - Tokens saved by filtering\n - Filter cache hit rate\n - Average latency added by filtering",
|
||||
"testStrategy": "1. Unit test: Token estimation is reasonably accurate\n2. Unit test: Cache correctly stores and retrieves decisions\n3. Unit test: Threshold logic skips filtering for small responses\n4. Unit test: Cache TTL expiration works correctly\n5. Integration test: Metrics are recorded accurately\n6. Performance test: Cache improves latency for repeated queries",
|
||||
"priority": "medium",
|
||||
"dependencies": [
|
||||
"29"
|
||||
],
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:47:07.709Z"
|
||||
},
|
||||
{
|
||||
"id": "33",
|
||||
"title": "Update mcpctl to use mcplocal as daemon",
|
||||
"description": "Modify mcpctl CLI to connect to mcplocal instead of mcpd directly, update configuration options, add dual connectivity status checking, and implement authentication commands (login/logout) with secure credential storage.",
|
||||
"status": "done",
|
||||
"dependencies": [
|
||||
"27"
|
||||
],
|
||||
"priority": "high",
|
||||
"details": "1. Update `src/cli/src/config/schema.ts`:\n ```typescript\n export interface McpctlConfig {\n mcplocalUrl: string; // NEW: default 'http://localhost:3200'\n mcpdUrl: string; // Keep for reference/direct access if needed\n // ... other fields\n }\n ```\n2. Update `src/cli/src/config/defaults.ts`:\n - Change default daemonUrl to http://localhost:3200 (mcplocal)\n3. Update `src/cli/src/api-client.ts`:\n - Default baseUrl now points to mcplocal\n4. Add new config commands in `src/cli/src/commands/config.ts`:\n ```typescript\n .command('set-mcplocal-url <url>')\n .command('set-mcpd-url <url>')\n .command('get-mcplocal-url')\n .command('get-mcpd-url')\n ```\n5. Update `src/cli/src/commands/status.ts` to show both connections and auth status:\n ```\n $ mcpctl status\n mcplocal: connected (localhost:3200)\n mcpd: connected (nas.local:3100) via mcplocal\n Auth: logged in as user@example.com\n LLM Provider: ollama (llama3.2)\n Token savings: 45% (last 24h)\n ```\n6. Update CLI --daemon-url flag to point to mcplocal\n7. Add --direct flag to bypass mcplocal and talk to mcpd directly (for debugging)\n8. Create `src/cli/src/commands/auth.ts` with login/logout commands:\n - `mcpctl login`: Prompt for mcpd URL (if not configured) and credentials\n - Call POST /api/v1/auth/login with { email, password }\n - Store session token in ~/.mcpctl/credentials with 0600 permissions\n - `mcpctl logout`: Invalidate session and delete stored token\n9. Create `src/cli/src/auth/credentials.ts` for secure token storage:\n - Use fs.chmod to set 0600 permissions on credentials file\n - Token format: { token: string, mcpdUrl: string, user: string, expiresAt?: string }\n10. Update api-client.ts to include stored token in requests to mcplocal\n - mcplocal passes this token to mcpd for authentication",
|
||||
"testStrategy": "1. Unit test: Default config points to mcplocal URL\n2. Unit test: Config commands update correct fields\n3. Integration test: CLI commands work through mcplocal proxy\n4. Test status command shows both mcplocal and mcpd status\n5. Test --direct flag bypasses mcplocal\n6. Test backward compatibility with existing config files\n7. Unit test: login command stores token with correct permissions (0600)\n8. Unit test: logout command removes credentials file\n9. Integration test: login flow with POST /api/v1/auth/login\n10. Test status command shows auth status (logged in as user)\n11. Test token is passed to mcplocal in API requests\n12. Test invalid credentials return appropriate error message\n13. Test expired token handling",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Update config schema for mcplocal and mcpd URLs",
|
||||
"description": "Modify McpctlConfigSchema in src/cli/src/config/schema.ts to include separate mcplocalUrl and mcpdUrl fields with appropriate defaults.",
|
||||
"dependencies": [],
|
||||
"details": "Update the Zod schema to add mcplocalUrl (default: http://localhost:3200) and mcpdUrl (default: http://localhost:3100). Update DEFAULT_CONFIG and ensure backward compatibility with existing daemonUrl field by mapping it to mcplocalUrl.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit test schema validation for new URL fields. Test default values are correct. Test backward compatibility mapping.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Create auth credentials storage module",
|
||||
"description": "Create src/cli/src/auth/credentials.ts to handle secure storage and retrieval of session tokens in ~/.mcpctl/credentials.",
|
||||
"dependencies": [],
|
||||
"details": "Implement saveCredentials(token, mcpdUrl, user), loadCredentials(), and deleteCredentials() functions. Use fs.chmod to set 0600 permissions. Store JSON format: { token, mcpdUrl, user, expiresAt }. Handle file not found gracefully in loadCredentials.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Unit test credentials are saved with 0600 permissions. Test load returns null when file doesn't exist. Test delete removes the file.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Implement login command",
|
||||
"description": "Create src/cli/src/commands/auth.ts with mcpctl login command that prompts for mcpd URL and credentials, calls POST /api/v1/auth/login, and stores the session token.",
|
||||
"dependencies": [
|
||||
2
|
||||
],
|
||||
"details": "Use inquirer or prompts library for interactive credential input (email, password). If mcpdUrl not configured, prompt for it. Call POST /api/v1/auth/login with credentials. On success, save token using credentials module. Display 'Logged in as {user}' on success. Handle errors (invalid credentials, network errors) with clear messages.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test prompts collect correct input. Test successful login stores credentials. Test failed login shows error without storing token.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Implement logout command",
|
||||
"description": "Add mcpctl logout command to auth.ts that invalidates the session and removes stored credentials.",
|
||||
"dependencies": [
|
||||
2
|
||||
],
|
||||
"details": "Load stored credentials, optionally call a logout endpoint on mcpd to invalidate server-side session, then delete the local credentials file. Display 'Logged out successfully' or 'Not logged in' as appropriate.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test logout removes credentials file. Test logout when not logged in shows appropriate message.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Update api-client to include auth token",
|
||||
"description": "Modify src/cli/src/api-client.ts to load and include stored session token in Authorization header for requests to mcplocal.",
|
||||
"dependencies": [
|
||||
2
|
||||
],
|
||||
"details": "Import loadCredentials from auth module. Add Authorization: Bearer {token} header to requests when credentials exist. Handle expired token by returning appropriate error suggesting re-login.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test requests include Authorization header when logged in. Test requests work without token when not logged in.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "Update status command to show auth status",
|
||||
"description": "Modify src/cli/src/commands/status.ts to display authentication status (logged in as user X or not logged in) along with mcplocal and mcpd connectivity.",
|
||||
"dependencies": [
|
||||
2,
|
||||
5
|
||||
],
|
||||
"details": "Load credentials and display auth status line: 'Auth: logged in as {user}' or 'Auth: not logged in'. Update status output format to show mcplocal and mcpd status separately with the auth info.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test status shows 'logged in as user' when credentials exist. Test status shows 'not logged in' when no credentials.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "Add config commands for mcplocal and mcpd URLs",
|
||||
"description": "Add set-mcplocal-url, set-mcpd-url, get-mcplocal-url, and get-mcpd-url commands to src/cli/src/commands/config.ts.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Add four new subcommands to the config command for setting and getting the mcplocal and mcpd URLs independently. Update the generic 'set' command to handle these new schema fields.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test each command correctly reads/writes the appropriate config field.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "Add --direct flag for mcpd bypass",
|
||||
"description": "Add --direct flag to CLI commands that bypasses mcplocal and connects directly to mcpd for debugging purposes.",
|
||||
"dependencies": [
|
||||
1,
|
||||
5
|
||||
],
|
||||
"details": "Add global --direct option to the main CLI. When set, api-client uses mcpdUrl instead of mcplocalUrl. Useful for debugging connectivity issues between mcplocal and mcpd.",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test --direct flag causes requests to use mcpdUrl. Test normal operation uses mcplocalUrl.",
|
||||
"parentId": "undefined"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "Register auth commands in CLI entry point",
|
||||
"description": "Import and register the login and logout commands in src/cli/src/index.ts.",
|
||||
"dependencies": [
|
||||
3,
|
||||
4
|
||||
],
|
||||
"details": "Import createAuthCommand from commands/auth.ts and add it to the main program with program.addCommand(createAuthCommand()).",
|
||||
"status": "pending",
|
||||
"testStrategy": "Test mcpctl login and mcpctl logout are available as commands.",
|
||||
"parentId": "undefined"
|
||||
}
|
||||
],
|
||||
"updatedAt": "2026-02-21T18:39:11.345Z"
|
||||
},
|
||||
{
|
||||
"id": "34",
|
||||
"title": "Connect mcplocal MCP router to mcpd proxy endpoint",
|
||||
"description": "Update mcplocal's MCP router to forward tool calls to mcpd's new /api/v1/mcp/proxy endpoint instead of connecting to MCP servers directly.",
|
||||
"details": "1. Update `src/mcplocal/src/router.ts` to use mcpd proxy:\n ```typescript\n class Router {\n private mcpdClient: McpdClient;\n \n async handleToolsCall(request: JsonRpcRequest) {\n const { name, arguments: args } = request.params;\n const [serverName, toolName] = name.split('/');\n \n // Pre-process with LLM if enabled\n const processedArgs = this.config.enablePreprocessing\n ? await this.llmProcessor.preprocessRequest(toolName, args)\n : args;\n \n // Call mcpd proxy endpoint\n const result = await this.mcpdClient.post('/api/v1/mcp/proxy', {\n serverId: serverName,\n method: 'tools/call',\n params: { name: toolName, arguments: processedArgs }\n });\n \n // Post-process response with LLM if enabled\n return this.config.enablePreprocessing\n ? await this.llmProcessor.filterResponse(toolName, args, result)\n : result;\n }\n }\n ```\n2. Update upstream configuration:\n - Remove direct upstream connections for managed servers\n - Keep option for local/unmanaged upstreams\n3. Add server discovery from mcpd:\n ```typescript\n async refreshServerList() {\n const servers = await this.mcpdClient.get('/api/v1/servers');\n this.updateAvailableTools(servers);\n }\n ```\n4. Handle tools/list by aggregating from mcpd servers\n5. Handle resources/list and prompts/list similarly",
|
||||
"testStrategy": "1. Unit test: Tool calls are forwarded to mcpd proxy correctly\n2. Unit test: Server name is extracted from namespaced tool name\n3. Integration test: Full flow Claude -> mcplocal -> mcpd -> container\n4. Test tools/list aggregates from all mcpd servers\n5. Test error handling when mcpd is unreachable\n6. Test LLM preprocessing is applied when enabled",
|
||||
"priority": "high",
|
||||
"dependencies": [
|
||||
"28",
|
||||
"29"
|
||||
],
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:43:14.673Z"
|
||||
},
|
||||
{
|
||||
"id": "35",
|
||||
"title": "Implement health monitoring across all tiers",
|
||||
"description": "Extend health monitoring to track connectivity and status across mcplocal, mcpd, and individual MCP server instances.",
|
||||
"details": "1. Update mcplocal health monitor in `src/mcplocal/src/health.ts`:\n ```typescript\n export class TieredHealthMonitor {\n async checkHealth(): Promise<TieredHealthStatus> {\n return {\n mcplocal: {\n status: 'healthy',\n llmProvider: await this.checkLlmProvider(),\n uptime: process.uptime()\n },\n mcpd: await this.checkMcpdHealth(),\n instances: await this.checkInstancesHealth()\n };\n }\n \n private async checkMcpdHealth(): Promise<McpdHealth> {\n try {\n const health = await this.mcpdClient.get('/api/v1/health');\n return { status: 'connected', ...health };\n } catch {\n return { status: 'disconnected' };\n }\n }\n \n private async checkInstancesHealth(): Promise<InstanceHealth[]> {\n const instances = await this.mcpdClient.get('/api/v1/instances');\n return instances.map(i => ({\n name: i.name,\n status: i.status,\n lastHealthCheck: i.lastHealthCheck\n }));\n }\n }\n ```\n2. Add health endpoint to mcplocal HTTP server: `GET /health`\n3. Update mcpctl status command to display tiered health\n4. Add degraded state detection:\n - LLM provider unavailable but mcpd reachable\n - Some instances down but others healthy\n5. Add health event notifications for state transitions\n6. Add configurable health check intervals",
|
||||
"testStrategy": "1. Unit test: Health check correctly identifies all states\n2. Unit test: Degraded state is detected correctly\n3. Integration test: Full health check across all tiers\n4. Test health endpoint returns correct format\n5. Test mcpctl status displays health correctly\n6. Test state transition events are emitted",
|
||||
"priority": "medium",
|
||||
"dependencies": [
|
||||
"33",
|
||||
"34"
|
||||
],
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:46:07.885Z"
|
||||
},
|
||||
{
|
||||
"id": "36",
|
||||
"title": "End-to-end integration testing",
|
||||
"description": "Create comprehensive integration tests that validate the full data flow from mcpctl through mcplocal to mcpd to MCP server containers and back.",
|
||||
"details": "1. Create test fixtures in `src/mcplocal/test/fixtures/`:\n - Mock MCP server that returns predictable responses\n - Test configuration files\n - Sample tool call payloads\n2. Create integration test suite in `src/mcplocal/test/integration/`:\n ```typescript\n describe('End-to-end flow', () => {\n it('mcpctl -> mcplocal -> mcpd -> mcp_server', async () => {\n // Start mock MCP server\n // Start mcpd with test config\n // Start mcplocal pointing to mcpd\n // Execute mcpctl command\n // Verify response flows back correctly\n });\n \n it('LLM pre-processing reduces response size', async () => {\n // Send query that returns large dataset\n // Verify LLM filtering reduces token count\n // Verify relevant data is preserved\n });\n \n it('credentials never leave mcpd', async () => {\n // Monitor all traffic from mcplocal\n // Verify no credentials appear in requests/responses\n });\n });\n ```\n3. Test scenarios:\n - Management commands (get servers, instances, etc.)\n - MCP tool calls with LLM preprocessing\n - MCP tool calls without preprocessing\n - Error handling (mcpd down, instance down, LLM failure)\n - Health monitoring accuracy\n4. Add CI integration test workflow\n5. Create docker-compose.test.yml for test environment",
|
||||
"testStrategy": "1. All integration tests pass in CI environment\n2. Test coverage includes happy path and error scenarios\n3. Performance benchmarks: measure latency at each tier\n4. Security test: verify credential isolation\n5. Load test: multiple concurrent requests\n6. Chaos test: random component failures",
|
||||
"priority": "high",
|
||||
"dependencies": [
|
||||
"29",
|
||||
"33",
|
||||
"34",
|
||||
"35"
|
||||
],
|
||||
"status": "done",
|
||||
"subtasks": [],
|
||||
"updatedAt": "2026-02-21T18:52:29.084Z"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"version": "1.0.0",
|
||||
"lastModified": "2026-02-21T04:56:01.659Z",
|
||||
"taskCount": 24,
|
||||
"completedCount": 8,
|
||||
"lastModified": "2026-02-21T18:52:29.084Z",
|
||||
"taskCount": 36,
|
||||
"completedCount": 33,
|
||||
"tags": [
|
||||
"master"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user