aws-samples / aws-samples/amazon-bedrock-client-for-mac

[FEATURE] Dynamic Context Loading for MCP

Open
#122 0 comments 0 reactions 1 assignee Claimed by @didhd View on GitHub
enhancement
Dominant language
Swift
Stars
446
Forks
45
PR merge metrics
No merged PRs in 30d

Description

**Feature description**
Dynamic Context Loading for MCP - A system that activates MCP servers on-demand based on conversation context, rather than loading all configured servers upfront. Each MCP configuration could include activation keywords and onboarding documentation.

**Problem it solves**
Currently, MCP implementations load all configured tools at startup. With multiple MCP servers connected, this can consume significant context window space before the user even starts typing. For example, 5 MCP servers might add 50,000+ tokens to every conversation, slowing response times and reducing output quality due to context dilution.

Additionally, AI assistants often lack framework-specific best practices when using tools, leading to trial-and-error patterns that waste tokens and time.

**Proposed solution**
Implement keyword-based dynamic MCP activation:

1. **Activation keywords**: Each MCP server config includes trigger keywords (e.g., `["database", "postgres", "query"]` for a database MCP)
2. **Lazy loading**: MCP servers initialize only when their keywords appear in conversation
3. **Context switching**: When conversation shifts topics, deactivate irrelevant MCPs and activate relevant ones
4. **Optional onboarding docs**: Allow users to attach markdown documentation to each MCP that loads alongside the tools, giving the model best practices for that specific toolset

Example flow:
- User mentions "payment processing" → Stripe MCP activates with its tools + usage guidelines
- User switches to "database schema" → Stripe deactivates, Postgres MCP activates
- Baseline context usage stays minimal

**Alternatives considered**
- Manual MCP toggling in settings (current approach) - requires user intervention
- Loading all MCPs always - wastes context window
- Separate "skills" or "rules" systems - fragments the configuration

**Additional context**
This aligns with the existing MCP support in the app and could leverage the current infrastructure. The UI could show which MCPs are currently active in the conversation, similar to how tool usage is already tracked. https://kiro.dev/blog/introducing-powers/

**Environment**
- macOS version: 14+
- Amazon Bedrock Client for Mac version: 1.4.2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.