Closed
Conversation
- Install mongoose ^9.2.2 as dependency - Create src/lib/mongodb.ts: Mongoose connection singleton with HMR guard and graceful defaults-only mode when MONGODB_URI is absent - Create src/lib/encryption.ts: AES-256-GCM encrypt/decrypt with random 96-bit IV, auth tag, and dev key fallback; maskCredential shows last 4 chars
- Create src/models/mcp-server.ts: IMcpServer interface + McpServerSchema with collection "mcp", timestamps, HMR guard - Create src/lib/mcp-defaults.ts: getDefaultServers() assembles default servers from MCP_TYPEBOT_URL and MCP_CLOUDHUMANS_URL env vars with stable IDs and isDefault flag
- GET merges defaults (from env vars) with user servers from MongoDB - GET masks all credentials before returning (decrypt then maskCredential) - GET silently falls back to defaults-only when MongoDB is unreachable - POST validates body with Zod schema including auth/credential cross-field rules - POST encrypts credentials before MongoDB write, returns masked on response - POST returns 422 on validation failure, 503 when DB not configured, 500 on error - No Edge Runtime export (Node.js runtime required for MongoDB)
- PUT updates user-added servers with re-encrypted credentials - PUT returns 403 for default server IDs (default-typebot, default-cloudhumans) - PUT returns 422 when credentials contain masked value or are empty for bearer/apiKey - PUT returns 404 for non-existent servers or invalid ObjectId format - DELETE removes user-added servers; returns 403 for default server IDs - DELETE returns 404 for non-existent servers or invalid ObjectId format - ObjectId validation via mongoose.Types.ObjectId.isValid() prevents CastError 500s - No Edge Runtime export (Node.js runtime required for MongoDB)
- McpServer interface matching GET /api/mcp-servers response shape - fetchServers with loading/error state via useCallback + useEffect - addServer, updateServer, deleteServer with toast feedback - toggleServer with optimistic update and rollback on failure - refetch exported for external refresh triggers
- McpServerRow: name, URL, Default badge, inline Switch (disabled for defaults) - McpServerList: skeleton loading state, server rows, optional onAdd/renderActions slots - Settings page: new MCP Servers section below API Keys with Separator
- Shared dialog component with server? prop for add/edit mode discrimination - useState-based form: name, url, authType, credentials (never pre-filled) - Conditional credentials field shown only when authType !== none - handleAuthTypeChange clears credentials when switching to none (Pitfall 5) - handleSubmit omits credentials when empty in edit mode (Pitfall 1 avoided) - credentials: null sent when authType is none to clear stored value - Form reset via useEffect when dialog opens
… updated list and settings - DeleteServerAlert: AlertDialog with destructive confirm for server deletion - McpServerActions: Popover with Edit (McpServerFormDialog) and Delete (DeleteServerAlert) - McpServerList: updated onAdd prop type to async fn, renders McpServerFormDialog in header - settings/index.tsx: destructures addServer/updateServer/deleteServer, passes renderActions and onAdd to McpServerList; renderActions returns McpServerActions only for !isDefault servers
The (app)/layout.tsx duplicated html/head/body tags already present in the root layout.tsx, causing hydration errors and breaking sidebar rendering (including tenant dropdown). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- GET /api/mcp-servers/[id]/tools: decrypts credentials server-side, connects via StreamableHTTPClientTransport, returns listTools() result - GET /api/mcp-servers/snapshot: accepts ids[] query param, returns decrypted server objects for embedding in agent configurable - Both routes handle default servers (env-based) and MongoDB servers - Node.js runtime (not Edge) for crypto and Mongoose compatibility
- Wraps @radix-ui/react-checkbox with project-consistent styling - Matches switch.tsx pattern: "use client", data-slot, cn() merging - Checked state: bg-primary + text-primary-foreground + border-primary - Includes focus-visible ring, disabled state, and Check icon indicator
…onent - useMcpServerTools: fetches tool list via /api/mcp-servers/[id]/tools proxy, aborted flag prevents stale state updates, refetch callback for re-running - McpServerSelector: checkbox list from useMcpServers, tool preview via ServerToolPreview per selected server, unreachable servers auto-removed from selection - ServerToolPreview: calls useMcpServerTools per server, shows loading text, destructive error text, collapsible tool list with name + description - Badge "Default" label for default servers, Skeleton loading states, empty-list message
…t save - use-agent-config: detect mcp_servers in graph schema, expose hasMcpServers boolean - agent-form: add McpServerSelector section (guarded by hasMcpServers), accept selectedMcpServerIds and onMcpSelectionChange props - edit-agent-dialog: read hasMcpServers from useAgentConfig, call useMcpServers for pre-population, useEffect matches snapshot names to current server IDs, submit handler fetches /api/mcp-servers/snapshot before updateAgent - create-agent-dialog: new agents default to empty selection (AGNT-02), submit handler fetches snapshot if servers selected - mcp_servers only written to configurable when graph schema declares the field (avoids Pitfall 3)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add JWT validation and tenant isolation to all MCP server API routes so each tenant sees only its own servers while default servers remain global. - Create shared requireAuth() helper (validates Bearer token via Cognito, extracts x-tenant-name header) - Add tenantName field to McpServer model with compound index - Scope all CRUD and snapshot queries by tenantName (cross-tenant access returns 404 to avoid leaking existence) - Send Authorization + x-tenant-name headers from all frontend hooks (useMcpServers, useMcpServerTools, agent create/edit snapshot fetches) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…, cleanup - Snapshot endpoint now returns `id` field for stable server matching - Edit/create dialogs match by `id` first, fall back to `name` - McpServerToolGroups filters out disabled servers and accepts servers as props (removes duplicate useMcpServers() call) - Thread mcpServers/mcpServersLoading from dialogs through AgentFieldsForm - Hard-error in production when MCP_ENCRYPTION_KEY is missing - Document new env vars (MONGODB_URI, MCP_ENCRYPTION_KEY, default servers) - Remove unused checkbox.tsx and @radix-ui/react-checkbox dependency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prefix tool names with server slugs (slug__toolName) on save so claudia-agentic can filter with a simple Set.has(). Strip prefixes on load in the edit dialog so the UI still displays bare names. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add `slug` field to MongoDB model with unique (tenantName, slug) index - Compute slug via toServerSlug(name) on create/update, return 409 on collision (MongoError 11000 or default server slug conflict) - Add slug to McpServerDefault, McpServer interface, snapshot response - Remove deduplicateSlugs from mcp-slug.ts (no longer needed) - Update create/edit agent dialogs to use snap.slug from snapshot for tool prefixing (edit dialog falls back to toServerSlug for old configs) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Slug is always present in snapshot — no need for runtime fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… remove disabled servers Three fixes: 1. Tenant validation: requireAuth now extracts cognito:groups from the JWT and validates x-tenant-name against it. @cloudhumans.com emails bypass the check for full access. 2. Credentials: snapshot endpoint now returns encrypted credentials (MongoDB values pass through as-is, default server values encrypted on the fly). Credentials are never decrypted in the frontend flow. 3. Removed the disabled/enabled toggle from MCP servers — servers are either present or deleted, eliminating ghost state in agent configs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
Superseded by new PR with security fixes (tenant validation, encrypted credentials, removed disabled servers). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
100% vibecodado -- preciso revisar aqui pq acho q a IA implementou de uma forma burra