feat: add dynamic MCP servers with per-user preferences - #157
feat: add dynamic MCP servers with per-user preferences#157harshitkgupta wants to merge 3 commits into
Conversation
Allow developers to declare a catalog of MCP servers in config.yaml (CDK) or
terraform.tfvars (Terraform). Each enabled entry becomes an AgentCore Gateway
target (streamable-HTTP MCP). Per-user enable/disable toggles are persisted in
DynamoDB and surfaced through a settings dialog in the chat UI. The agent
runtime filters gateway tools per user on each request via Strands tool_filters.
Infrastructure (CDK + Terraform parity):
- McpServerConfig types + validation (NONE/OAUTH auth, https-only, no stdio)
- Gateway targets via L2 GatewayTarget.forMcpServer / native TF resource
- OAuth2 credential providers via L2 / native TF resource
- McpPrefsTable (DynamoDB) + mcp-prefs Lambda (GET/PUT /mcp-servers)
- Runtime env vars (MCP_PREFS_TABLE, MCP_SERVERS_CATALOG) + IAM grants
- API Gateway cache disabled on GET /mcp-servers (prevent cross-user leak)
Agent runtime:
- tools/mcp_prefs.py: reads user's enabled list, builds rejection filter
- tools/gateway.py: passes tool_filters to MCPClient
- Fail-open on DynamoDB error (catalog defaults used)
Frontend:
- McpServersDialog with checkbox toggles per server
- Gear icon in ChatHeader opens dialog
- mcpServerService for GET/PUT calls
Also:
- Cedar policy opened to all gateway tools (MCP tool names unknown at deploy)
- cedar-policy Lambda: idempotent CreatePolicyEngine (handle ConflictException)
- Target names shortened to mcp-{id} (Bedrock 64-char tool-name limit)
|
Latest scan for commit: Security Scan ResultsScan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies: Column Explanations: Severity Levels (S/C/H/M/L/I):
Other Columns:
Scanner Results:
Severity Thresholds (Thresh Column):
Threshold Source: Values in parentheses indicate where the threshold is configured:
Statistics calculation:
Detailed FindingsShow 40 actionable findingsFinding 1: CKV_AWS_119
Description: Code Snippet: Finding 2: CKV_AWS_158
Description: Code Snippet: Finding 3: CKV_AWS_173
Description: Code Snippet: Finding 4: CKV_AWS_116
Description: Code Snippet: Finding 5: CKV_AWS_272
Description: Code Snippet: Finding 6: CKV_AWS_115
Description: Code Snippet: Finding 7: CKV_AWS_117
Description: Code Snippet: Finding 8: CKV_AWS_50
Description: Code Snippet: Finding 9: CKV_AWS_237
Description: Code Snippet: Finding 10: CKV_AWS_120
Description: Code Snippet: Finding 11: CKV_AWS_73
Description: Code Snippet: Finding 12: CKV_AWS_158
Description: Code Snippet: Finding 13: CKV_AWS_28
Description: Code Snippet: Finding 14: CKV_AWS_119
Description: Code Snippet: Finding 15: CKV_AWS_158
Description: Code Snippet: Finding 16: CKV_AWS_173
Description: Code Snippet: Finding 17: CKV_AWS_116
Description: Code Snippet: Finding 18: CKV_AWS_272
Description: Code Snippet: Finding 19: CKV_AWS_115
Description: Code Snippet: Finding 20: CKV_AWS_117
Description: Code Snippet: Finding 21: CKV_AWS_50
Description: Code Snippet: Finding 22: CKV_AWS_225
Description: Code Snippet: Finding 23: CKV2_AWS_5
Description: Code Snippet: Finding 24: CKV2_AWS_4
Description: Code Snippet: Finding 25: CKV2_AWS_51
Description: Code Snippet: Finding 26: CKV2_AWS_53
Description: Code Snippet: Finding 27: CKV2_AWS_53
Description: Code Snippet: Finding 28: CKV2_AWS_53
Description: Code Snippet: |
Summary
config.yaml/terraform.tfvars— each becomes an AgentCore Gateway target (streamable-HTTP MCP, NONE or OAUTH auth)tool_filters; fail-open on DynamoDB errorConflictExceptionon retry)mcp-{id}(Bedrock 64-char tool-name limit)Test plan
tsc --noEmit(CDK + frontend)cdk synth— MCP targets, OAuth2 provider, prefs table, API routes all render correctlyterraform validate— passesmcp_prefs.pylogic self-check (defaults, prefs override, DDB error fail-open, filter callback)search_documentation→ real URL returned)